So, in my last entry we talked about Modeling Languages and Drawing Software where this process of design is not much as deterministic but more empirical. Now, we can say that software design, just like any type of design is based on principles of design and design patterns. As of now, let´s talk bout design patterns.
Origin.
The concept of “Design Patterns” began to be used in Architecture with Christopher Alexander in 1977 with the aim of reusing designs that had been applied in other constructions and that were cataloged as complete.
“Each pattern describes a problem that occurs over and over again in our environment and the describes the core of the solution to that problem is such way that you can use this solution a million times over without ever doing it the same way twice.”
Christopher Alexander (Architect)
With this being said, a pattern must be applicable to multiple similar situations.
For example:
- In designing room layout: People feel more comfortable in rooms with at least two walls.
- In the case of hallways: keep them as short as possible, make them look like rooms with carpets, shelves, windows, seating alcoves.
Since Christopher Alexander in 1977, design patterns have been applied in much other areas, including software engineering.
Design Patterns in Software.
Kent Beck and Ward Cunningham used the ideas of Design Patterns form Christopher Alexander for the design of Smalltalk´s GUI in OOPSLA, 1987.
Gang of Four (Gamma, Helm, Johnson, Vlissides) with the Design Patterns: Elements of Reusable Object-Oriented Software, 1991-1994.
Based on the previous book from the Gang of Four that popularized the term of “Design Patterns” in Software, we obtain three types of patterns:
- Behavioral
- Creational
- Structural.
Behavioral Pattern.
This type of pattern is related with objects, classes, and relations between them.
- Observer: Being aware of the change or events that an object evokes to act accordingly.
- Strategy: Allows to choose an algorithm as a response to different contexts or situations.
- Command: Encapsulates some operation along with its parameters in an object.
Creational Pattern.
This type of pattern is related to the instances of objects, the logic of their creation and their encapsulation.
- Builder: The same construction process that serves different representations of an object.
- Prototype: Allows you to create new objects using “templates” or cloning objects.
- Factory method: A creation method used and implemented in creation within subclasses.
Structural Pattern.
This type of pattern is related to the composition and complex structures of classes and objects.
- Wrapper: Adapts and interface so that it can be used in some way that it could not before.
- Composite: Allows to build complex objects from simpler ones thanks to recursive composition.
- Facade: Creates a simplified interface to navigate a more complex system.
If you want to get more in-depth with design patterns check out this video from TechLead:
Summary
We can say that Design Patterns in software are a reusable way to solve a common problem, that helps us save time, increase the validity of our code and establish generalization in our community. Design patterns helps us achieve successful practices that capture the experience in patterns and make it accessible to non-experts. A catalog of patterns helps the communication and documentation of the development process in the dissemination of best practices and contribute to the formation of Software Engineering as a discipline.




Leave a comment