Continuous Design - To Avoid Technical Cruft

leena

April 15, 2017

In my previous post, I referred to the below four rules of Simple Design to reduce the code getting messy or becoming cruft.

The first 3 rules are self-explanatory but the fourth one is confusing and contradictory especially with related to SOLID principles and design patterns. It conveys the principles YAGNI and Last Responsible Moment i.e. don’t do anything assuming that it might be required in future.

Design Incrementally

Agile recommends to do design continuously and emerge your design instead of doing a Big Design UpFront (BDUF) and recommends to Do The Simplest Thing That Could Possibly Work.

The following is the excerpt from XP Explained Book by Kent Beck on Incremental Design.

XP teams can meet their human need for immediate and frequent success as well as their economic need to defer investment to the last responsible moment. Some of the teams who read and applied the first edition of this book didn’t get the part of the message about the last responsible moment. They piled story on story as quickly as possible with the least possible investment in design. Without daily attention to design, the cost of changes does skyrocket. The result is poorly designed, brittle, hard-to-change systems.

The question is not whether or not to design, instead the question is when to design. The incremental design suggests that the most effective time to design is in the light of experience.

If small, safe steps are how to design, the next question is when to improve the design. The simple heuristic I found helpful is to eliminate duplication. I have the same logic in two places, I work with the design to understand how I can have only one copy.

Emergent Design and Continuous Design

Emergent Design - popularised by Neal Ford - the design emerges by following Last Responsible Moment and Idiomatic Patterns. Refer to his 15 article series, which talks about the same. I will write about the same, especially about the Idiomatic Patterns, in another post.

Continuous Design was the term given by James Shore. He explains the same as:

I prefer the term continuous design because it emphasizes the core of the process: continuously taking advantage of opportunities to improve your design. When you discover a design flaw, you fix it. When a new feature doesn’t fit, you update the design.

Summary

Instead of doing a big bang design phase, refactor the code meticulously by applying the Boys Scout Rule. Use tools to identify Cyclomatic Complexity and Afferent Coupling in the code. Follow Test Driven Development which helps to do enough design required for the current requirement. Test coverage gives the confidence to refactor the code.

References

*This is an updated version of an earlier post** -** What is Agile Design*?