Jeremy D. Miller -- The Shade Tree Developer

Sponsors

The Lounge

Wicked Cool Jobs

Syndication

News

Advertisement

Images in this post missing? We recently lost them in a site migration. We're working to restore these as you read this. Should you need an image in an emergency, please contact us at imagehelp@codebetter.com
Just because it's in a patterns book...

I'm picking on a commenter here a little bit, and he probably didn't mean it this way, but it provided the impetus.

Don't ever assume a solution is correct for your problem just because it's a pattern in a book on your shelf.  Heck, the GoF book has a full chapter on the Singleton pattern, one of the leading sources of painfully tight coupling in enterprise systems.  Patterns are just things that reoccur in code.  Not good, not bad, just patterns.  Any given pattern is probably useful in certain situations and harmful in others.  Just because Fowler or the Gang of Four or the POSA guys wrote about a pattern doesn't magically make that pattern a good solution anywhere you feel like sprinkling it into your design.

When you learn about design patterns you absolutely have to pay attention to the discussion on when and why to use a pattern.  It also helps to understand the trade offs when there are competing patterns.


Posted Mon, Oct 15 2007 9:16 AM by Jeremy D. Miller
Filed under: ,

[Advertisement]

Comments

Joe Ocampo wrote re: Just because it's in a patterns book...
on Mon, Oct 15 2007 10:51 AM

Gospel vs Guidelines mentality.

A majority of our industry interprets guidelines as Gospel. Then we(coaches) spend the remainder of our time putting them through rehab.

Jeremy D. Miller wrote re: Just because it's in a patterns book...
on Mon, Oct 15 2007 11:27 AM

@Joe,

Very true.  As coaches though, we really need to explain "the why" anytime we give out any kind of guidance.

Jeff Doolittle wrote re: Just because it's in a patterns book...
on Mon, Oct 15 2007 2:18 PM

This is why I recommend Kerievsky's Refactoring to Patterns (www.amazon.com/.../0321213351).  

From page 29: "Good designers refactor in many directions, always with the goal of reaching a better design."

The goal should never be "wow, look at all the cool patterns I used" but rather, "look how I was able to use well-known practices to create an elegant and maintainable design."  Patterns for patterns' sake is folly.

Joe Ocampo wrote re: Just because it's in a patterns book...
on Mon, Oct 15 2007 4:10 PM

But what about the pattern thumper who has the GOF patterns memorized and strictly has a myopic view of the design.  He holds his GOF high in the air and sacrifices a key board and mouse to it every week.  All code must factor to the GOF there is no other way.  You will find peace and serenity in the GOF.  If it isn't in the GOF than you are going to hell!  Yeah that guy.

Let us pray now..... ahmmmmmmm ahhmmmmmm.

This takes him out of the job and goes against his very creed.

Object Bigot wrote re: Just because it's in a patterns book...
on Mon, Oct 15 2007 8:47 PM

In software development as in life, many people hold the persistent belief that there is one true book out there that will tell them all they need to know. If I can just find this book all my problems will be solved! Hallelujah!

People are basically lazy and have no interest in knowing 'why'. Someone should start a crusade to burn all copies of this GOF book. The Singleton pattern is pure evil and must be stopped at all costs!!

Russell Ball wrote re: Just because it's in a patterns book...
on Mon, Oct 15 2007 10:48 PM

@Jeremy - Well said.

"Value the Why over the How" should be one of the alt.net tenets. A solid principle that is misapplied has more potential to wreak havoc than all the drag-n-drop tools in the world. It also has the unfortunate side affect of turning people off to legitimate sources of knowledge like the GoF patterns because people get jaded after seeing them misapplied so often.

Jeff Brown wrote re: Just because it's in a patterns book...
on Tue, Oct 16 2007 2:51 AM

GoF offers a useful perspective on recurring design problems, it is not intended to be prescriptive.  If it were then I'm sure there'd be a spiffy "Refactor Now" button in your IDE to apply all of the *cough* "correct" refactorings for you.  ;-)

Glenn Block wrote re: Just because it's in a patterns book...
on Tue, Oct 16 2007 4:10 AM

People often forget that Patterns came second, not first. If you could read the 'Genesis' of Patterns it would be 'In the beginning there were solutions, then people looked at those solutions, saw common ways of solving problems and thus patterns were born". The reverse which is the misconception starts with something along the lines of "In the beginning there were patterns...".

DotNetKicks.com wrote Just because it's in a patterns book...
on Tue, Oct 16 2007 4:37 AM

You've been kicked (a good thing) - Trackback from DotNetKicks.com

Mark Heath wrote re: Just because it's in a patterns book...
on Tue, Oct 16 2007 6:19 AM

well said Jeremy

the Singleton pattern has singlehandedly turned the project I am working on into an horribly tightly coupled sprawling monster. its the only "design pattern" that many of the developers can name

Vikas Kerni wrote re: Just because it's in a patterns book...
on Tue, Oct 16 2007 9:19 AM

Patterns are solutions to a problem in a particular context.

Generally some people forget the context part.

Nikola Malovic wrote re: Just because it's in a patterns book...
on Tue, Oct 16 2007 2:19 PM

I totally agree that patterns should be treated more as principle and not as law.

For e.g., for me composite pattern is an type with the collection property of the same type, command is just a "traveling delegate" etc...

The patterns are common solutions to common problems, but they should be used only if there is no other "painless" way to do the same thing without patterns because they introduce additional complexity etc...  

book » Just because it's in a patterns book… wrote book » Just because it's in a patterns book…
on Wed, Oct 17 2007 7:29 AM

Pingback from  book » Just because it's in a patterns book…

Pawel Lesnikowski wrote re: Just because it's in a patterns book...
on Wed, Oct 17 2007 10:18 AM

It's not about the patterns but about refactoring to them.

That's why the Kerievsky's book is so good. It really helps you to create the ability to see paths in your code, that can take you to different patterns.

And as with paths in a wood, they can take you to a very gloomy and scary places.

But seeing those paths often helps in asking yourself a question "why?" Why should I implement  this in such way? Why is this solution better then the other one?

ThemePassion - Best stuff about design! » Just because it's in a patterns book… wrote ThemePassion - Best stuff about design! » Just because it's in a patterns book…
on Mon, Oct 29 2007 10:48 PM

Pingback from  ThemePassion - Best stuff about design! » Just because it's in a patterns book…

Lexapro. wrote Lexapro.
on Fri, Jul 18 2008 12:04 AM

Lexapro.

Add a Comment

(required)  
(optional)
(required)  
Remember Me?
Devlicio.us