Why design is hard (and interesting) - No Fluff Just Stuff

Why design is hard (and interesting)

Posted by: Venkat Subramaniam on July 14, 2006

A couple of days ago a young intelligent man walked into my office with a design problem on hand. He
said he decided to use SRP (Single Responsibility Principle) and so has separated each concern into
separate classes. The result, he had about eight classes to solve that problem. He wanted to know if
he's in the right direction.

I truly believe that agile development will become a mere act of code hacking if we ignore good design
principles.

While SRP, DRY (Don't Repeat Yourself), OCP (Open Closed Principle), LSP (Liskov's Substitution
Principle), and other principles with TLAs (Three Letter Acronyms) have been very useful, the challenge
is figuring out if they are applicable. We need to figure out if we are using the principles at the right time
and for the right reason.

In this particular instance, the bright programmer had taken the time to learn the concepts and principles
as he was genuinely eager to learn designing. However, he was struggling to find if he is doing things
right (that is key to learning?seeking feedback to see if we have things right).

The challenge in this case is while SRP is a good principle to use, learning what that concern separation
is not easy. We discussed if the way he had separated the concerns actually made the code more
cohesive, or less. In a few minutes, he was beginning to see that the separation of the concern may not
be as clear cut as he had thought. We eliminated a number of classes. Then we discussed about the
possibility of extensibility (based on what all this application should do) and figured that introducing an
interface may be useful. We then set out to throw in some code to try out a few concepts we discussed.

That is the beauty of design. It is hard to do it as the design greatly differs based on the perspective.
That is one of the reasons why I think designing in isolation is a terrible idea.

How do we learn good design? Are there books and articles on the topic? Yes there are and we should
certainly take time to read them first. However, the best way to learn design is to do it and to do it with
someone. If you are working on a design (and you are if you?re writing any form of code), then seek
some input from a colleague you respect. You will find that this becomes a learning experience for both
of you. And, the design will evolve to benefits from the right use of good design principles.

Venkat Subramaniam

About Venkat Subramaniam

Dr. Venkat Subramaniam is an award-winning author, founder of Agile Developer, Inc., creator of agilelearner.com, and an instructional professor at the University of Houston.

He has trained and mentored thousands of software developers in the US, Canada, Europe, and Asia, and is a regularly-invited speaker at several international conferences. Venkat helps his clients effectively apply and succeed with sustainable agile practices on their software projects.

Venkat is a (co)author of multiple technical books, including the 2007 Jolt Productivity award winning book Practices of an Agile Developer. You can find a list of his books at agiledeveloper.com. You can reach him by email at venkats@agiledeveloper.com or on twitter at @venkat_s.

Why Attend the NFJS Tour?

  • » Cutting-Edge Technologies
  • » Agile Practices
  • » Peer Exchange

Current Topics:

  • Languages on the JVM: Scala, Groovy, Clojure
  • Enterprise Java
  • Core Java, Java 8
  • Agility
  • Testing: Geb, Spock, Easyb
  • REST
  • NoSQL: MongoDB, Cassandra
  • Hadoop
  • Spring 4
  • Cloud
  • Automation Tools: Gradle, Git, Jenkins, Sonar
  • HTML5, CSS3, AngularJS, jQuery, Usability
  • Mobile Apps - iPhone and Android
  • More...
Learn More »