What Will You Learn?
- What are software design patterns?
- What are the use cases for software design patterns?
- What are common types of software design patterns?
- How do I choose the right software design pattern?
- Where can I learn more about software design patterns?
The Basics
Learn design patterns to accelerate software development. A design pattern considers languages and frameworks as its components. Design patterns help you solve a problem with many software languages and frameworks.
Each design pattern is a three-part rule expressing a relationship between a specific context, problem, and solution. It is a solution to a recurring problem within a particular context.
High-quality patterns define the consequences of using them and work with many languages and frameworks.
Software design patterns are a map and not a prescription. Patterns help define the why and how within your context, but not when to apply them.
Patterns used in the wrong context at the wrong time are anti-patterns. Identifying and eliminating them is a primary responsibility of software developers.
Primary Use Cases
- Save time
- Quickly communicate ideas
- Solve recurring problems
Purpose
Understanding a design pattern’s purpose first is an effective approach. Its purpose should reflect what it does.
Types
There are three types of design patterns. Creational, structural, and behavioral.
Creational
Creational design patterns manage object creation. A basic form of object creation can result in design problems. Creational design patterns address this by controlling object creation.
An example is the builder pattern which separates the construction of a complex object from its representation.
Imagine you are building an itinerary. When building the itinerary, you’ll need a car, a hotel, a flight, etc. Use the builder pattern to acquire a car, a hotel, and a flight with different workflows.
Structural
Structural design patterns ease a design by identifying a simple way to realize entity relationships.
An example is the module pattern. It is the most common structural pattern in everyday software implementations. The module pattern is a fundamental concept of a language. For example, in Python, any .py file is a module, along with Terraform, where each .tf file is a module.
A module is self-contained and runs independently of other code.
Behavioral
Behavioral design patterns identify common communication patterns. These patterns increase communication flexibility.
An example is the strategy pattern which adjusts data type behaviors.
Imagine your program accepts multiple payment types. When someone pays with PayPal, your strategy differs from paying with American Express.
The strategy pattern simplifies adding new payment types with different concerns.
How To Choose
Choosing an appropriate design pattern is a crucial design decision.
Follow these steps to simplify design pattern selection.
- Thoroughly read its description to form an overview.
- Identify the design problem it solves.
- Learn what principles it follows.
- Study how it relates to other patterns.
- Identify code change needs and how it applies.
Conclusion
While software design patterns aid with design choices, be judicious with their use.
Follow this checklist to validate its usage.
- Is the pattern appropriate for your context?
- Does the problem it solves repeat across space and time?
- Does the pattern solve your problems, or does it introduce new problems?
Software design patterns pack a serious punch. With power comes great responsibility, so strive to understand a pattern before using it.
Best of luck on your endless journey with software design patterns!
Learn Software Design Patterns - Beyond the Basics
- Videos
- Books
- Mastering Python Design Patterns: A guide to creating smart, efficient, and reusable software, 2nd Edition — Amazon
- Design Patterns: Elements of Reusable Object-Oriented Software — Amazon
- Microservices Patterns: With examples in Java — Amazon
- Head First Design Patterns, 2nd Edition — O’Reilly
- Software Architecture Design Patterns in Java — O’Reilly
Related Content
- The 7 Most Important Software Design Patterns
- Design Patterns – Revisiting Gang of Four
- Keep it Simple with the Strategy Design Pattern
- Important Java Design Patterns You Need to Know About
- The Catalog of Design Patterns
- Design Patterns in C# With Real-Time Examples
- Design Patterns: Who gives a 💩?
Other Learning
- How Do I Learn Effectively?
- Learn 3D Graphics
- Learn Amazon Athena
- Learn Asymptotic Notations
- Learn AWS Amplify
- Learn Color Theory
- Learn Data Visualization
- Learn Design Systems
- Learn ECS
- Learn GitHub
- Learn How To Prioritize
- Learn Java
- Learn Java Coding Challenges
- Learn JavaScript
- Learn jq
- Learn Kubernetes
- Learn Python
- Learn Rendanheyi
- Learn SignalFx
- Learn Software Architecture
- Learn Software Design Patterns
- Learn Structurizr
- Learn systemd
- Learn Terraform