Software architecture patterns
3 pattern design types:
Creational:
Factory
Defines an interface for creating objects but lets subclasses alter the type of created objects.
Abstract Factory
Provides an interface for creating families of related objects without specifying their concrete classes.
Builder
Constructs a complex object step by step, often used when objects need many optional parameters or different configurations.
Prototype
Creates new objects by copying an existing object, used for cloning and when object creation is expensive.
Singleton
Ensures a class has only one instance and provides a global access point to it.
Such class doesn't have a public constructor but a pulic static getter returned the instance of this class.
Structural
Adapter
Converts an interface of a class into another interface that clients expect, allowing incompatible interfaces to work together.
Bridge
Separates an abstraction from its implementation, so the two can vary independently.
Composite (Tree)
Treats individual objects and compositions of objects uniformly, often used to represent hierarchies (e.g., a file system).
Decorator (Wrapper)
Adds new behavior to objects dynamically without altering their structure, useful for adding features at runtime.
Facade
Provides a simplified interface to a complex subsystem, used to reduce dependency and simplify interactions.
Flyweight (Cache)
Reduces memory usage by sharing common parts of objects, especially useful in systems with large numbers of similar objects.
Proxy
Provides a placeholder for another object to control access, manage permissions, or optimize performance.
With an Adapter, you access an existing object through a different interface.
With an Proxy, the interface remains unchanged.
With Decorator, you access an object through an extended interface.