You can’t be Agile
if your code sucks

Peter Gfader
twitter.com/peitor
My Mission
#1 Agile??
#2 Code & Craftmanship
About me
Peter Gfader

peter.gfader@zuehlke.com
http://blog.gfader.com
twitter.com/peitor
Agile
What is Agile for you?
http://agilemanifesto.org/
The Agile Manifesto invites wimpy-ness
"… Individuals and interactions over processes & tools…"
Yayy!! I don't have to follow those stupid processes any more!
"… Working software over comprehensive documentation…"
W00t!! Dump the documentation! I LOVE this agile stuff!
"… Customer collaboration over contract negotiations…"
I'm done when I'm done and I never have to say when!
"… Responding to change over following a plan…"
No plans! No project managers! No architects!

Where do I sign up?

© Alistair Cockburn
What is Agile for you?
What is all this stuff?

XP
Lean

RUP

SAFe

Agile
© Henrik Knieberg
Thinking tools

Tool

a.k.a. ”mindsets” or ”philosophies”

”anything used as a means of
accomplishing a task or purpose.”
- dictionary.com

Physical tools

Lean

Agile
Systems Thinking
Theory of Constraints

Toolkits

a.k.a. ”frameworks”
Scrum RUP XP
Kanban

Process tools

a.k.a. ”organizational patterns”

Product Owner role
Pair programming
Visualize the workflow
5

Dev
3

H

Test

Release

D

To do

C

2

G

3

Done!
A
B

K
FLOW

© Henrik Knieberg
© Henrik Knieberg
The illusion of a ”bad tool”

The old
tool
was
better!
Don’t blame
the tool!

© Henrik Knieberg
Compare for
understanding, not
judgement

Key
point

© Henrik Knieberg
Compare for
understanding, not
judgement

Key
point

Tools can be
combined
© Henrik Knieberg
• Know your Goal

Take-away points

o Why

• Agile/Lean are tools, not goals
• Don’t limit yourself to one tool
• Experiment & enjoy the ride
o Don’t worry about getting it right from
start
© Henrik Knieberg
• We won’t
RUP

XP
Lean

SAFe

Agile
© Henrik Knieberg
The important thing isn’t the process.

© Henrik Knieberg
The important thing isn’t the process.

The important thing is the process for
improving your process.

© Henrik Knieberg
The important thing isn’t the process.

The important thing is the process for
improving your process.

Continuous Improvement
© Henrik Knieberg
3 essential skills needed
regardless of process

Splitting the system into
useful pieces

Software
craftsmanship

Retrospectives

As a buyer
I want to save my shopping cart
so that I can continue shopping later

© Henrik Knieberg
3 essential skills needed
regardless of process

Splitting the system into
useful pieces

As a buyer
I want to save my shopping cart
so that I can continue shopping later

Software
craftsmanship

Retrospectives
3 essential skills needed
regardless of process

Splitting the system into
useful pieces

As a buyer
I want to save my shopping cart
so that I can continue shopping later

Software
craftsmanship

Retrospectives
Essential Skill:
Software craftsmanship
1) Software is never written
once and never changed
[LARM03]
2) How to slow down your
project?
Write crappy code
 Make code easier to read
Easy code to read
 Easy code to change
maintain
Why do you write bad code?
#1 reason for Bad code
We write bad code,
because we read bad code
Code Readings?
•
•
•
•

Code Reviews
Peer Reviews
Pair Programming
Open source
Good code is like a joke!
No need for explanation
#TODO: Code to read
https://github.com/nsubstitute/NSubstitute
https://github.com/techtalk/SpecFlow
https://github.com/sf105/goos-code
https://github.com/machine/machine.specifications
https://github.com/BjRo/xunitbddextensions
https://github.com/dtchepak/DaveSquared.StringsTheThing
#TODO: Review Code
•
•
•
•

In your team
With 1 peer
Open source
Brown bags – Lunch time discussion
Code Reviews
• Code, !Person
• Constructively propose changes
 Questions!
Code Reviews
• Code, !Person
• Constructively propose changes
 Questions!

• Review not only code
o Tests
o Build process
o ..
Code Reviews
• Code, !Person
• Constructively propose changes
 Questions!

• Review not only code
o Tests
o Build process
o ..

 Grow as a team
Instead of
“That lousy long method”

Say
“Why don’t you split that
method”

“I reviewed your code and
found 1,2,3 things to
change”

“Can you help me?”

“If you don’t want to do it. I
do it”

