Design Patterns — get the gist in 2 min concluding series with easy to remember one liners on each pattern

aditya chaudhari
JavaDeveloperDiary — JDD
5 min readJul 4, 2023

Since few months now i have been exploring design patterns from GOF and head-first books and trying to write 2 min post and long 5–10 min post.
In this post concluding the series of all those articles along with simple to understanding one liners.

Creational design pattern gives you a lot of flexibility in what gets created, who creates it and how it gets created and when.
Below are important types of Creational desing pattern :

  1. Factory method pattern :
    one liner :”Let subclasses decide which objects to create.”
    Factory method pattern defines an interface for creating an object but lets the subclass decide which class to instantiate.
    Further reference : https://medium.com/javadeveloperdiary-jdd/factory-method-pattern-get-the-gist-in-2-min-720f875142ba
  2. Singleton Pattern
    one liner :”only one item to rule them all.”
    The singleton pattern ensures a class has only one instance, and it provides a global point of access to it.
    Further reference : https://medium.com/javadeveloperdiary-jdd/singleton-design-pattern-get-the-gist-in-2-min-445539d4cf14
  3. Prototype Pattern
    one liner :”Clone and customize, a blueprint in action”
    With the Prototype pattern, you can create new objects by cloning existing ones, saving time and reducing the potential for errors.
    The Prototype design pattern allows us to create new objects by cloning existing ones, rather than by creating them from scratch.
    Further reference : https://medium.com/javadeveloperdiary-jdd/prototype-design-pattern-get-the-gist-in-2-min-265ddaf7efa7
  4. Builder Pattern
    one liner :”Step by step build it right”
    The intent behind the Builder Design Pattern is to separate the construction of a complex object from its representation so that the same construction process can create different representations.
    Further reference : https://medium.com/javadeveloperdiary-jdd/builder-pattern-get-the-gist-in-2-min-7c6befd0515d

Structural patterns are concerned with how classes and objects are composed to form large structures.
Below are important types of the structural design patterns

  1. Adaptor Pattern
    one liner :”Bridging the gaps between incompatible interfaces, making them work together seamlessly ”
    Adaptor pattern converts the interface of a class into another interface clients expect. The adapter lets classes work together that couldn’t otherwise because of incompatible interfaces. This is done simply by adapter implementing the interface of one object and wrapping another object.
    Further reference : https://medium.com/javadeveloperdiary-jdd/adapter-pattern-get-the-gist-in-2-min-f1fcad7d706d
  2. Composite Pattern
    one liner :”Treating individual and group objects uniformly, forming a unified structure with hierarchical relationships.”
    It’s about composing different objects of a similar family (interface) and then appearing them as one for an external client. Each object in the composition may or may not have child objects.
    Further reference : https://medium.com/javadeveloperdiary-jdd/composite-design-pattern-get-the-gist-in-2-min-cffcbe5953
  3. Decorator Pattern
    one liner :”Adding new functionalities dynamically, enhancing an object’s behavior without altering its core implementation”
    In simple words, the decorator pattern helps attach different behaviors to the object at the runtime by wrapping the object with a specific type of wrapper class which contains the new behavior logic.
    Further reference : https://medium.com/javadeveloperdiary-jdd/decorator-pattern-get-the-gist-in-2-min-3a3f84d85f38
  4. Proxy Pattern
    one liner :”Acting as a representative or surrogate for another object, controlling access and providing additional functionality when needed.”
    Think of a proxy pattern when you want to add an extra layer of indirection to access a resource or control access to it. It is useful in scenarios where you would want to improve performance by caching frequently used objects, reduce network traffic by implementing lazy loading, or provide a simplified interface to a complex system.
    Further reference : https://medium.com/javadeveloperdiary-jdd/proxy-design-pattern-java-get-the-gist-in-2-min-684adff7b077

Behavioral design patterns intent to focus on communication and interaction between objects, defining how they collaborate and distribute responsibilities.
Use: These patterns are used to manage complex object interactions, providing flexible communication patterns.

  1. Template method Pattern
    one liner :”Follow the blueprint, customize the details”
    The main intent behind the template method pattern is to provide the skeleton of an algorithm in the parent class and let subclasses extend the parent and define fill-ins by overriding methods. Well, the interesting part is that though algorithm fill-ins are implemented in the subclasses they are called by the parent class. Only parent calls those methods from subclass and this is called as famous “ Don’t call us, we will call you” Principle.
    Further reference : https://medium.com/javadeveloperdiary-jdd/template-method-pattern-get-the-gist-in-2-min-8cad25087564
  2. Strategy Pattern
    one liner :”Switch it up choose the best approach”
    All intent behind the strategy pattern is to encapsulate behaviors that belongs to a similar purpose and make them interchangeable .
    Further reference : https://medium.com/javadeveloperdiary-jdd/strategy-pattern-java-get-the-gist-of-it-in-2-min-b8ed180b1c43
  3. Command Pattern
    one liner :”Wrap it up, encapsulate object for further reference”
    The Command Design Pattern is all about encapsulating a request as an object and passing it as a request parameter. It decouples the object that invokes the action from the object that performs the action.
    Further reference : https://medium.com/javadeveloperdiary-jdd/command-pattern-get-the-gist-in-2-min-14a5a7dface2
  4. Observer Pattern
    one liner :”Stay in sync, get notified when things change.”
    The basic idea behind observer pattern is to have a publisher — subscriber like mechanism , where publisher wants to notify multiple subscriber objects regarding some events / state change which is the in interest of subscriber.
    Further reference : https://medium.com/javadeveloperdiary-jdd/observer-pattern-get-the-gist-in-2-min-49d5f0afe6b0
  5. Iterator Pattern
    one liner :”Take it step by step, explore a collection one element at a time.”
    Iterator pattern is all about streamline the access of the collection so that the client which want to iterate over collection must not worry about entire collection instead it just check if list hasNext() element and call next() element.
    Further reference : https://medium.com/javadeveloperdiary-jdd/iterator-pattern-get-the-gist-in-2-min-51ba536bf996

Learning is a never-ending journey that brings constant satisfaction through multiple milestones.
Here at this point concluding the 2 min series of design patterns but with the promise to come up with more such simple to understand posts related to enterprise application development.
Please also check https://www.adityatechinsights.com/series/design-patterns for detail insights for the design patterns and future posts.

Thanks for reading ! Happy coding !

--

--

aditya chaudhari
JavaDeveloperDiary — JDD

building efficient, scalable and maintainable enterprise e-commerce applications using java, spring framework and SAP CC. Life Mantra → Love IT Live IT Enjoy IT