Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

Which design pattern do you think is the most popular?

share

locked by Yannis Rizos 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. More info: help center.

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.

1  
Do you mean GoF style design patterns? Or architectural patterns like MVC? –  Matt Olenik Sep 24 '10 at 14:31
2  
voted to close as not constructive - this is basically a poll. Unless someone has an empirical study to cite, the answers will all be guesses or favorites (or non-favorites) and the votes will reflect personal sentiments. The end result will be a list of design patterns with no depth. Hence, not constructive. –  Steven A. Lowe Mar 3 '11 at 21:17
show 4 more comments

16 Answers

up vote 39 down vote accepted

I'm pretty sure the most common is 'The Big Ball of Mud'. Unfortunately for us all.
http://en.wikipedia.org/wiki/Big_ball_of_mud

share
3  
@Arturo - That's one possible reason. Others: 1) Small project started by inexperienced programmer that is unexpectedly successful, and then grows beyond it's original purpose. 2) The tendency of inexperienced programmers being assigned to maintenance, who then don't have guidance or understanding of the original architecture, so they just hack stuff in, and it gets worse as system ages. 3) The team uses the wrong technology, or a new technology they are unfamiliar with and use it poorly on a new project, and it craters before the deadline :) –  Jay Sep 24 '10 at 16:06
1  
LOL - if I could add more points to you, I would. Excellent (and sad) observation. –  luis.espinal Feb 24 '11 at 15:18
show 1 more comment

MVC and its variations is definitely one of the top design patterns.

share
2  
I was going to say that the OP's question is rather silly (I still believe it is). However, your answer is pretty much right IMO. If there is one pattern (and its variations) that is pretty much used consistently, it is this one. +1 for your good answer. –  luis.espinal Feb 24 '11 at 15:15
add comment

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.

share
2  
It's even sadder when you consider many people consider the Singleton an antipattern! –  RichardOD Sep 24 '10 at 15:28
1  
@RichardOD, sad that people consider it one when it isn't, or sad that people use it when it's an anti-pattern? –  Matt Olenik Sep 24 '10 at 16:57
show 5 more comments

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).

share
1  
Funny, but I've never had the need to use a Singleton. If I need someplace to hold global state, I put it in a configuration file and use a normal class to access it. –  Robert Harvey Sep 24 '10 at 15:01
show 2 more comments

Facade

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.

share
add comment

Observer

If you've ever used an event. You've used Observer.

share
show 1 more comment

Decorator

Add functionality to an object at runtime through composition. My personal favorite.

Edit: Also Factory is probably one of the most common.

share
add comment

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).

share
add comment

Strategy Pattern

If you've ever used dependency injection, you've used the strategy pattern.

share
show 1 more comment

The most frequently used design pattern is, obviously, Spaghetti.

share
add comment

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.

share
add comment

Specification

I don't think it's listed in the GoF, but I use variations of it all the time.

share
add comment

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.

share
add comment

Along with my previous answer, I'm going to add a new one I ran into today from my beast of an inherited project:

Copy/Paste

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.

share
add comment

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?

share
add comment

Interpreter

Rarely implemented, often used. XPATH, XSLT, Regex, jQuery selectors, etc.

share
add comment

protected by Walter Feb 2 '11 at 23:29

Thank you for your interest in this question. Because it has attracted low-quality answers, posting an answer now requires 10 reputation on this site.

Would you like to answer one of these unanswered questions instead?

Not the answer you're looking for? Browse other questions tagged or ask your own question.