An Introduction to Design Patterns
Podcast: Play in new window | Download (50.8MB) | Embed
Subscribe: Apple Podcasts | Spotify | Email | RSS | More
In this episode Will and BJ begin a four part series on design patterns. This week they introduce design patterns giving a brief history and overview of the different sets of patterns. In the subsequent episodes they will be discussing each of the three sets of patterns.
“In software engineering, a design pattern is a general repeatable solution to a commonly occurring problem in software design.” ~ sourcemaking.com
Design patterns are a way of thinking about abstract concepts in Object-Oriented Programming. In the original book 23 patterns were listed divided into three sets of patterns: Creational, Structural, and Behavioral. Will and BJ discuss both the benefits and some of the critiques of using design patterns when designing and developing code.
Episode Breakdown
-
15:13 Gang of Four
“These are fundamental elements of how you design software”
The Gang of Four refers to the four authors (Gamma, Helm, Johnson, and Vlissides) that wrote the original book: Design Patterns – Elements of Reusable Object-Oriented Software. For the book they took ideas from the architectural community. The basis for design patterns is to program to an interface not an implementation favoring object composition over inheritance.
Gall’s Law states that all complex working systems evolved from simpler working systems. Design patterns are Gall’s Law put into practice within the development world. They are not “theological” constructs but developed out of simpler designs that worked and are repeatable.
-
17:58 Usage of Design Patterns
Design patterns create a common language platform for developers no matter their preferred language to communicate and develop best practices. BJ and Will as .NET developers are able to discuss the same concepts with Ruby or Python developer friends.
-
19:53 Benefits of Design Patterns
Design patterns are tested and proven paradigms that speed up the process of development. They have stood the test of time and actually work in practice as opposed to working in academia. They are general solutions that standardize communication between developers no matter the language they use.
-
22:52 Types of Design Patterns
Creational
“It’s a way of abstracting the creation to deal with it the same way you deal with everything else”
Creational patterns have to do with the instantiation mechanisms. They are used to make creating objects easier. Instead of every consumer of a class having to build an object from scratch they can request it.
Structural
“You don’t want to play Operation with your design.”
Structural patterns relate to the relationships between objects or entities. They make it easier for entities to work together. They allow for an intermediate between two objects communicating so that each individual object doesn’t have to know the details of the other. This allows for interchangable code.
Behavioral
Behavioral patterns deal with the communication between objects or entities. They make communication easier and more flexible.
-
32:52 Critiques of Design Patterns
There are many, many, many critiques of design patterns. This is by far not an exhaustive list, one doesn’t exist to our knowledge. These are some of the more prominent critiques.
- Targets the Wrong Problem
The need arises from using languages with insufficient abstractions and many patterns are not needed depending on the language. Using the wrong pattern to solve one problem because it is more apparent but less effective.
- Lacks Formal Foundations
There is a critique primarily from academia that this was an ad hoc study. These patterns are ones that were recognized in reusable code not scientifically formulated and tested.
- Leads to Inefficient Solutions
Critiques on the inefficiency of solutions arise from the need to standardize best practices. A well factored implementation is better than “just enough” design pattern.
- Doesn’t Significantly Differ from Other Abstractions
The idea of design patterns is to abstract abstractions to help humans understand the best way to write for computers.
- Targets the Wrong Problem
IoTease: Project
$20 Raspberry Pi Portable Retro Gaming Console
Using the Raspberry Pi Zero and some cheaper parts a portable retro gaming console can be built for around $20. Running RetroPie for games adding a screen, case, and d-pad and buttons this DIY project makes a great present for the kids.
Hardware
- Raspberry Pi Zero
- 2.4in 240×320 SPI TFT Display
- Lithium Ion Battery 14500 cell
- Prototyping Board
- Charging Circuit
- Micro USB Breakout
- 3V to 5V DC-DC Step Up Boost Converter
Software
- RetroPie
Tricks of the Trade
Knowing when to make trade-offs is the idea that you aren’t building code in a vaccume. Take the time to understand where the code is running such as the quality of the team, how smart the customers are using it, or the runtime environment and ease of debugging. When you use a pattern to try to acheive a result you must make a trade-off that it is consumable by the team working on it.
First 12 minutes is just time waste. These guys talk about their beard being longer than Richard Stallman’s and such suit for 12 minutes, when they first use the term Design Patterns!
Ha, well I mean our email address is neckbeards… That episode was so long ago back when we first got started podcasting and had long beards. Check out some of our more recent episodes, the intros aren’t as long as we’ve gotten better at writing episodes and podcasting in general.