Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Hi I am learning design patterns from a book . How to figure out the actual production code where it is implemented .

For example , if I am learning strategy pattern , it might be implemented in Spring framework . But how to go and search there and see it .

Do you guys have any easy ways of finding such stuff ?

share|improve this question
Have you read the J2EE BluePrints documentation yet? Please read some of that and then update your question with specific links or references. – S.Lott Mar 29 '11 at 13:38
up vote 2 down vote accepted

You often don't need to see the code to have a good idea of what pattern is being implemented. What's important is how the classes interact with other objects, and that you can deduce from looking at its Methods and Properties.

For example, lots of C# and Java Libraries have classes where there is not a constructor for the class, but there is a "CreateWidget()" function which returns a new Widget dependent on some parameters you pass that function. That is an example of a "Factory" pattern.

share|improve this answer

It's the other way around. You shouldn't code based on a design pattern. Pattern emerges in your code. It's then you make the code more general and make it based on a design pattern. When you start repeating yourself then you should ask your self if there isn't a pattern that should fit the problem.

share|improve this answer

In general Books about design patters show an actual implementation in some language (Like Gamma's Design Patterns).

If your looking for implementations of design patterns on a certain software its a bit harder because each implementation not always follows the exact same patter. I think one way to find them is trying to look for parts of the software that resolv esome kind of generic problem (like rendering a window is most probable that uses a composite pattern).

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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