Design Patterns in Software Engineering 
Cheat Sheet

Welcome to the world of DESIGN PATTERNS! What are they? Think of them as reusable solutions to common design problems in software development. You probably heard of the insanely popular: Design Patterns: Elements of Reusable Object-Oriented Software by (Erich Gamma, Richard Helm, Ralph Johnson, and John Vlissides). While not the easiest reading, they provided concepts to describing reusable design problems. So dive in! They are broken out by creational, structural, and behavioral patterns with additional bonus patterns outside the scope of the book.

design patterns in software engineering

Creational Design Patterns in Software Engineering

Creational Design patterns are deals with object creation mechanisms, trying to create objects in a manner suitable to the situation. The basic form of object creation could result in design problems or in added complexity to the design. Creational design patterns solve this problem by somehow controlling this object creation.

  1. Abstract factory pattern provides an interface for creating families of related or dependent objects without specifying their concrete classes.
  2. Factory pattern provides an interface for creating objects in a superclass, but allows subclasses to alter the type of objects that will be created.
  3. Builder pattern separates the construction of a complex object from its representation, allowing the same construction process to create different representations.
  4. Prototype pattern allows new objects to be created by copying existing objects, rather than creating new objects from scratch.
  5. Singleton pattern ensures that a class has only a single instance while providing a global access point to that instance.

Structural Design Patterns in Software Engineering

structural design patterns

Structural design patterns are design patterns that deal with object composition, creating relationships between objects to form larger structures. These patterns are concerned with how objects are made up and how they can be modified and composed to get new functionality.

These patterns are useful when you need to create relationships between objects to provide new functionality. They can help you reduce the complexity of your code by creating a simpler interface for clients to use.

  1. Adapter pattern allows two incompatible interfaces to work together by wrapping an interface of an existing class with a new interface.
  2. Bridge pattern separates an abstraction from its implementation, allowing the two to vary independently.
  3. Facade pattern provides a simplified interface to a complex system, hiding the complexity behind a single, easy-to-use interface.
  4. Composite pattern allows a group of objects to be treated as a single object.
  5. Proxy pattern provides a placeholder for another object, allowing you to control access to that object or add additional behavior.
  6. Flyweight pattern reduces the memory footprint of an application by sharing common data among objects, rather than storing duplicate copies of the data in each object.

Behavioral Design Patterns in Software Engineering

A behavioral design pattern is a design pattern that focuses on communication between objects, what goes on between objects and how they operate together. These patterns are concerned with communication between objects, what goes on between objects and how they operate together.

  1. Command pattern encapsulates a request as an object, allowing you to parameterize clients with different requests, queue or log requests, and support undoable operations.
  2. Chain of Responsibility pattern allows a request to be passed along a chain of objects until it is handled, without the sender of the request knowing which object in the chain will handle it.
  3. Interpreter pattern evaluates a language or notation by representing sentences in that language as abstract syntax trees.
  4. Mediator pattern allows you to reduce the coupling between objects by introducing a mediator object that handles communication between the objects.
  5. Memento pattern saves and restores the state of an object without exposing its internal representation.
  6. Iterator pattern provides a way to traverse a collection of objects without exposing the underlying representation of the collection.
  7. State pattern enables an object to alter its behavior when its internal state changes, without changing its class.
  8. Strategy pattern set of interchangeable algorithms and switch between them at runtime.
  9. Template pattern lets you define the skeleton of an algorithm in a base class, deferring some steps to subclasses.
  10. Observer pattern sets a one-to-many dependency between objects, such that when one object changes state, all of its dependents are notified and updated automatically.
  11. Visitor pattern enables a new operation without changing the classes of the elements on which it operates.

design patterns reuse

Additional Design Patterns in Software Engineering

  1. Filter pattern is a set of objects to be filtered based on a set of criteria, without the objects being aware of the criteria.
  2. Decorator pattern defines new behavior to be added to an existing object dynamically, by wrapping the object with a new object that adds the desired behavior.
  3. Null Object pattern provides a default object that does nothing, rather than returning null for methods that return objects.
  4. Service Locator pattern gives a centralized registry of services, allowing clients to look up and retrieve services without knowing the underlying implementation.
  5. Specification pattern allows you to define a set of criteria as a reusable class, allowing you to encapsulate complex queries and reuse them throughout your code.
  6. Subject-Observer pattern sets a one-to-many dependency between objects, such that when one object changes state, all of its dependents are notified and updated automatically.
  7. Template Method pattern allows you to specify the skeleton of an algorithm in a base class, deferring some steps to subclasses.
  8. Type Object pattern establishes a set of related classes that represent a single entity, such as a person or an animal.
  9. Virtual Proxy pattern provides a placeholder for another object, allowing you to control access to that object or add additional behavior.

These are just a few examples of the many design patterns that are used in software engineering. These are just a place to start and be aware of - over time you will actually come up with your own design patterns.