Structural patterns
Composite
Lets clients treat a single element and a whole tree of elements in exactly the same way.
Article
Composite – trees in which a leaf and a branch look the same
Composite lets you treat a single object and a whole group of objects in exactly the same way. A course curriculum example with modules and lessons in C#, TypeScript, Java, Go and Python.
Related articles
- Specification: business rules as objects you can combine
The Specification pattern from Domain-Driven Design: named rules with isSatisfiedBy, combining with and, or and not, one rule for validation and querying, translation to SQL via expression trees,…
- Flyweight – how to fit 60,000 stadium seats in memory
Flyweight separates the state shared by many objects from the state unique to each one, and shares the former. A stadium seat map example from a ticket booking system in C#, TypeScript, Java, Go and…
- Builder – complex objects step by step
Builder collects an object's parameters in readable steps and hands over a finished, valid product only in build(). A catering order example in C#, TypeScript, Java, Go and Python.
- Decorator – adding behaviour layer by layer
Decorator wraps an object in another object with the same interface and adds behaviour before or after the call. An example of caching, retries and logging for an exchange rate provider in C#,…
Challenges
Around the topic
- Composite article · web · Refactoring.Guru
- This Design Pattern Simplifies Everything video · youtube · ArjanCodes
- torokmark/design_patterns_in_typescript repo · github · torokmark
- Design Patterns: Elements of Reusable Object-Oriented Software book · openlibrary · Erich Gamma, John Vlissides, Richard Helm, Ralph Johnson
- Kompozyt / Composite article · web · Refactoring.Guru