“Can I help you with this? I
think we can improve it”
#2 reason for Bad code
Nobody can write good code in 1 sit-in

-> Refactoring
it’s an art of designing code
#TODO Refactoring
https://github.com/NotMyself/GildedRose
https://github.com/jcbozonier/Refactoring-Katas
The little issue with
Refactoring?
Development With and Without Testing
Without Tests

• Don’t know our own quality
• Unclear what works and what
doesn't
• Unintended consequences of
changes remain hidden
• We are never done

With Tests

• Change and refactor without
fear
• Add new features faster

• Confidence that we didn't
break anything
• We can actually be done
Done = Tested!
Refactoring
+
Tests
=
?
Refactoring
+
Tests
=
Waste?? Overhead??
Test-Driven Development (TDD)
• Writing tests prior to writing the production code
• Test-Driven Development is
o
o
o
o

A design practice
A powerful way to avoid defects in software
A feedback loop for validating code changes
A way to write tests
REFACTOR

RED

GREEN
Test-Driven Development (TDD)
Goal is not to write tests
but to write good code

RED

REFACTOR

GREEN
What is Quality
“Why should I care?
We have a QA department!”
**** ADD PIC ****
How do you measure
Quality?
First Law of Programming

“Lowering Quality Lengthens
Development Time”
http://c2.com/cgi/wiki?FirstLawOfProgramming
Only Quality lets us go faster!
http://manifesto.softwarecraftsmanship.org/
Who?
Quality?
• Measure of how well the software is
designed and implemented
• Subjective
Quality?
•
•
•
•
•
•

LOC
Code Coverage
Class Coupling
Cohesion
Code Duplication
Cyclomatic Complexity
Quality: How to measure?
•
•
•
•
•
•
•

Highly subjective
Highly qualitative
Is the code readable, understandable?
Is the code verbose?
Variable/method names that are meaningful
Simple code that works
Does it have tests? What’s the coverage?
Quality: How to measure?
• Trends
Quality: How to measure?
• Trends
• “Output” over time
o Velocity - Trend
o Business Value - Trend
o Bug – Trends

• #TODO: How do you measure Business value?
Ways to Improve Quality
• Avoid Silo Thinking
o

•
•
•
•
•
•
•

Its not “us” vs “them”

Start early
Don’t Compromise
Schedule time to lower your technical debt
Make it work; make it right (right away)
Requires monitoring and changing behavior
Be willing to help and be helped
Devise lightweight non-bureaucratic measures
Simple Design == High Quality?
•
•
•
•

Passes its tests
Minimizes duplication
Maximizes clarity
Has fewer elements
http://c2.com/cgi/wiki?XpSimplicityRules
#TODO Visualize
•
•
•
•
•

Bug Trends
Build Status
Performance Report
Technical Debt
Code Quality
Visualize Technical Debt

http://verraes.net/2013/07/managed-technical-debt/
Build Monitor
Checkin Frequently
• Focus your work on small tasks
• Easier to describe what you did in your check-in
comment
• Clear code history
• Easier merging -> if you really need to branch and merge
• Fast code reviews
• Never get merge hell -> only give it :-)
http://blog.gfader.com/2011/12/tfs-see-your-application-grow-like.html
Team Efforts
• Avoid Shortcuts
• Take collective ownership
Team should own the code
• Promote positive interaction
• Provide constructive feedback
• Constant code review
Guantanamo Code Tool
• All code is guilty until tested innocent
• Do you have problems maintaining high test coverage?

• Send the untested code to
Guantanamo!
http://docs.codehaus.org/display/ASH/Guantanamo
Agile – the bar is rising

http://blog.gfader.com/2013/05/the-1st-principle-of-agile-manifesto-30.html
Our highest priority is to satisfy the customer

through early and continuous delivery
of valuable software
1st principle of the Agile Manifesto
Our highest priority is to satisfy the customer
through early and continuous delivery
of valuable software
1st principle of the Agile Manifesto
Recap
The important thing isn’t the process

The important thing is the process for
improving your process
Essential skills needed
regardless of process

Splitting the system into
useful pieces

As a buyer
I want to save my shopping cart
so that I can continue shopping later

Software
craftsmanship

Retrospectives
#TODO TO READ
E. Goldratt “The Goal”

S.Freeman, N.Price GOOS
#TODO References
•
•
•
•

•
•
•

