Skip to content

Commit cf4fd6d

Browse files
docs: add mermaid diagrams
1 parent f393fbd commit cf4fd6d

1 file changed

Lines changed: 58 additions & 0 deletions

File tree

README.md

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,24 @@ graph LR
1717
1818
FactoryMethod -->|subclass decides| ConcreteProduct
1919
Pool -->|reuses| PooledInstance
20+
```
21+
22+
| Pattern | Description |
23+
|:------- |:----------- |
24+
| [abstract_factory](patterns/creational/abstract_factory.py) | use a generic interface to create a family of related objects |
25+
| [borg](patterns/creational/borg.py) | a singleton with shared-state among instances |
26+
| [builder](patterns/creational/builder.py) | instead of using complex constructors, isolate the construction of an object and make it multi-step |
27+
| [factory](patterns/creational/factory.py) | delegate the creation of objects to specialized methods or classes |
28+
| [lazy_evaluation](patterns/creational/lazy_evaluation.py) | wait until the value is needed to calculate it |
29+
| [pool](patterns/creational/pool.py) | preinstantiate and maintain a group of objects of the same type |
30+
| [prototype](patterns/creational/prototype.py) | use a factory to create new objects by copying an existing instance |
31+
| [singleton](patterns/creational/singleton.py) | restrict the instantiation of a class to one object |
32+
33+
## Structural Patterns
34+
35+
> Patterns that define **how classes and objects are composed** to form larger, flexible structures.
36+
37+
```mermaid
2038
graph TD
2139
Client --> Facade
2240
Facade --> SubsystemA
@@ -32,6 +50,26 @@ graph TD
3250
Component --> Composite
3351
Composite --> Leaf1
3452
Composite --> Leaf2
53+
```
54+
55+
| Pattern | Description |
56+
|:------- |:----------- |
57+
| [3-tier](patterns/structural/3-tier.py) | data<->business logic<->presentation separation (strict relationships) |
58+
| [adapter](patterns/structural/adapter.py) | adapt one interface to another using a white-box wrapper |
59+
| [bridge](patterns/structural/bridge.py) | decouple an abstraction from its implementation |
60+
| [composite](patterns/structural/composite.py) | encapsulate a group of objects into a single object |
61+
| [decorator](patterns/structural/decorator.py) | wrap a class to add new functionality without changing its structure |
62+
| [facade](patterns/structural/facade.py) | provide a simplified interface to a complex system |
63+
| [flyweight](patterns/structural/flyweight.py) | use sharing to support a large number of objects efficiently |
64+
| [front_controller](patterns/structural/front_controller.py) | a single entry point for all requests to an application |
65+
| [proxy](patterns/structural/proxy.py) | an object representing another object |
66+
| [mvc](patterns/structural/mvc.py) | separate data (model), user interface (view), and logic (controller) |
67+
68+
## Behavioral Patterns
69+
70+
> Patterns concerned with **communication and responsibility** between objects.
71+
72+
```mermaid
3573
graph LR
3674
Sender -->|sends event| Observer1
3775
Sender -->|sends event| Observer2
@@ -45,3 +83,23 @@ graph LR
4583
4684
Originator -->|saves state to| Memento
4785
Caretaker -->|holds| Memento
86+
```
87+
88+
| Pattern | Description |
89+
|:------- |:----------- |
90+
| [chain_of_responsibility](patterns/behavioral/chain_of_responsibility.py) | allow multiple objects to handle a request without them needing to know about each other |
91+
| [command](patterns/behavioral/command.py) | encapsulate a request as an object, allowing for parameterization and queuing |
92+
| [catalog](patterns/behavioral/catalog.py) | a class that allows looking up other classes based on various criteria |
93+
| [chaining_method](patterns/behavioral/chaining_method.py) | allow calling multiple methods on the same object in a single statement |
94+
| [interpreter](patterns/behavioral/interpreter.py) | define a grammar for a language and use it to interpret statements |
95+
| [iterator](patterns/behavioral/iterator.py) | provide a way to access elements of a collection sequentially |
96+
| [mediator](patterns/behavioral/mediator.py) | encapsulate how a set of objects interact |
97+
| [memento](patterns/behavioral/memento.py) | capture and restore an object's internal state |
98+
| [observer](patterns/behavioral/observer.py) | allow objects to notify other objects about changes in their state |
99+
| [publish_subscribe](patterns/behavioral/publish_subscribe.py) | allow objects to subscribe to events and receive notifications when they occur |
100+
| [registry](patterns/behavioral/registry.py) | keep track of all instances of a class |
101+
| [specification](patterns/behavioral/specification.py) | define a set of criteria that an object must meet |
102+
| [state](patterns/behavioral/state.py) | allow an object to change its behavior when its internal state changes |
103+
| [strategy](patterns/behavioral/strategy.py) | define a family of algorithms and make them interchangeable |
104+
| [template](patterns/behavioral/template.py) | define the skeleton of an algorithm in a method, allowing subclasses to override specific steps |
105+
| [visitor](patterns/behavioral/visitor.py) | separate an algorithm from the object structure it operates on |

0 commit comments

Comments
 (0)