What are Design Patterns?
Design Pattern is a used and tested solution for a known problem. In simple words, you can say a general reusable solution to a commonly occurring problem within a given context in software design.
Why Design Patterns?
Because good software design requires considering issues that may not become visible until later in the implementation.
It prevents issues that can cause a significant problem in the software and also improves the code readability.
Different types of Design pattern by GOF(Gang of Four):
- Creational Design Pattern
- Structural Design Pattern
- Behavioural Design Pattern
Again they have also categorised into different types, such as:
Creational Design Pattern, DP = Design Pattern
- Factory Method DP
- Abstract Factory DP
- Builder DP
- Prototype DP
- Singleton DP
Structural Design Pattern:
- Adapter DP
- Bridge DP
- Composite DP
- Decorator DP
- Facade DP
- Flyweight DP
- Proxy DP
Behavioural Design Pattern:
- Observer DP
- State DP
- Strategy DP
- Iterator DP
- Chain of Responsibility DP
- Command DP
- Interpreter DP
- Mediator DP
- Memento DP
- Template Method DP
- Visitor DP
Is it necessary to use design pattern always? No, because we should not try to force the code into a specific way; instead, notice which practices crystallise out of your code. I mean, writing a program that does X using the pattern Y is not a good idea.
The question is, when did you start doing everything using patterns? Not all solution fit neatly into an existing design pattern, and adopting a practice may mean that you muddy the cleanness of your solution.
What is the difference between Design-Pattern and Framework?
- DP are the recurring solution to a problem that can come in an application or software life. A framework is a group of components that helps each other provide a reusable architecture for the application.
- DP are logical. The framework is more physical.
- DP is independent of language, whereas the framework depends on the language.
- DP is generic and can be used in any application, whereas the framework is domain-specific.
To be continued.