Pragmatics of Agile Development
http://www.agiledeveloper.com/presentations/pragmatics_of_agile_development.pdf
Kanban VS Scrum
http://www.infoq.com/minibooks/kanban-scrum-minibook
Agile Software Development
http://www.agiledeveloper.com/presentations/AgileSoftwareDevelopment.zip
A Thinking Tool called Agile
https://sites.google.com/site/leanagileandscrum/lean-agile-scrum-conference2010/presentations-las-2010/00_Kniberg_Keynote.pdf?attredirects=0&d=1
The Four Elements of Simple Design
http://www.jbrains.ca/permalink/the-four-elements-of-simple-design
http://agilemanifesto.org/
http://manifesto.softwarecraftsmanship.org/
Now you
1.
2.
3.
4.

Download presentation
Search for #TODO
Get it done
Send me a tweet “I’m done”
Continue the conversation
peter.gfader@zuehlke.com
twitter.com/peitor
http://blog.gfader.com

You cant be agile if your code sucks

Editor's Notes

  • #2 Click to add notesPeter Gfader
  • #3 3 ingredients for success
  • #4 Wiekommeichzu Agile?1. Scrum/AgileSüdtirolProjekte: Alles gut -> ZumSchluss (Graph from xscd)Graph: Happiness, Definition Wahnsinn: Immerwieder das Gleichemacht, abereinanderesErgebniserwartet2. AgileMinimize Risk: Deployment dayFertigmitEntwickeln. Deploy -> Hardware ist da, OS und tools alles da. Deploy to Production.Funzt net. **TODO: Find the problem we had @AuctionsPlus, @POK, POK: IP filtering, ...
  • #5 Wiekommeichzu Scrum und CD?1. Scrum/AgileSüdtirolProjekte: Alles gut -> ZumSchluss (Graph from xscd)Graph: Happiness, Definition Wahnsinn: Immerwieder das Gleichemacht, abereinanderesErgebniserwartet2. AgileMinimize Risk: Deployment dayFertigmitEntwickeln. Deploy -> Hardware ist da, OS und tools alles da. Deploy to Production.Funzt net. **TODO: Find the problem we had @AuctionsPlus, @POK, POK: IP filtering, ...
  • #7 Develop relevant softwareDeliver value earlierCreate value fastWelcome changes and gapsOpen communicationEmpowering peopleKeep it simple
  • #10 2011 Snowbird
  • #12 Develop relevant softwareDeliver value earlierCreate value fastWelcome changes and gapsOpen communicationEmpowering peopleKeep it simple
  • #13 Purpose of this presentation is to clarify how some of these things fit togetherHow does agile look when done well?
  • #15 Pretty meaningless question right? Because the answer depends on your context. For eating meatballs the fork is probably best. For chopping mushrooms the knife is probably best. For drumming on the table either will do fine. For eating a steak you probably want to use both tools together. For eating rice... well... some prefer fork while others prefer chopsticks.
  • #16 Never blame the tool!
  • #17 Vergleichen um zuVerstehen und Lernen und nichtBeurteilen und Schlechtmachen
  • #18 Vergleichen um zuVerstehen und Lernen und nichtBeurteilen und Schlechtmachen
  • #19 Don’t love agile.Know your GoalFocus on WhyAgile/Lean are tools, not goalsTools sind nicht erfolgreich oder scheitern. Menschen sind aber.Es gibt kein gutes oder schlechtes Tool. Nur gute oder Schlechte Entscheidungen wenn, wo, wie und wieso wir ein Tool einsetzenDon’t limit yourself to one toolMix & matchCompare for understanding, not judgement.Experiment & enjoy the rideDon’t worry about getting it right from start. You won’t.The important thing isn’t your process.The important thing is your process for improving your process.
  • #20 Purpose of this presentation is to clarify how some of these things fit togetherHow does agile look when done well?
  • #26 - Communication Skills- Facilitator / ScrumMaster- Vision
  • #48 Having good tests is like have great brakes on a sports car. Good brakes allow us to go faster.We do not know the QualityFearless refactoring requires Tests. Refactoring is required to react on a changing worldWe are faster releasing the SWDone = Tested. No DoneDone!
  • #49 waste?
  • #51 Sometimes you don’t need well designed codeGoal is not to write tests but to write good code
  • #52 Sometimes you don’t need well designed codeGoal is not to write tests but to write good code
  • #54 Tester
  • #61 Go fast -> Go well
  • #63 Cyclomatic Complexity NumberGives an indication of degree of hardnessDoes not indicate degree of defectAddresses problems arising from large, low cohesive codeCode Size Rules check for the size of code and flags if it exceedsHow small is smallCode must fit into a screen (without lowering font size)[about 15 to 20 statements per method]