Total day of fun in the sun. Grabbed my 2 daughters and the family canoe mid-morning and paddled out to a sand bar in the middle of the Sarasota Bay that is only accessible by watercraft. Spent the bulk of the day BS’ing with others frolicking on the small oasis as the kids splashed around on what has to be one of the nicest days this year.
This past week I have been reading a new book, called Agile Software Development – Principles, Patterns, and Practices by Robert C. Martin. It’s a new book for me, but one that has been around since October 2002. I have only read about 100 of the 520 some odd pages, so it is too early to make any judgement calls on it. I have been doing somewhat of a chapter-by-chapter summary of it, so if you are interested in following my progress through it, you can read the following 3 initial posts on it:
- Agile Practices, Extreme Programming, and Test-Driven Development: Chapters 1 – 4
- Refactoring and Pair Programming: Chapter 5 and 6
- Agile Design: Chapter 7
So far I am pretty aligned with Darrell’s review of the book. The agile design material is really awesome. There is a lot of good coverage of the principles of object-oriented design and I have barely touched them. However, the code examples so far are lacking a bit. Although I do have to say that I really enjoyed the pair programming re-enactment to create an application to calculate the score of a game of bowling. It really makes me want to experience pair programming firsthand.
One of the things I thought was interesting so far was Robert’s description of Design Smells, which are essentially the odors associated with rotting software. These are different than refactoring code smells in that they apply at a higher (application) level, whereas code smells are more focused on a method, class, etc. Here is his list with a much more brief description of each:
- Rigidity – System is hard to change in even the most simple ways.
- Fragility – Changes cause system to break easily and require other changes.
- Immobility – Difficult to entangle components that can be reused in other systems.
- Viscosity – Doing things right is harder than doing things wrong.
- Needless Complexity – System contains infrastructure that has no direct benefit.
- Needless Repetition – Repeated structures that should have a single abstraction.
- Opacity – Code is hard to understand.
So yeah, you don’t want your applications to have those design smells and I would say this is about as good a list as I have found.
Interestingly enough, I feel like there is a relationship between these Design Smells and GRASP (General Responsibility Assignment Software Patterns) as described in Applying UML and Patterns by Craig Larman. GRASP is a series of 9 patterns / principles to help you with the most fundamental aspect of OO Design, which is assigning responsibilities to objects. I have begun, but not finished, to list all 9 of the GRASP Patterns here on this blog. I think if you master those principles you will be able to eliminate or lessen the chance of having those design smells.
As luck or some weird coincidence would have it, I just came across a recent article by Robert that explains his principles of object-oriented design, which I can only guess help you avoid the design smells mentioned above. I am familiar with the principles, but I didn’t read them on his website because they are the same principles that Robert talks about later in the book. The first 5 principles on class design should interest all developers:
- The Single Responsibility Principle – A class should have one, and only one, reason to change.
- The Open Closed Principle – You should be able to extend a classes behavior, without modifying it.
- The Liskov Substitution Principle – Derived classes must be substitutable for their base classes.
- The Dependency Inversion Principle – Depend on abstractions, not on concretions.
- The Interface Segregation Principle – Make fine grained interfaces that are client specific.
Again, you can read more about those 5 principles and others on Robert’s website here. As I get further through the book I will touch base on them in future blog posts as well as the GRASP patterns that I have not forgot about.