Which design pattern do you think is the most popular?
closed as not constructive by ChrisF♦ Sep 1 '11 at 21:19
As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance. If this question can be reworded to fit the rules in the help center, please edit the question.
locked by yannis May 11 '13 at 22:16
This question exists because it has historical significance, but it is not considered a good, on-topic question for this site so please do not use it as evidence that you can ask similar questions here. This question and its answers are frozen and cannot be changed. See the help center for guidance on writing a good question.
Read more about locked posts here.
I'm pretty sure the most common is 'The Big Ball of Mud'. Unfortunately for us all.
MVC and its variations is definitely one of the top design patterns.
If you're talking about Gang-of-Four design patterns I would have to say Singleton. This is a really sad state of affairs - almost as if programmers hear about the magic of design patterns and then simply stop after the first one.
If you're talking about architectural-style patterns (in other words, design patterns which span multiple classes or layers) I would have to say MVC. A few other popular ones are the repository pattern and service-locator.
If you've ever used an event. You've used Observer.
Add functionality to an object at runtime through composition. My personal favorite.
Edit: Also Factory is probably one of the most common.
Think of any REST interface like Twitter or the SO APIs. It's hiding a bunch of back end stuff that, at least in twitters case, can be horribly complex.
Do I care which db tables @apklusk's tweets are stored in? And that it has a fast cache? And that @shemnon has such low readership the tweets are always out of memory? That's the magic of the Facade.
If you've ever used dependency injection, you've used the strategy pattern.
Why has nobody mentioned the iterator yet? Especially with all the maps that make up complex data structures... its the one I use the most. Or are we talking about patterns that we re-implement?
I am surprised no one has mentioned the Factory pattern, in my experience that is one of the most used (and also most abused) of the patterns out there. If not first, probably the singleton should be first, I would have thought this would be a close second.
Along with my previous answer, I'm going to add a new one I ran into today from my beast of an inherited project:
While debugging I ran into a piece of code calling 2 similarly named functions:
if(x) Func1 else Func2
Func1 and Func2 had the same parameters. I pulled them out and diffed, and they are 100% the same except for Func1 calls Func3 and Func2 calls Func4. I pulled those out and diffed them. 100% the same, except for 1 line. So a previous programmer decided to copy and paste two 50-line-nested functions, instead of adding a flag parameter, to 2 private functions used in exactly 1 place. It makes me want to cry.
Talking about Gang-of-Four design patterns, I can't think of a program that does not use the Observer pattern. Also, as Jaco mentioned, Singleton is highly used too, unfortunately it has become a hammer (any programmer uses it even if it's not completely needed).
Rarely implemented, often used. XPATH, XSLT, Regex, jQuery selectors, etc.
I'm surprised no one has said "Builder" yet. Or "Adapter". They're probably not as exotic as some of the other ones mentioned, but I use them all the time. Factory and Abstract Factory are very common as well (but they're already taken).
I don't think it's listed in the GoF, but I use variations of it all the time.
The most frequently used design pattern is, obviously, Spaghetti.
At the software design level, I would argue that Composite, Strategy and Template (and to a lesser extend, Factory) are the most widely usage. For the last decade or so we have seen a preference for composition over inheritance when building our systems using a OO design. As a result, combination of the patterns just mentioned play a much more important role than all others IMO.
Architecturally, I'd argue for MVC on the enterprise, and patterns based on state machines on the embedded side of things.