• 8 hours
  • Easy

Free online content available in this course.

course.header.alt.is_video

course.header.alt.is_certifying

Got it!

Last updated on 3/28/24

Build Complex Systems With the Help of Design Patterns

What if you are driving a car and one of the tires goes flat? 🚗  It is a problem that happens often enough that people have come up with a solution. (Well, other than calling a tow service.) The answer is that the car has an extra tire (a spare), just in case.

This is an example of a pattern. A problem that occurs so often, it is given a name and a known solution. I can say “spare tire,” and you immediately know what I mean. Now, each car has a different implementation of the idea. Some spare tires are small, and others are full-sized. Some are easy to find in the trunk; others are not. But the big picture is, you know what I mean when I refer to the spare tire.

What Is a Design Pattern?

A design pattern is a proven, reusable solution to a commonly occurring problem. It describes the static or dynamic nature of classes and objects that implement the solution. For any design pattern, you are free to tailor the solution to fit your particular situation.

In 1994, the “Gang of Four” (Erich Gamma, Richard Helm, Ralph Johnson, and John Vlissides) released the book Design Patterns: Elements of Reusable Object-Oriented Software. These four authors looked at over 300 projects that other developers were working on. They recognized that many of the same problems kept appearing.

They also noticed that these various projects solved the problems in roughly the same way. Their book discusses these problems and solutions, giving them the name patterns.

The world of design patterns has evolved since then, with the popularity of more modern languages, such as Python, designed to avoid some of these problems. 🎉

However, it’s still a super important concept regardless of the language - and in this course, we’ll be looking at three that are especially suitable to Python.

  • The constant design pattern: this very simple pattern makes it easy for developers to update your code values.

  • The decorator design pattern: this medium-complexity pattern makes it easy to create many functions that do similar things.

  • The model-view-controller pattern: this pattern is an architecture you can use for your entire application, making it easy for users to interact with your system reliably.

Let’s Recap!

  • Patterns are proven, reusable solutions to commonly occurring problems.

  • Use of patterns leads to better understandability and maintainability.

Meet me in the next chapter, and we’ll get started with the constant design pattern!

Example of certificate of achievement
Example of certificate of achievement