In this chapter, we are going to discuss on the concept of Design Patterns which denote the best practices in the object-oriented software development. Almost all software developers face general problems in their day to day life during software development. These design patterns not only provide the best practices, but also a common solution to these general problems. These solutions, which are now standardised through designers and their patterns, were actually obtained by many experienced software developers through trial and error approach over a period of time in the software industry. These design patterns help novice developers learn about the software design very swiftly and easily.
In this tutorial, we are going to implement design pattern concepts by following the step by step approach using Java /J2EE as the programming language. Therefore, it is an assumption made here is that the readers of this tutorial are well versed with the basic java programming concepts.
Invention of Design Pattern:
Design Patterns were actually invented as an architectural concept by Christopher Alexander in the year of 1977. A design pattern book by the gang of four (GOF) refers to a popular book ( Design Patterns – Elements of Reusable Object-Oriented Software) written by four experienced developers ( Erich Gamma, John Vlissides, Ralph Johnson, and Richard Helm) on the concept of Design Pattern in the Software development. This book was published in the year of 1994. It is mainly based on best practices and the following ideologies of object orientated design.
• Supporting program to an interface and not an implementation.
• Supporting object composition over inheritance.
Application and use of Design Patterns
Object-oriented design patterns characteristically demonstrate the relationships and interactions between the class objects, without stipulating the final application class objects which are involved. They can be observed as a structured approach to computer programming between the levels of a software design paradigm and a concrete algorithm. The following two are the main usages of the Design Patterns by the software developer in any software application development.
1. Provision for Common platform for the software developers: Design patterns help to provide a standard terminology to novices as well as experienced software developer which are precise to a particular problem or scenario. E.g., a singleton design pattern indicates the use of single object in a program. Therefore, all developers who are familiar with the single design pattern can easily make use of the single object in their program and can easily transfer the knowledge to other team members who are going to program on a singleton design pattern.
2. Best Programming Practice: Design patterns provide the best solutions to the programming problems or scenarios which a software developer usually face in their day to day coding practices. Such standardised solutions through the design patterns were actually obtained by many experienced software developers through a trial and error approach over a period of time in the software industry. Therefore, these design patterns help novice developers to learn about the software design very swiftly within no time.
Categories of the Design Patterns
Referring to the popular book of Design Patterns – Elements of Reusable Object-Oriented Software, there are total 23 design patterns. These design patterns can be categorized into the following three categories:
• Creational design pattern.
• Structural design pattern.
• Behavioral design patterns.
Another category of design pattern other than from this book is known as J2EE design pattern. The following is the explanation for all of these categories of the design patterns,
In this chapter, we discussed the overview, concepts, application and categorization of various Design Patterns which obey standardized coding practice and help novice developers to learn about the software design very swiftly within no time.