๐๐ผ ๐ฌ๐ผ๐ ๐ก๐ฒ๐ฒ๐ฑ ๐ง๐ผ ๐๐ป๐ผ๐ ๐๐น๐น ๐๐ฒ๐๐ถ๐ด๐ป ๐ฃ๐ฎ๐๐๐ฒ๐ฟ๐ป๐?
February 19, 2024
programming
WARNING: This post is over a year old. Some of the information this contains may be outdated.
๐๐ผ ๐ฌ๐ผ๐ ๐ก๐ฒ๐ฒ๐ฑ ๐ง๐ผ ๐๐ป๐ผ๐ ๐๐น๐น ๐๐ฒ๐๐ถ๐ด๐ป ๐ฃ๐ฎ๐๐๐ฒ๐ฟ๐ป๐?
The answer is no. Even though we have 23 design patterns, around 10 are mostly used in everyday development. Knowing which patterns exist overall is good, but you need to know these very well.
Design patterns can be divided into three main types:
๐ญ. ๐๐ฟ๐ฒ๐ฎ๐๐ถ๐ผ๐ป๐ฎ๐น ๐ฃ๐ฎ๐๐๐ฒ๐ฟ๐ป๐
These design patterns deal with object creation mechanisms, trying to create objects in a manner suitable to the situation.
Important patterns in this group are:
๐น๐๐ฎ๐ฐ๐๐ผ๐ฟ๐: This pattern allows delegating the instantiation logic to factory classes. The Factory Method creates objects without exposing the instantiation logic to the client.
๐น๐ฆ๐ถ๐ป๐ด๐น๐ฒ๐๐ผ๐ป: The Singleton pattern ensures that a class has only one instance and provides a global point of access to it. It's useful when exactly one object is needed to coordinate actions across the system.
๐ฎ. ๐ฆ๐๐ฟ๐๐ฐ๐๐๐ฟ๐ฎ๐น ๐ฃ๐ฎ๐๐๐ฒ๐ฟ๐ป๐
These patterns deal with the composition of classes and objects that form larger structures.
Important patterns in this group are:
๐น๐๐ฑ๐ฎ๐ฝ๐๐ฒ๐ฟ: This pattern works as a bridge between two incompatible interfaces. It wraps an existing class with a new interface to become compatible with the client's interface.
๐น๐๐ฎ๐ฐ๐ฎ๐ฑ๐ฒ: The Faรงade pattern provides a unified interface to a set of interfaces in a subsystem. Faรงade defines a higher-level interface that makes the subsystem easier to use.
๐น๐๐ฒ๐ฐ๐ผ๐ฟ๐ฎ๐๐ผ๐ฟ: This pattern dynamically adds/overrides behavior in an existing method of an object. This pattern provides a flexible alternative to subclassing for extending functionality.
๐น๐ฃ๐ฟ๐ผ๐ ๐: The Proxy pattern provides a surrogate or placeholder for another object to control access to it. In its most general form, a proxy is a class functioning as an interface to something else.
๐ฏ. ๐๐ฒ๐ต๐ฎ๐๐ถ๐ผ๐ฟ๐ฎ๐น ๐ฃ๐ฎ๐๐๐ฒ๐ฟ๐ป๐
These patterns are specifically concerned with communication between objects and how they interact and distribute work.
Important patterns in this group are:
๐น๐๐ผ๐บ๐บ๐ฎ๐ป๐ฑ: The Command pattern encapsulates a request as an object, thus allowing users to parameterize clients with queues, requests, and operations.
๐น๐ง๐ฒ๐บ๐ฝ๐น๐ฎ๐๐ฒ ๐ ๐ฒ๐๐ต๐ผ๐ฑ: This pattern defines the program skeleton of an algorithm in a method called template method, which defers some steps to subclasses.
๐น๐ฆ๐๐ฟ๐ฎ๐๐ฒ๐ด๐: The Strategy pattern defines a family of algorithms, encapsulates each one, and makes them interchangeable. Strategy lets the algorithm vary independently from clients that use it.
๐น๐ข๐ฏ๐๐ฒ๐ฟ๐๐ฒ๐ฟ: This pattern defines a one-to-many dependency between objects so that all its dependents are notified and updated automatically when one object changes state.
s๏ปฟource: @milan_milanovic
Comments are not enabled for this post.