About this ebook
Related to The Design Patterns Companion
Related ebooks
Implementing Design Patterns in C# 11 and .NET 7 - 2nd Edition: Learn how to design and develop robust and scalable applications using design patterns (English Edition) Rating: 0 out of 5 stars0 ratingsDesign Patterns Made Easy: A Practical Guide with Examples Rating: 0 out of 5 stars0 ratingsDesign Patterns in Practice: Unlock the Secrets of Expert-Level Skills Rating: 0 out of 5 stars0 ratingsMastering Java Design Patterns: Unlock the Secrets of Expert-Level Skills Rating: 0 out of 5 stars0 ratingsObject-Oriented Analysis: Using Design Patterns Rating: 0 out of 5 stars0 ratingsDesign Patterns in Java: From Basics to Expert Proficiency Rating: 0 out of 5 stars0 ratingsCase Studies in Design Patterns Rating: 5 out of 5 stars5/5Mastering Python Design Patterns: Craft essential Python patterns by following core design principles Rating: 0 out of 5 stars0 ratingsPatterns, Principles, and Practices of Domain-Driven Design Rating: 0 out of 5 stars0 ratingsJava 8 to 21: Explore and work with the cutting-edge features of Java 21 (English Edition) Rating: 0 out of 5 stars0 ratingsMastering C++ Design Patterns: Create Efficient and Scalable Code Rating: 0 out of 5 stars0 ratingsMastering the Craft: Unleashing the Art of Software Engineering Rating: 0 out of 5 stars0 ratingsReliable JavaScript: How to Code Safely in the World's Most Dangerous Language Rating: 0 out of 5 stars0 ratingsMastering Python Design Patterns for Scalable Applications: Unlock the Secrets of Expert-Level Skills Rating: 0 out of 5 stars0 ratingsDesign for Software: A Playbook for Developers Rating: 4 out of 5 stars4/5Learning Software Architecture Rating: 0 out of 5 stars0 ratingsJavaScript Domain-Driven Design Rating: 3 out of 5 stars3/5Mastering Design Patterns with Python: Essential Techniques for Efficient Software Development Rating: 0 out of 5 stars0 ratingsAbout Face: The Essentials of Interaction Design Rating: 4 out of 5 stars4/5Swift 2 Design Patterns: Build robust and scalable iOS and Mac OS X game applications Rating: 0 out of 5 stars0 ratingsDesign in Object Technology 2: The Annotated Class of 1994 Rating: 0 out of 5 stars0 ratingsEssential Design Patterns in Java: Mastering Core Concepts and Practical Applications Rating: 0 out of 5 stars0 ratingsMastering Object-Oriented Design Patterns in Modern C++: Unlock the Secrets of Expert-Level Skills Rating: 0 out of 5 stars0 ratingsDesigning for the Digital Age: How to Create Human-Centered Products and Services Rating: 4 out of 5 stars4/5Phaser.js Game Design Workbook: Game development guide using Phaser JavaScript Game Framework Rating: 0 out of 5 stars0 ratingsThe Black Book of the Programmer Rating: 0 out of 5 stars0 ratingsGame Development Patterns and Best Practices: Better games, less hassle Rating: 5 out of 5 stars5/5Architectural Metapatterns: The Pattern Language of Software Architecture Rating: 0 out of 5 stars0 ratings
Project Management For You
The PARA Method: Simplify, Organize, and Master Your Digital Life Rating: 5 out of 5 stars5/5Building a Second Brain: A Proven Method to Organize Your Digital Life and Unlock Your Creative Potential Rating: 4 out of 5 stars4/5Managing Time (HBR 20-Minute Manager Series) Rating: 5 out of 5 stars5/5Project Management For Dummies Rating: 4 out of 5 stars4/5Design Thinking for Beginners: Innovation as a Factor for Entrepreneurial Success Rating: 5 out of 5 stars5/5SHRM Society for Human Resource Management Complete Study Guide: SHRM-CP Exam and SHRM-SCP Exam Rating: 4 out of 5 stars4/5Q & As for the PMBOK® Guide Sixth Edition Rating: 5 out of 5 stars5/5CompTIA Project+ Study Guide: Exam PK0-005 Rating: 0 out of 5 stars0 ratingsITIL® 4 Essentials: Your essential guide for the ITIL 4 Foundation exam and beyond Rating: 5 out of 5 stars5/5Managing Projects (HBR 20-Minute Manager Series) Rating: 4 out of 5 stars4/5Managing Construction Projects Rating: 4 out of 5 stars4/5PMP Question Bank Rating: 4 out of 5 stars4/5ITIL® 4 Direct, Plan and Improve (DPI): Your companion to the ITIL 4 Managing Professional and Strategic Leader DPI certification Rating: 0 out of 5 stars0 ratingsThe Third Wave: An Entrepreneur's Vision of the Future Rating: 4 out of 5 stars4/5Personal Knowledge Graphs: Connected thinking to boost productivity, creativity and discovery Rating: 5 out of 5 stars5/5Managing For Dummies Rating: 4 out of 5 stars4/5PMP Exam Companion Rating: 0 out of 5 stars0 ratingsCAPM Success Path : MCQs and Explanations for Prep Excellence Rating: 0 out of 5 stars0 ratingsAgile Project Management: Scrum for Beginners Rating: 4 out of 5 stars4/5CBAP / CCBA Certified Business Analysis Study Guide Rating: 5 out of 5 stars5/5ITIL Foundation Essentials ITIL 4 Edition - The ultimate revision guide Rating: 5 out of 5 stars5/5Kanban in 30 Days: Modern and efficient organization that delivers results Rating: 5 out of 5 stars5/5The Book on Flipping Houses: How to Buy, Rehab, and Resell Residential Properties Rating: 4 out of 5 stars4/5Change Management for Beginners: Understanding Change Processes and Actively Shaping Them Rating: 5 out of 5 stars5/5Product Management For Dummies Rating: 5 out of 5 stars5/5
Reviews for The Design Patterns Companion
0 ratings0 reviews
Book preview
The Design Patterns Companion - Scott L Bain
Introduction From the Author
Design patterns were originally delineated in the seminal work of the Gang of Four
: Erich Gamma, Richard Helm, Ralph Johnson, and John Vlissides. They, in turn, were responding to an earlier work by the architect Christopher Alexander, The Timeless Way of Building. The Gang of Four's work, Design Patterns: Elements of Reusable Object-Oriented Software, received a lot of attention when it was originally published in 1994.
Some have suggested, however, that the industry has moved beyond the patterns in the more than two decades that have passed since its publication, and that in the age of agile processes and test-driven development, the patterns are no longer relevant. They say that patterns represent an old view, namely big design up front.
I disagree. Not only do I think the patterns are relevant today, I believe they are far more relevant than they were when the work was originally published. Here's why:
Patterns form a rich language of design. This is all the more important now that nearly all software projects are highly collaborative. We need reliable ways to communicate and make group decisions. Nearly all complex human activity involves specialized language: medicine, law, engineering, etc. They all have their own rich nomenclature to describe what is being proposed, or what has been done.
Patterns all follow the principles of good design in different ways. This means they are highly changeable without decay. The agile movement says, among other things, that we must embrace change. The patterns help us to do this.
This book is not meant to teach you the patterns; see the References section for books that do. This is meant to be a field guide for those who are already pattern practitioners, something to refer to as part of your day-to-day activities.
What Design Patterns Represent
The Design Patterns movement, begun (in software) by the Gang of Four (GoF) (Gamma, Helm, Johnson, & Vlissides, 1994), essentially elevated certain design elements as valuable, repeated, and high-quality examples of a particular approach to design.
Their general advice was given in three parts:
Design to interfaces.
Favor composition over inheritance.
Encapsulate the concept that varies.
All patterns adhere to this rubric in different ways. But they also all exhibit certain qualities of design, and they all adhere to a set of shared principles. What I will outline in the following pages are the three bits of guidance listed above, as well as how each pattern respects:
Strong cohesion
Proper coupling
Robust encapsulation
Avoiding redundancy
Testability
In addition, I will submit that each pattern follows good principles in design, such as open-closed, the separation of concerns, and others.
I'll start with the definitions, then examine the patterns.
Design to Interfaces
Behavior in object-oriented systems is a reflection of the interaction of objects. If you change the objects or alter their interactions, the resulting behavior changes.
This means that objects have relationships to other objects, usually through references that are used to call methods. The GoF recommends that these relationships are defined based on how the objects look to each other, not by how the objects are implemented.
It's easy to misinterpret this to mean every object should have a separate interface,
referring to the type interface
that many languages provide. But the advice was not meant to indicate any language-specific idiom.
An interface
means any defined means of communication. A method signature is an interface; the collective public methods of a class are an interface; an abstract class is an interface; etc. What is meant by that is the interface of any interaction should be based on what is needed by the clients and not the way the behavior is implemented. Changing the implementation should not affect the interface, and thus should not affect the clients.
In other words, the full version of this is design to interfaces (how you work with them) rather than implementations (what each actually does).
Favor Composition Over Inheritance
Composition/aggregation indicates a has-a
relationship between objects. Inheritance, on the other hand, indicates an is-a
relationship. The GoF would seem to be suggesting that you lean toward (favor
) the former rather than