Learn GoF Design patterns to solve problems in software design

“A design that doesn’t take change into account risks major redesign in the future.” ― Erich Gamma

Why learn these design patterns

Classification of design patterns

  1. Creational patterns — They provide object creation mechanisms that increase flexibility and reuse of existing code.
  2. Structural patterns — They explain how to assemble objects and classes into larger structures while keeping the structures flexible and efficient.
  3. Behavioral patterns — They take care of effective communication and the assignment of responsibilities between objects.

Creational Design Patterns

  1. Singleton — A singleton is a creational design pattern that ensures a class has only one instance and provides a global access point to this instance.
  2. Factory — The factory method is a creational design pattern that provides an interface for creating objects in a superclass while allowing subclasses to change what type of object is created.
  3. Abstract Factory — The abstract factory is a creational design pattern that allows you to produce classes of related objects without specifying their concrete classes.
  4. Builder — A builder is a creational design pattern that lets you construct complex objects step by step. You can create different types and representations of an object using the same construction code.
  5. Prototype — A prototype is a creational design pattern that lets you copy existing objects without making your code dependent on their classes.

Structural Design Patterns

  1. Adapter — Adapter is a structural design pattern that allows objects with incompatible interfaces to communicate.
  2. Composite — Composite is a structural design pattern that let you compose objects into tree structures and then work with those structures as if they were individual objects.
  3. Proxy — Proxy is a structural design pattern that allows you to provide a placeholder or substitute for another object. Using a proxy, you can control access to the original object, allowing you to do something before or after the request is delivered to the original object.
  4. Flyweight — With flyweight, you can fit more objects into RAM by sharing common parts of the state between multiple objects rather than keeping all of the data in each of them.
  5. Facade — A facade is a design pattern that provides a simplified interface to a library, a framework, or any other set of classes.
  6. Bridge — Bridge is a design pattern that allows you to split a large class or a set of closely related classes into two separate hierarchies — abstraction and implementation — that can be developed independently.
  7. Decorator — Using the decorator design pattern, you can attach new behaviors to objects by placing them inside special wrapper objects that contain the new behaviors.

Behavioral Design Patterns

  1. Template method — A template method is a behavioral design pattern that defines the skeleton of an algorithm in the superclass, but allows subclasses to override specific steps without modifying its structure.
  2. Mediator — Using the mediator, you can reduce chaotic dependencies between objects. The pattern restricts direct communication between the objects and forces them to collaborate only through a mediator.
  3. Chain of Responsibility — Chains of responsibility allow you to pass requests along a chain of handlers. Upon receiving a request, each handler decides whether to process the request or to pass it on to the next handler in the chain.
  4. Observer — The observer pattern allows you to define a mechanism to notify multiple objects about events that occur to the object they are observing.
  5. Strategy — Using the strategy, you can define a family of algorithms, put them into different classes, and make their objects interchangeable.
  6. Command — Command is a behavioral design pattern that turns requests into stand-alone objects containing all information about them. With this transformation, you can parameterize methods with various requests, delay or queue the execution of a request, and support undoable operations.
  7. State — As a behavioral design pattern, the state lets an object change its behavior when its internal state changes. It looks as if the object changed its class.
  8. Visitor — Using the visitor pattern, you can separate algorithms from the objects on which they operate.
  9. Interpreter — The interpreter is a behavioral design pattern
    that defines a grammatical representation for a language and provides an interpreter to deal with this grammar.
  10. Iterator — A behavioral design pattern called an iterator lets you traverse elements of a collection without exposing their underlying representation.
  11. Memento — The memento is a behavioral design pattern that allows you to save and restore the previous state of an object without revealing its implementation details.





“Walking on water and developing software from a specification are easy if both are frozen”

Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

AWS Lambda for Beginners

Powershell For Penetration Testing : Part 3

How To Create Golang REST API: Project Layout Configuration [Part 3]

Dockerize a Laravel Application with Nginx, Php-FPM, Node js (Bonus: Deploy to CloudRun)

Andy just had an episode He started to collapse and go unconscious when he was moving from his…

Python From Scratch

Connect all your IoT devices with Yonomi

Unity and light probes

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Neeraj Kushwaha

Neeraj Kushwaha

“Walking on water and developing software from a specification are easy if both are frozen”

More from Medium

Principles of the Microservice Architecture

Tools to support clean code and design analysis

Practical Use Of SOLID Design Principles In Code

Building a Websocket Server in a Microservice Architecture