RailsConf 2007 Sessions: Clean Code
Robert Martin’s session on clean code has already reshaped my development practices. Bob provided an excellent overview of the use of Test-First practices and nailed down many of the gaps in my understanding. His demonstration of TDD without making breaking changes was especially interesting, serving to affirm the mantra “I am not allowed to make a change that breaks the system.”
Clean Code – Robert Martin, Object Mentor
Description: Ward Cunningham once said that Smalltalk failed because it was too easy to make a mess. Professionals don’t make messes. This talk demonstrates the techniques and heuristics for keeping Ruby code clean and stresses the attitude of professionalism and craftsmanship that can keep Ruby from Smalltalk’s fate.
What are we going to do about bad code?
- The grand redesign in the sky
- 10 years to develop the new system
- incremental improvement
- always check code in better than you checked it out
- never let the sun set on bad code
- test first => “test obsessed”
- provides the necessary flexibility
- understand the open closed principle => open for extension, closed for modification
- Time to refactor => things are about to get smelly.
- started out clean,
- built up over time
- initial structure didn’t scale well
- the more it grew the worse it got
- eventually I had to stop
- iterating is where its at
TDD => Keep the system running at all times!
I am not allowed to make a change that breaks the system. Every tiny change I make will keep that system working.
Let’s refactor
- Principle of least surprise
- tiny steps => change each variable type, then run the tests
- shrink the granularity of your development
- meta-programming to build marshallers only when you need them
- create a barrier between things that change and things that don’t
Is it worth it?
- crafting good solutions
- clean it up as soon as it gets messy
- the dinner parable: get up and walk away from the dinner table or keep your dishes clean all the time
- bad schedules, requirements, team dynamics can all be fixed
- bad code rots ferments and becomes an inexorable weight that drags the team down.
Professional Behavior
- The “Green Band” on his wrist that says “Test Obsessed”
- Professionals write their tests first
- Professionals keep their code clean
- Professionals know that the only way to go fast is to go well.
- making things a little bit nicer => the check-in rule
Contact
About this entry
You’re currently reading “RailsConf 2007 Sessions: Clean Code,” an entry on planet jerry!
- Published:
- May 23rd 03:41 PM
- Updated:
- May 23rd 03:48 PM
- Sections:
- Ruby and Rails



0 comments
Jump to comment form | comments rss [?]