Drawing Blanks

Premature Optimization is a Prerequisite for Success

Single Responsibility

leave a comment »

David Cooksey wrote some interesting observations on The Dangers of Single Responsibility in Programming (continued here ).

I view the SRP as one of the most important design principles, because it gives birth to loose coupling and reuse.
It can be applied on the OOD pattern level, as well as on the higher levels: layering, deployment packaging, and multi-tier architecture.
Obviously, it can be harmful when misinterpreted and misapplied. And David gave a good description of how this can happen.
Interestingly, in my career, I have very rarely encountered the SRP abuse. Much more frequently I saw designs that could definitely benefit from applying the SRP.
Can we say that “premature application of design principles is the root of all evil”? Well, yes and no. On one hand, the whole point of design patterns is that you apply them in anticipation of change, so they have to be “premature”. On the other hand, good patterns often emerge when you refactor. I’d say, it’s not possible to arrive to a well balanced design without constant refactoring. You need to both anticipate the change and embrace the change. This is the Zen of Design.

Here is a Zen quote about a pattern of two loosely coupled interacting classes:
“Just think of the trees: they let the birds perch and fly, with no
intention to call them when they come
and no longing for their return when they fly away.”
(Zen Quotes, 470-543 AD)

“Design pattern” is an anagram of “Departing nest”, found via Xworder.

Advertisements

Written by bbzippo

11/20/2009 at 5:58 pm

Posted in programming

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: