Introduction To Design Patterns

27/10/2009

Pattern is a defined, used and tested solution for a know problem. Design patterns is all about re-use. Software design patterns evolved as a subject of study only when object oriented programming started becoming popular. OOPS and design patterns became inseparable.

In OOPS, we should have well defined boundaries for objects. That is every object should have its roles and responsibilities well defined. Then at next level, we should have a clear interaction plan between objects. If you design a OO software with the above principle, then by default you will be following some of the already defined design patterns.

A formal definition for design patterns, “A design pattern addresses a recurring design problem that arises in specific design situations and presents a solution to it” (Buschmann, et. al. 1996)

Java widely uses design patterns in its APIs. It started as early as Java 1.2 in java foundation classes. By then you can see the widespread use of commonly know design patterns in collections framework and IO packages. When I say commonly known design patterns, I mention about the set of 23 design patterns by Gang of Four (GOF). Gamma, Helm, Johnson and Vlissides known as Gang of Four (GOF) published a book “Design Patterns — Elements of Reusable Software” (1995) based on their series of technical meetings. It is one of the best seller in computer science books till date.

In China gang of four means different set of people. Jiang Qing (Mao Zedong’s fourth wife), Zhang Chunqiao, Yao Wenyuan, and Wang Hongwen were very popular leaders of cultural revolution. They almost seized power after Mao Zedong’s death. But they were finally arrested and imprisoned for life.

Our GOF divided the 23 design patterns into three types creational design patterns, structural design patterns and behavioral design patterns.

Creational design patterns can be used to instantiate objects. Instead of instantiating objects directly, depending on scenario either X or Y object can be instantiated. This will give flexibility for instantiation in high complex business logic situations.

Structural design patterns can be used to organize your program into groups. This segregation will provide you clarity and will enable you for easier maintainability.

Behavioral design patterns can be used to define the communication and control flow between objects.

Following this post, I have planned to write a series of article on these design patterns with java source code examples and UML diagrams. Looking forward to your comments.

Its really a good blog for the people who are looking for java tutorials.
I suggest all to go thru this.
And owner, plz give some more elaborated description for all the topics so,no need to go to another site for reading this.

Srikanth Reddy Sanivarapu on November 6th, 2009 4:14 pm

Thanks Srikanth. I am working on elaborate and detailed tutorials nowadays. Also, I have plans to update already posted tutorials with more details and sample java source code.

Joe on November 6th, 2009 4:40 pm

Even i like all your elobrated description and all topics is giving depth knowledge .. Please explore also on j2ee tech like springs ..hibernate and also server side like weblogic , websphere

Regards
Nilesh

Nilesh on March 14th, 2010 7:50 am

Hi Joe,

Nice explanation. Can you please post a topic that covers entire Design Pattern in one stroke. This need not be an elaborate one, but would be useful for those who are new to Design Pattern. Just to understand each in a simpler way. If base is strong, probably we can explore more in days to come.

Thanks and Regards
Srikanth S

Srikanth S on July 6th, 2010 7:26 pm

Hi Srikanth,

I am working on posting about all design patterns. But doing everything in one go will be quite difficult. You can surely expect me to cover as much as design patterns quite soon.

Thanks,
Joe.

Joe on July 6th, 2010 7:39 pm

Hey Srikanth,

When can we expect more on Design pattern ?
Really waiting for the same.

Thanks in advance

Harish Dewangan on July 27th, 2010 7:27 am

Nice I appreciate you ..keep posting sir..

Sujeet on November 21st, 2010 3:08 am

This blog is useful .And can we expect on more Design patterns?

Thanks
nag

Nagender on February 3rd, 2011 6:36 pm

Hi Joe,

Nice blog.. i really love this.. kindly post more .j2ee tech..like taking a simple project and covering all most, all important topics by pratical means(Don forget to post screen shots of those…).Do the same using a frame work(Struts or Spring).

Thanks in advance..

Anand on February 6th, 2011 9:25 am

This is really a nice article. You explained the concept in very easy and understandable language. It would be really great if you can give examples of Java API (internally) using design patterns.

Thanks,
Shital

Shital on April 12th, 2011 5:12 pm

[...] Pattern 02/05/2011Singleton design pattern is the first design pattern I learned (many years back). In early days when someone asks me, “do you know any design [...]

Singleton Pattern&hellip on May 7th, 2011 7:06 am

[...] 17/05/2011To extend or modify the behaviour of ‘an instance’ at runtime decorator design pattern is used. Inheritance is used to extend the abilities of ‘a class’. Unlike inheritance, [...]

Decorator Pattern&hellip on May 17th, 2011 12:04 am

[...] design pattern is the first design pattern I learned (many years back). In early days when someone asks me, “do you know any design [...]

Singleton Pattern in java&hellip on July 24th, 2011 12:12 pm

It really gud article for beginners easy to understand.

Himanshu on August 1st, 2011 3:51 pm

Joe, Good information on design patterns.

Anonymous on August 18th, 2011 9:58 am

hi,

i have a question related to java :
is there a way to create a sdk (exported to a jar file) while having multiple packages and classes in it, so that only a part of its public classes and methods will be available to the programmer who use them?
maybe a design pattern for it?

i’ve read about it over the internet, and it seems that this question is very rare . how could people create sdk’s like that ? did they use a special tool, or did they all flatten all of the packages into one package?

android developer on September 10th, 2011 9:49 pm

Really impressive.
Can you please explain Business Deligate Design pattern?

Anonymous on October 16th, 2011 10:40 am

plz eloborate the J2EE technologies like
structs and hibernates.
Difference between structs-1 and atructs-2.

jagadeesh on November 29th, 2011 8:38 am

I love this article and looking forward for such a great articles from you…

Your work is greatly appreciated…

THANK YOU SO MUCH FOR ALL YOU DO…

Anonymous on January 9th, 2012 7:36 pm

Hi Srikanth, why can’t post about the J2ME as you are sharing the knowledge about Java ..

Meher Sagar on January 23rd, 2012 2:51 pm

Sorry for giving wrong name JOE..

Meher Sagar on January 23rd, 2012 2:52 pm

[...] design pattern is one among the other design patterns that promote loose coupling. It emphasizes one more important aspect of design which is [...]

Facade Design Pattern&hellip on January 29th, 2012 6:01 pm

[...] design pattern can be implemented in two ways. One using the inheritance method and second using the composition [...]

Adapter Design Pattern&hellip on January 29th, 2012 6:33 pm

[...] you might be wondering, why all the fuss about prototye design pattern and do we really need this design pattern? Just ignore, all the big guys requires it. For you, just understand the pattern and sleep over it. [...]

Prototype Design Pattern&hellip on January 29th, 2012 6:35 pm

Hi Joe,

Nice explanation. Can you please post a topic that covers entire Design Pattern in one stroke. Just to understand each in a simpler way. If base is strong, probably we can explore more in days to come.Can you please explain me in detail

Thanks,
Lakshman

LakshmiNarayana on March 15th, 2012 3:55 pm

[...] Proxy means ‘in place of’. In attendance roll call, we give proxy for our friends in college right? ‘Representing’ or ‘in place of’ or ‘on behalf of’ are literal meanings of proxy and that directly explains proxy design pattern. It is one of the simplest and straight forward design pattern. [...]

Proxy Design Pattern&hellip on April 1st, 2012 10:49 pm


Email:

about
I am Joe, author of this blog. I run this with loads of passion. If you are into java, you may find lot of interesting things around ...more about me. Google+
java badge
Home