An Introduction to Design Patterns




Complete Developer Podcast show

Summary: <br> 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.<br> “In software engineering, a design pattern is a general repeatable solution to a commonly occurring problem in software design.” ~ sourcemaking.com<br> 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.<br> <br> Episode Breakdown<br> <br> * <br> 15:13 Gang of Four<br> “These are fundamental elements of how you design software”<br> 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.<br> 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.<br> <br> * <br> 17:58 Usage of Design Patterns<br> 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.<br> <br> * <br> 19:53 Benefits of Design Patterns<br> 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.<br> <br> * <br> 22:52 Types of Design Patterns<br> Creational<br> “It’s a way of abstracting the creation to deal with it the same way you deal with everything else”<br> 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.<br> Structural<br> “You don’t want to play Operation with your design.”<br> 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.<br> Behavioral<br> Behavioral patterns deal with the communication between objects or entities. They make communication easier and more flexible.<br> <br> * <br> 32:52 Critiques of Design Patterns<br> 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.<br> <br> * Targets the Wrong Problem<br> 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.<br> <br> * Lacks Formal Foundations<br> 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 formu...