When you build software, you have to face lots of problems. There are some problems, which are very common and faced by lots of software developers. What If we have common problems, solved it. Anyone having the same problem can use those solutions. This is the actual concept behind Design Patterns.
[tmh_article_ads]
We can solve Object-oriented conceptual problems with the help of some common solutions. Throughout the industries, we have some professionals providing some best practices.
We call these best practices as “Design pattern”. It all started around 1994. Programmers, after writing lots of code, experienced problems over time which they solved. They noticed some of these solutions can be categorized. They are four people “Gang of Four” (GOF). There is a book by these people, in which they have mentioned principles of design patterns. If you want to make software using best practices, Just follow design patterns.
There are two questions for software developer:
Q: Should we know all Design patterns?
Ans: Yes, You should know all the design patterns.
Q: Should we implement all the design patterns in a project?
Ans: You should not use all the design patterns. It should depend on your requirements. If your requirement is to create an object, then you have to follow the Creational Design Patterns.
If you want to have composed objects,i.e. You want to include objects inside an object or If one object has some features and another object has some features. One object want to use another object, then you have to follow the Structural Design Patterns.
If you don’t want to compose objects but want to communicate between objects. At this point, you have to follow the Behavioural Design patterns.
It’s not necessary to use all design patterns. Just think about your logic, requirements, and software problems
So, basically, when you know patterns, you know solutions to problems that are extremely common in software engineering.
Benefits of Design patterns:
- Reduce code length
- Minimize bugs
- Easy to understand, clean and elegant codes
We shall go through all these designs patterns one by one.
Creational Design Patterns
This design pattern is all about class instantiation. This explains how to create an object effectively, how we can reuse an object which we have created and also explains how to control object creation.
Structural Design Patterns
These design patterns are all about class and object composition. It uses inheritance to compose interfaces. It defines a way to compose objects to obtain new functionality. It describes how objects and classes can be combined to form the larger structure.
Behavioral Design Patterns
These design patterns are those which are concerned with the interaction between the objects. The interaction between the objects should be such that they are talking to each other and still are loosely coupled.
Try to solve problems with the help of Design Patterns. Approx. we have 23 basic patterns.
Structural Pattern
Behavioural Pattern
Share your thoughts