Design patterns are practical proven solutions to recurring design problems. They are blueprints not algorithms or code to solve a common software problems.
It's important to note that it won't be so simple to look at a software design problem and automatically know which design pattern to use.
Design patterns are categorized into 3 groups :
Creational Patterns : provide mecanisms for object creation which increase flexibility and reuse of existing code. Example : Factory Pattern, Builder Pattern, Singleton...
Structural Patterns : Describe how objects are connected to each other, example : Adapter Pattern, Decorator Pattern, Facade...
Behavioral Patterns : how objects distribute work and how they work towards a common goal.
Design patterns help to have a common design vocabulary between developers. Rather than having to explain the details of a design solution you can simplify the discussion by having a suggestive word to describe it.
One of the design principles is to identify the aspects of application that varies and separate them from what stays the same. With this approach we won't have to make changes in different places when a new request is made by the client, that minimize the amount of bugs that can be introduced by the change and it makes the code flexible.
*1. Strategy pattern : *
Define a family of algorithms encapsulates each other and make them interchangeable. Strategy lets the algorithm vary independently from client that use it
Top comments (0)