{"id":21196002,"url":"https://github.com/jasoncheung94/design-patterns","last_synced_at":"2025-03-14T21:47:13.902Z","repository":{"id":217420956,"uuid":"490402342","full_name":"Jasoncheung94/design-patterns","owner":"Jasoncheung94","description":"Curated list of design patterns and idioms.","archived":false,"fork":false,"pushed_at":"2022-10-01T10:43:30.000Z","size":97,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-01-21T14:17:08.610Z","etag":null,"topics":["concurrency-patterns","design-pattern","design-patterns","gang-of-four","gang-of-four-design-patterns","go","golang","idioms","snippets-collection","software-engineering"],"latest_commit_sha":null,"homepage":"","language":"Go","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Jasoncheung94.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null}},"created_at":"2022-05-09T18:35:07.000Z","updated_at":"2024-01-14T16:37:52.000Z","dependencies_parsed_at":"2024-01-16T10:05:42.306Z","dependency_job_id":"70c0ad0c-1063-4236-b4db-3ab6a6254090","html_url":"https://github.com/Jasoncheung94/design-patterns","commit_stats":null,"previous_names":["jasoncheung94/design-patterns"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Jasoncheung94%2Fdesign-patterns","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Jasoncheung94%2Fdesign-patterns/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Jasoncheung94%2Fdesign-patterns/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Jasoncheung94%2Fdesign-patterns/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Jasoncheung94","download_url":"https://codeload.github.com/Jasoncheung94/design-patterns/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243652705,"owners_count":20325607,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["concurrency-patterns","design-pattern","design-patterns","gang-of-four","gang-of-four-design-patterns","go","golang","idioms","snippets-collection","software-engineering"],"created_at":"2024-11-20T19:32:55.359Z","updated_at":"2025-03-14T21:47:13.880Z","avatar_url":"https://github.com/Jasoncheung94.png","language":"Go","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Design Patterns\n\nCurated list of design patterns and idioms using Go (mostly) and other languages such as Python.\n\n[Design patterns](https://en.wikipedia.org/wiki/Software_design_pattern)\n\n## Creational Patterns\n\nCreational patterns provide the capability to create objects based on a required criterion and in a controlled way.\n\n| Pattern                                                                                                        | Description                                                                                                                                                                          | Status |\n| -------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------ | ------ |\n| [Abstract Factory](./creational/abstract_factory/README.md)                                                    | Provides an interface for creating families of related objects without specifying their concrete classes                                                                             | ✅     |\n| [Builder](./creational/builder/README.md)                                                                      | Builds a complex object using simple objects. Allows you to produce different types and representations of an object using the same construction code                                | ✅     |\n| [Dependency Injection](./creational/dependency_injection/README.md)                                            | A class accepts the objects it requires from an injector instead of creating the objects directly.                                                                                   | ✅     |\n| [Factory Method](./creational/factory_method/README.md)                                                        | Provides an interface for creating objects in a superclass, but allows subclasses to alter the type of objects that will be created                                                  | ✅     |\n| [Lazy initialization / Lazy Loading](/creational/lazy_initialization/README.md)                                | A class that uses lazy initialization to delay the creation of an object until it is first used.                                                                                     | ✅     |\n| [Multiton](./creational/multiton/README.md)                                                                    | A class that provides a named instances of itself. And provide a global point of access to them. Allows for the controlled creation of multiple instances, which it manages.         | ✅     |\n| [Object pool](./creational/object_pool/README.md)                                                              | Avoid expensive acquisition and release of resources by recycling objects that are no longer in use. Can be considered a generalisation of connection pool and thread pool patterns. | ✅     |\n| [Prototype](./creational/prototype/README.md)                                                                  | Allows cloning objects, even complex ones, without coupling to their specific classes.                                                                                               | ✅     |\n| [Resource acquisition is initialization (RAII)](./creational/resource_acquisition_is_initialization/README.md) | Ensure that resources are properly released by tying them to the lifespan of suitable objects.                                                                                       | ✅     |\n| [Singleton](./creational/singleton/README.md)                                                                  | Only one object of its kind exists and provides a single point of access to it for any other code ( aka Global variable )                                                            | ✅     |\n\n## Structural Patterns\n\nStructural patterns are about organizing different classes and objects to form larger structures and provide new functionality.\n\n| Pattern                                       | Description                                                                                  | Status |\n| --------------------------------------------- | -------------------------------------------------------------------------------------------- | ------ |\n| [Adapter](./structural/adapter/README.md)     | Allows objects with incompatible interfaces to collaborate.                                  | ✅     |\n| [Bridge](./structural/bridge/README.md)       | Separates an abstraction from its implementation so that the two can vary independently.     | ✅     |\n| [Composite](./structural/composite/README.md) | Allows you to compose objects into tree structures to represent part-whole hierarchies.      | ✅     |\n| [Decorator](./structural/decorator/README.md) | Allows you to attach additional responsibilities to an object dynamically.                   | ✅     |\n| [Facade](./structural/facade/README.md)       | Provides a unified interface to a set of interfaces in a subsystem.                          | ✅     |\n| [Flyweight](./structural/flyweight/README.md) | An object that minimizes memory usage by sharing some of its data with other similar objects | ✅     |\n| [Proxy](./structural/proxy/README.md)         | Provides a substitute or placeholder for another object to control access to it.             | ✅     |\n\n## Behavioral Patterns\n\nBehavioral patterns are about identifying common communication patterns between objects and realizing these patterns.\n\n| Pattern                                                                   | Description                                                                                                               | Status |\n| ------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------- | ------ |\n| [Chain of Responsibility](./behavioral/chain_of_responsibility/README.md) | Allows you to pass requests along a chain of objects until one of them can handle the request.                            | ✅     |\n| [Command](./behavioral/command/README.md)                                 | Allows you to encapsulate a request as an object, thereby letting you parameterize other objects with different requests. | ✅     |\n| [Interpreter](./behavioral/interpreter/README.md)                         | Allows you to implement an interpreter pattern.                                                                           | ✅     |\n| [Iterator](./behavioral/iterator/README.md)                               | Allows you to traverse a set of objects without exposing its underlying implementation.                                   | ✅     |\n| [Mediator](./behavioral/mediator/README.md)                               | Allows you to decouple components that communicate with each other.                                                       | ✅     |\n| [Memento](./behavioral/momento/README.md)                                 | Allows you to save and restore the state of an object without breaking its encapsulation.                                 | ✅     |\n| [Observer](./behavioral/observer/README.md)                               | Allows you to decouple the subscriber from the publisher (sender) by implementing the publish/subscribe pattern.          | ✅     |\n| [State](./behavioral/state/README.md)                                     | Allows you to encapsulate the current state of an object in an object.                                                    | ✅     |\n| [Strategy](./behavioral/strategy/README.md)                               | Allows you to define a family of algorithms, put each one in a separate class, and make their objects interchangeable.    | ✅     |\n| [Template Method](./behavioral/template_method/README.md)                 | Allows you to define the skeleton of an algorithm in an operation, deferring some steps to subclasses.                    | ✅     |\n| [Visitor](./behavioral/visitor/README.md)                                 | Allows you to separate an algorithm from the data structures that support it.                                             | ✅     |\n\n## Concurrency Patterns (TODO) - Find common idioms and patterns with different languages\n\n| Pattern                   | Description | Status |\n| ------------------------- | ----------- | ------ |\n| Active Object             |             | ❌     |\n| Balking pattern           |             | ❌     |\n| Barrier                   |             | ❌     |\n| Double-checked locking    |             | ❌     |\n| Guarded suspension        |             | ❌     |\n| Leaders/followers pattern |             | ❌     |\n| Monitor Object            |             | ❌     |\n| Nuclear reaction          |             | ❌     |\n| Reactor pattern           |             | ❌     |\n| Read write lock pattern   |             | ❌     |\n| Scheduler pattern         |             | ❌     |\n| Thread pool pattern       |             | ❌     |\n| Thread-local storage      |             | ❌     |\n\n## Additional Resources/References\n\n- [Design patterns](https://en.wikipedia.org/wiki/Software_design_pattern)\n- [Refactoring Guru](https://refactoring.guru/design-patterns)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjasoncheung94%2Fdesign-patterns","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjasoncheung94%2Fdesign-patterns","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjasoncheung94%2Fdesign-patterns/lists"}