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.

Ads by Google

42 comments on “Introduction To Design Patterns

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

      • Hey,
        Buddy you have done good job for those who wants to do study on especially Design Patterns,faboulas.Go head….

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

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

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

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

  6. Hey Srikanth,

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

    Thanks in advance

  7. Nice I appreciate you ..keep posting sir..

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

    Thanks
    nag

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

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

  11. Pingback: Singleton Pattern

  12. Pingback: Decorator Pattern

  13. Pingback: Singleton Pattern in java « kevzpace

  14. It really gud article for beginners easy to understand.

  15. Joe, Good information on design patterns.

  16. 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?

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

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

  19. 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…

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

  21. Pingback: Facade Design Pattern

  22. Pingback: Adapter Design Pattern

  23. Pingback: Prototype Design Pattern

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

  25. Pingback: Proxy Design Pattern

  26. I am looking forward for more articles.
    The way you write and explain things in short is amazing. I checked your blog just yesterday finding ajax tutorial and now m going through other articles as well. Great work.Keep writing.

  27. Pingback: Flyweight Design Pattern

  28. Hi Joe,

    Thank you so much.We are eagerly waiting for you article on Design Patterns(which include Java code and UML diagrams).
    Thanks in Advance.

  29. Pingback: JAXB Tutorial

  30. Joe,

    I too love Java by heart & reading your multiple blogs on Core Java keep me tightly coupled with Java, I appreciate your efforts in popularizing & helping many Java Techies.

    Its really feel good that you’r looking forward to cover up SPRING in your future releases.

    I wish you BEST OF LUCK for all your upcoming blogs. Once again you’r helping so many people by sharing your knowledge, Hv a happy ahead.

  31. Pingback: Chain of Responsibility Design Pattern

  32. Hi joe, really nice article, thanks for explaining it in very simple terms. Really easy to understand it. I have one request could you please explain hashcode() from Object and String class?

  33. hello sir, i want to know that how we use design pattern in real project envoironment .

  34. Hi joe
    This is Suresh.And i red the some of the article of your’s,Those are very nice and shows some interest for the learners
    if you never mind now i would like to give a small suggession to you that if you add some practical implemtation exmaples for the desingn patterns that will brings effective explaination for the readers

    Thanks and Regards
    Suresh

  35. Pingback: Dependency Injection (DI) with Spring

Leave a Reply

Your email address will not be published.

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

ABOUT
I am Joe, author of this blog. I run javapapers with loads of passion. If you are into java, you may find lot of interesting things around.
Ads by Google
STAY in TOUCH:

Email:

Core Java | Servlet | JSP | Design Patterns | Android | Spring | Web Service | © 2008-2012 javapapers.