Design patterns provide tried and tested, optimum solutions to some commonly occuring problems.
Benefits of design patterns:
- Code reusability, as you might heard in object oriented programming concepts, instead of developing something over and over again from scratch, we want to reuse existing one to reduce development costs and time. Design patterns makes reusing easier.
- It makes communication easier by providing a common language on some design details.
For example an app needs a single instance of a class at runtime. if there isn't any instance created then it should be created: if there is, that one should be used instead of creating again etc.
or you could just say we need a Singleton class.
- Robust and effective solutions. As said in the first sentence design patterns are tried and tested solutions they are result of extensive experience.
- Improves code readability. It helps new or less experienced developers learn and adopt quickly.
- It helps your code to be more flexible and extensible.
Ok, we talked about some of the benefits of design patterns and want to learn more about them, so where do we start? Design patterns are divided into four category as Creational, Structural, Behavioral and Concurrency. In this writing, i am gonna try to explain some of them.