PHP Developers Network

What's with design patterns
Page 1 of 1

Author:  Live24x7 [ Mon May 28, 2012 5:21 pm ]
Post subject:  What's with design patterns

I have finally taken the quantum leap from procedural to to OOP.

1) i am reading books on OOP
2 ) reading codes designed in OOP

Atleast they have started making some sense to me now, though not yet coded anything n OOP so far

Next, design patterns (the gang of four book) is something i have been influenced to explore.
I read a little on the web but could not make much sense of its practical usage.

My Question

1) Where does 'design patterns' fit in the entire OOP schema ?>

Are they necessary to know ?

Author:  Christopher [ Mon May 28, 2012 10:30 pm ]
Post subject:  Re: What's with design patterns

Author:  Live24x7 [ Mon May 28, 2012 11:44 pm ]
Post subject:  Re: What's with design patterns

Thanks a lot :)

I read yesterday that design patterns are to programming what scales are to music :)

Author:  requinix [ Tue May 29, 2012 1:43 am ]
Post subject:  Re: What's with design patterns

Author:  Live24x7 [ Tue May 29, 2012 11:33 am ]
Post subject:  Re: What's with design patterns

wow ..that makes it even clear :)

Author:  kon [ Tue May 29, 2012 2:24 pm ]
Post subject:  Re: What's with design patterns

Design patterns are great for solving common problems and to have a common ground deciding a solution with others. Of course we shouldn’t learn those and think them as golden rules, almost each programming real life problem is not as simple and distinctive as the problems design patterns solves. More over if you have in your mind a premade solution there is the danger to modify the problem fitting your solution making the all design really mess. Don’t get me wrong, design patterns have their place in our knowledge, but after knowing as many of them, test and use them where each fit , you can consider them as your programming experience and not holly grails.

Author:  Celauran [ Tue May 29, 2012 2:29 pm ]
Post subject:  Re: What's with design patterns

Author:  Live24x7 [ Mon Jun 04, 2012 2:16 am ]
Post subject:  Re: What's with design patterns

@kon - thanks - very nicely explained.
That means - this is not something compulsory for a coder to know.
Infact knowing them may stifle creativity and the ability to search for original solutions.

@celaurun -
i had never heard of the term 'golden hammer'
read about it and couldn't have agreed more - if all you have is a hammer, everything looks like a nail

Author:  Christopher [ Mon Jun 04, 2012 3:56 pm ]
Post subject:  Re: What's with design patterns

Author:  kon [ Mon Jun 04, 2012 4:55 pm ]
Post subject:  Re: What's with design patterns

Christopher I would really like to learn your opinion about it, maybe I will learn something new (and I am not kiting). I agree with your first post and with Wikipedia ( ) . I am not advice anyone not to learn design patterns, the opposite. We should know them and use them a lot in experiment projects and learn their place in real life programming. For example I believe that we all have seen “Singleton” overused and not in right context. Why they do that? I believe simple because they had a “solution” , they modify the problem to fit the solution. So in that way it is a golden hammer (thank you celaurun for making me read more about the term). One more good link about design patterns is .

Author:  Christopher [ Mon Jun 04, 2012 7:03 pm ]
Post subject:  Re: What's with design patterns

I don't think what you are describing is a golden hammer. What you are describing is the saying "when all you have is a hammer -- everything looks like a nail." You give a good example with the Singleton. Programmers usually start out by using a lot of global variables. It is the obvious solution, just not a good practice. So when they come to OOP they look for a design that will work just like their previous bad design. Hence the Singleton is misused. That is not the fault of the Singleton. The confusion is between thinking you want one instance of a variable (which is not the Singleton) and when you want only one instance of a class (which is a Singleton). The latter concept implies a solid understanding of classes that people new to OOP don't have. And if they did even a little reading about the Singleton pattern they would learn that it is not something you should use very often. There are warnings on most descriptions. They might even learn what an anti-pattern is!

I just think it doesn't make much sense to say, "People sometimes don't understand the best solutions to common problems, therefore they should keep using bad solutions." Design patterns are simply best practice solutions to design problems. They are misused because software design is difficult, not because patterns are somehow bad or a problem.

I would recommend that Live24x7 read about every pattern she/he can find. I recommend reading the GoF patterns first (search for them, here are a couple inks or Then would read Fowlers EAA patterns ( It takes years to understand when and how to apply them -- so you might as well start now. Design is very counter-intuitive so you need to slowly unlearn all the things you figured out on your own.

Author:  John Cartwright [ Wed Jun 27, 2012 4:43 pm ]
Post subject:  Re: What's with design patterns

Others have covered this topic well, so I won't regurgitate anything. Just want to say design patterns are not a concept universally you can apply to fix bad design. It is just as important to know when to use them as it is to know what they are.

As you learn more about them, you may even find you have solved problems with design patterns without even knowing it, because it made sense, and likely simplified your design.

Page 1 of 1 All times are UTC - 5 hours
Powered by phpBB® Forum Software © phpBB Group