Design patterns in Java
Design patterns are the programming best practices followed by software developers. They were created as a solution to commonly occurring problems faced during software development. They are repeatable solutions to problems that generally arise in everyday software designing.
Design pattern categories
There are a total of 23 patterns which are classified into the following three categories:
1. Creational patterns: These patterns are related to classes creation and inheritance. They may also include patterns related to object creation.
2. Structural patterns: These patterns are how classes are composed; the composition of objects, classes in order to create interfaces.
3. Behavioral patterns: These patterns are related to how objects communicate with one another within the software.
The following table lists down each design pattern with respect to the category it falls in:
Why use design patterns
Design patterns simplify the process of software development by providing a basic structure for the problem at hand. Following are some of the advantages of using design patterns in your code:
- Provide a generic solution, i.e. code can be reused in different projects.
- Design patterns are a proven solution for common problems that arise in code.
- Using design patterns makes it easy to test the system as they are already proven solutions.
- All design patterns follow specific, self-descriptive naming conventions, which enhances the readability of the code.
Free Resources