DEV Community

Jayaprasanna Roddam
Jayaprasanna Roddam

Posted on • Edited on

Design patterns using GO

The 23 unique design patterns, categorized into Creational, Structural, and Behavioral patterns, as outlined by the Gang of Four (GoF):

Creational Patterns (5 Patterns)

These patterns deal with object-creation mechanisms.

  1. Singleton – Ensures only one instance of a class is created. read more

  2. Factory Method – Creates objects without specifying the exact class.read more

  3. Abstract Factory – Provides an interface for creating related objects without specifying concrete classes. read more

  4. Builder – Separates object construction from its representation. read more

  5. Prototype – Creates a new object by cloning an existing object. read more

Structural Patterns (7 Patterns)

These patterns deal with object composition and structure.

  1. Adapter – Allows incompatible interfaces to work together.read more

  2. Bridge – Separates an object’s abstraction from its implementation.

  3. Composite – Treats individual objects and compositions uniformly.

  4. Decorator – Adds behaviour to objects dynamically.

  5. Facade – Provides a simplified interface to a complex system.

  6. Flyweight – Reduces memory usage by sharing common parts of objects.

  7. Proxy – Provides a placeholder or surrogate for another object.

Behavioral Patterns (11 Patterns)

These patterns are concerned with object interaction and communication.

  1. Chain of Responsibility – Passes requests along a chain of handlers.
  2. Command – Encapsulates requests as objects, allowing for parameterization.
  3. Interpreter – Implements a specialized language grammar.
  4. Iterator – Provides a way to access elements of a collection sequentially.
  5. Mediator – Centralizes complex communications between objects.
  6. Memento – Captures an object’s internal state for restoring later.
  7. Observer – Defines a dependency between objects to update automatically.
  8. State – Allows an object to change its behaviour when its state changes.
  9. Strategy – Enables selecting an algorithm at runtime.
  10. Template Method – Defines the skeleton of an algorithm, with steps overridden by subclasses.
  11. Visitor – Separates an algorithm from the object structure it operates on.

Sentry image

See why 4M developers consider Sentry, “not bad.”

Fixing code doesn’t have to be the worst part of your day. Learn how Sentry can help.

Learn more

Top comments (0)

A Workflow Copilot. Tailored to You.

Pieces.app image

Our desktop app, with its intelligent copilot, streamlines coding by generating snippets, extracting code from screenshots, and accelerating problem-solving.

Read the docs

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay