On design patterns
Very often I find fellow developers struggling with design patterns. They get the question in a job interview or they need them in their daily life to build better system designs. Design patterns are a very important piece in the developers toolchain. I will explain about them and how to use them.
Design patterns are solutions to frequent problems in software design. They are kind of like a blueprint that you can customize for a recurring design problem in your code.
You cannot take a pattern and copy it from somewhere else, they are more like a concept for general problems. You can follow the details of the pattern and change it to suit you specific scenario.
Patterns are usually confounded with algorithms because they both describe typical solutions to general problems. An algorithm expresses the detailed steps to solve a problem. A pattern is a higher level description of a design solution. You can use the same pattern in different projects and the code can be different.
Design patterns are classified by their intent and purpose as:
Creational Design Patterns
Creational patterns provides mechanisms for creating objects and reuse existing code.
- Factory Method
- Abstract Factory
Structural Design Patterns
Structural patterns explain how to assemble objects and classes into larger structures and maintining this structures flexible and efficient.
Behavioral Design Patterns
Behavioral patterns are concerned with algorithms and responsibilities between objects.
- Chain of responsibility
- Template Method