While talking of design patterns there are two things we take into account. First, design and second, pattern. For every problem there should be a feasible design and if the problem occurs quite frequently then we create a reusable solution to that problem. This reusable solution is called design pattern. A design is considered to be good if it helps in developing a system that is behaviorally, economically, and socially feasible and can accommodate changes with minimal effort. There could be more than one good design for a particular system and we can pick a good design and create a pattern which solves a particular type of problem. That pattern will describe the problem which it was created for and then it can be used over and over again whenever the problem occurs.
Formally the word pattern was used by Christopher Alexander (a building architect), who defined a pattern as "a solution to a problem in a context." Alexander says that a description of a pattern involves four items:
Christopher Alexander further postulated that patterns could be used together to solve complex architectural problems.
However, Christopher talks of architectural patterns but patterns occur in software design too. Gamma, Helm, Johnson, and Vlissides in their classical book "Design Patterns: Elements of Reusable Object-Oriented Software" identified several patterns and developed standards for cataloguing new ones. Note that the authors did not create the patterns described in the book. Rather, they identified these patterns as already existing within the software community, patterns that reflected what had been learned about high-quality designs for specific problems.
To describe a design pattern there could be several different forms. We include the following items in pattern description. These items we are calling key features of a design pattern.
|Name||Every pattern has a unique name that identifies that pattern.|
|Purpose||The problem that the pattern is trying to solve.|
|Solution||How the pattern provides a solution to the problem in the context in which it shows up.|
|Constraints||The constraints and forces we have to consider in order to accomplish it.|
While explaining design patterns one by one we will include above key features in every design pattern's description.
Erich Gamma et al. in their book 'Elements of Reusable Object-Oriented Software' on design patterns classified design patterns in three categories - creational, structural, and behavioral.
Creational patterns address the question "how an object should be created so that it does not add the complexity to new object creation?" Creational patterns isolate the details of object creation. This pattern is useful when there are yet-to-be known classes in an application. Following design patterns fall under creational patterns:
Structural patterns are useful when classes and objects are composed to form larger structures. These patterns use inheritance to compose interfaces or implementations. For example, consider how multiple inheritance mixes two or more classes into one. The result is a class that combines the properties of its parent classes. This pattern is particularly useful for making independently developed class libraries work together. Following design patterns fall under structural patterns:
Behavioral patterns are used for assigning responsibilities between objects. Behavioral patterns describe how do objects interact with each othe?. They focus on how objects communicate with each other. Behavioral class patterns use inheritance to distribute behavior between classes and behavioral object patterns use object to assign the responsibilities between objects. Following design patterns fall under behavioral patterns:
In this tutorial we presented a quick overview of Java design patterns. We will discuss all design patterns one by one in individual tutorials. Hope you have enjoyed reading this tutorial, please do write us if you have any suggestion/comment or come across any error on this page. Thanks for reading!
Rory visits a beekeeper in Manchester who is gluing wireless chips to his bees.The long wait for a Persian iPhone keyboardPosted on Friday September 22, 2017
The new Apple's iOS has Persian keyboard. BBC Persian's Sam Farzaneh discusses why it is an important feature.Uber London loses licence to operatePosted on Friday September 22, 2017
Ride-hailing app Uber is "not fit and proper" to operate in London, the transport regulator says.Courtesy BBC News