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.

I am doing a bit of research for my paper, and I have a general question to you guys.

Consider a design pattern or any commonly accepted, reusable solution for a particular problem. It doesn't have to have a name or be classified as an actual design pattern.

Why would you use it? What does it help you to accomplish? Give your reasons and argument them.

share|improve this question

closed as not a real question by Blrfl, MichaelT, Kilian Foth, gnat, Caleb Mar 25 '13 at 19:10

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

I would use it because it's a commonly accepted, reusable solution to the problem at hand. Did you expect a different answer? –  user16764 Mar 25 '13 at 18:12
I'm reading a book right now that differentiates between design patterns, domain patterns, and architecture patterns. The author suggests that these categories are informal but you should be aware of the context of the pattern. Are you referring to a design pattern in this sense or are you referring to the general concept of patterns? –  Mayo Mar 25 '13 at 18:46
I'm referring to patterns in more general sense, being very high-level, architectural, or lower-level, object-oriented design pattern. And indeed, one must be aware of the context/scope of the pattern. –  Kel Mar 25 '13 at 18:59
@Mayo Is it Patterns of Enterprise Application Architecture you're reading by any chance? –  Kel Mar 25 '13 at 18:59
You don't use design patterns. You solve a problem, in a way that's incidentally so popular it got named. –  delnan Mar 25 '13 at 19:06

4 Answers 4

Basically, it avoids re-inventing the wheel.

  • Faster time to market
  • Less Cost

A good example:

A bike rider notices his hands are cold. Being a smart person he decides to come up with a solution to keep his hands warm while riding his bike. He spends lots of time and effort coming up with his "hand warming system" which does keep his hands warm.

Confident, he shows up to the next ride ready to show all his friends his new "hand warming system". When he arrives, he notices his friends all have something on thier hands. When he asks he friends what they are and they respond: "They are gloves, for keeping your hands warm."

So, even though his "hand warming system" worked, he wasted a lot time and effort because there was already a proven solution available.

share|improve this answer
I like the example! –  Florian Margaine Mar 25 '13 at 18:28
Thank you! Considering the cost, on what level would you say it reduces the cost? Do you save resources (money? time?) on maintenance, production, both, something else? –  Kel Mar 25 '13 at 19:04
Cost reduction could be quite significant. For example, a pair of gloves cost $10. Imagine the cost of adding a hand warming system to a bike. Time and money both saved. Maintenance would be harder to tell. Also, consider using something well known versus a custom solution. Antyhing that isn't well known or standardized inevitably ends up costing more. –  Jon Raynor Mar 25 '13 at 19:19

A great advantage to using a design pattern is that other programmers should be able to easily recognize it (especially if you use good naming conventions).

For example, the Observer Pattern is well known. A second programmer coming along to maintain your code who is aware of the observer pattern is going to immediately have a high level understanding of what you're trying to accomplished once they start seeing Observer and Subject as interfaces/classes.

share|improve this answer

If I know that handing out newspapers is similar to handing out leaflets or cards, why bother trying to come up with a novel solution each time I am given such a similar task?

share|improve this answer

Why would I use a design pattern or commonly accepted and resuable solution for a kind of problem?

To solve the problem of course, with the added benefit that other programmers need less time to understand the commonly accepted solution for that kind of problem.

share|improve this answer
Exactly as in chess games where you initially choose from known opening sequences, cooking where every cook understands you if you say you're larding the meat, or airplane pilots going through their checklist. –  Jan Doggen Mar 25 '13 at 18:53

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