# Software patterns

Aka how to code and not reinvent the bloody wheel again

Stolen shamelessly from <https://sourcemaking.com/design_patterns>

## Creational

* Factory = create an object by specifying the type
* Abstract factory = create an object factory by specifying the type
* Builder = build a complex object by separating the construction from the representation (construction is outside the class definition) and construction should be like an assembly.
* Pool = create a pool of objects to reuse, instead of create/destroy cycles
* Singleton = single instance / manager object
* Prototype = create object by copying an existing one

## Structural

* Adapter = adapt from 1 interface to another
* Bridge = separate object abstraction(interface) from implementation, and rely on abstraction ( dependency inversion)
* Composite
* Decorator
* Facade
* Flyweight
* Private class data
* Proxy

## Behavioural

* Chain of responsibility
* Command
* Interpreter
* Mediator
* Memento
* Null object
* Observer
* State
* Strategy
* Template
* Visitor


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://claudiu-stanciu.gitbook.io/software-craft/patterns/software-patterns.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
