Skip to content

loickreitmann/gang-of-four-design-patterns-in-go

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

52 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Design Patterns in Go

Design Patterns are a set of 23 classic design patterns in software development, described in the book Design Patterns: Elements of Reusable Object-Oriented Software. The book was authored by Erich Gamma, Richard Helm, Ralph Johnson, and John Vlissides, who are collectively known as the Gang of Four. They described these patterns as solutions to common problems in software design. They are divided into three categories: Creational, Structural, and Behavioral.

The following design patterns are foundational in object-oriented software development and are widely used to create flexible, reusable, and maintainable code.

A. Creational Patterns

Provides an interface for creating families of related or dependent objects without specifying their concrete classes.

Separates the construction of a complex object from its representation so that the same construction process can create different representations.

Defines an interface for creating an object but lets subclasses alter the type of objects that will be created.

Specifies the kinds of objects to create using a prototypical instance and creates new objects by copying this prototype.

Ensures a class has only one instance and provides a global point of access to it.

B. Structural Patterns

Converts the interface of a class into another interface that clients expect, allowing classes to work together that couldn't otherwise because of incompatible interfaces.

Separates an object's interface from its implementation so the two can vary independently.

Composes objects into tree structures to represent part-whole hierarchies, allowing clients to treat individual objects and compositions uniformly.

Attaches additional responsibilities to an object dynamically, providing a flexible alternative to subclassing for extending functionality.

Provides a unified interface to a set of interfaces in a subsystem, making the subsystem easier to use.

Uses sharing to support large numbers of fine-grained objects efficiently.

Provides a surrogate or placeholder for another object to control access to it.

C. Behavioral Patterns

Passes a request along a chain of handlers, allowing multiple objects a chance to handle the request.

Encapsulates a request as an object, thereby allowing for parameterization of clients with queues, requests, and operations.

Defines a representation for a language's grammar and uses an interpreter to interpret sentences in the language.

Provides a way to access the elements of an aggregate object sequentially without exposing its underlying representation.

Defines an object that encapsulates how a set of objects interact, promoting loose coupling.

Captures and externalizes an object's internal state without violating encapsulation, so the object can be restored to this state later.

Defines a one-to-many dependency between objects so that when one object changes state, all its dependents are notified and updated automatically.

Allows an object to alter its behavior when its internal state changes, appearing as if the object changed its class.

Defines a family of algorithms, encapsulates each one, and makes them interchangeable. Strategy lets the algorithm vary independently from clients that use it.

Defines the skeleton of an algorithm in an operation, deferring some steps to subclasses.

Represents an operation to be performed on elements of an object structure, allowing new operations to be defined without changing the classes of the elements on which it operates.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages