go-design-patterns

module
v0.0.0-...-3c7c91d Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 12, 2024 License: Apache-2.0

README

Design Patterns in Go

A collection of design patterns concept and their implementation in Go from various sources.

Table of Contents

  1. Single Responsibility Principle (SOLID)

    A type should be made for one specific purpose.

  2. Open-Closed Principle (SOLID)

    A type should be open for extension, but closed for modification.

  3. Liskov Substitution Principle (SOLID)

    All behaviours of an interface type should be implemented without any problems.

  4. Interface Segregation Principle (SOLID)

    An interface type should not impose any behavior that is not required.

  5. Dependency Inversion Principle (SOLID)

    High-level modules/packages should not depend on low-level modules/packages except through interfaces.

  6. Builder Design Pattern

    Creates complex objects step by step (method chaining).

  7. Factory Design Pattern

    Creates objects in one go without exposing the creation logic to the user.

  8. Prototype Design Pattern

    Creates objects by copying from an existing object (deep copying).

  9. Singleton Design Pattern

    Makes sure that a struct only has one instance.

  10. Adapter Design Pattern

    A struct which adapts an existing interface X to conform to the required interface Y

  11. Bridge Design Pattern

    Decouples an interface from an implementation, preventing complexity explosion.

  12. Composite Design Pattern

    Treats individual (scalar) objects and compositions of objects in a uniform manner.

  13. Decorator Design Pattern

    Facilitates the addition of behaviors to individual objects through embedding.

  14. Facade Design Pattern

    Provides a simplified interface to a complex and large body of code.

  15. Flyweight Design Pattern

    A space optimization technique, use less memory by avoiding redundancy when storing data.

  16. Proxy Design Pattern

    Controls access to the original object, perform additional actions before or after accessing the object.

  17. Chain of Responsibility Design Pattern

    Allows an object to pass a request along a chain of potential handlers until the request is handled.

  18. Command Design Pattern

    A stand-alone object represents a command to perform a particular action.

  19. Interpreter Design Pattern

    Provides a way to interpret and evaluate sentences or expressions in a language.

  20. Iterator Design Pattern

    Facilitates the traversal of various data structures in a controlled manner.

  21. Mediator Design Pattern

    Facilitates communication between other components without them having direct access to each other.

  22. Memento Design Pattern

    Rollbacks the system states arbitrarily.

  23. Observer Design Pattern

    Propagates a change in an object to other objects without tightly coupling them.

  24. State Design Pattern

    Changes object's behaviour when its internal state change.

  25. Strategy Design Pattern

    Separates a mechanism into its abstract and concrete implementation steps, which can be varied at run time.

  26. Visitor Design Pattern

    Allows to add further operations to objects without having to modify them.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL