A design pattern is the re-usable form of a solution to a design problem.
Singleton
Is a software design pattern that restricts the instantiation of a class to one “single” instance
Factory or Factory Method
https://refactoring.guru/design-patterns/factory-method
Is a creational design pattern that provides an interface for creating objects in a superclass, but allows subclasses to alter the type of objects that will be created.
he Factory Method pattern suggests that you replace direct object construction calls (using the new operator) with calls to a special factory method. The objects are still created via the new operator, but it’s being called from within the factory method. Objects returned by a factory method are often referred to as “products.”
Strategy pattern
Is a behavioral software design pattern that enables selecting an algorithm at runtime. Instead of implementing a single algorithm directly, code receives run-time instructions as to which in a family of algorithms to use.
Es.: a sort function that choose the sort algorithm upon data amount or type…
Adapter Pattern
Is a software design pattern (also known as wrapper, an alternative naming shared with the decorator pattern) that allows the interface of an existing class to be used as another interface. It is often used to make existing classes work with others without modifying their source code.
The Adapter pattern just links two incompatible interfaces.
Facade Pattern
A single control panel to run all the internal components.
Analogous to a facade in architecture, a facade is an object that serves as a front-facing interface masking more complex underlying or structural code. A facade can:
- improve the readability and usability of a software library by masking interaction with more complex components behind a single (and often simplified) API
- provide a context-specific interface to more generic functionality (complete with context-specific input validation)
- serve as a launching point for a broader refactor of monolithic or tightly-coupled systems in favor of more loosely-coupled code
Decorator Pattern
Is a design pattern that allows behavior to be added to an individual object, dynamically, without affecting the behavior of other objects from the same class.
0 commenti