22 November 2006

Balanced Design

Like most thing in life we have to choose, become, behave in a balanced way. Always there are consequences opting an extremity. Similar to Statistics where it can be shown in a graph like the Gaussian Distribution:

This also can be seen in language programming (i.e. the level of encapsulation, factorization, etc.) and even in design. The classic book Design Patterns from GoF identifies 23 patterns cataloging them under 3 classifications (creational, structural, behavioral).

The level, granularity and quantity you use them depends on several factor, nevertheless it is not advisable apply to used all of them at once, like in the following interview Eric makes mention of a similar case.

Do not start immediately throwing patterns into a design, but use them as you go and understand more of the problem. Because of this I really like to use patterns after the fact, refactoring to patterns. One comment I saw in a news group just after patterns started to become more popular was someone claiming that in a particular program they tried to use all 23 GoF patterns. They said they had failed, because they were only able to use 20. They hoped the client would call them again to come back again so maybe they could squeeze in the other 3.

Trying to use all the patterns is a bad thing, because you will end up with synthetic designs—speculative designs that have flexibility that no one needs. These days software is too complex. We can’t afford to speculate what else it should do. We need to really focus on what it needs. That’s why I like refactoring to patterns. People should learn that when they have a particular kind of problem or code smell, as people call it these days, they can go to their patterns toolbox to find a solution.

How to Use Design Patterns A Conversation with Erich Gamma,

From Ajax in Action book called this symptom (or condition) of overused of patterns as paralysis by analysis.

We can conclude, First try to make your first effort coding (of course there is analysis and design before, but we are stand at development and trying to refactor the solution) unless you have already the experience to use a known pattern to a particular problem then try to use some pattern from the catalog, and use them carefully, remember the first and final idea is to make things more simple, elegant and not chaos.

No comments :

My Blog List

Blog Archive

There was an error in this gadget


The views expressed on this blog are my own and do not necessarily reflect the views of Oracle.