Design Patterns in Python
4.4 (816 ratings)
Course Ratings are calculated from individual students’ ratings and a variety of other signals, like age of rating and reliability, to ensure that they reflect course quality fairly and accurately.
5,431 students enrolled

Design Patterns in Python

Discover the modern implementation of design patterns in Python
4.4 (816 ratings)
Course Ratings are calculated from individual students’ ratings and a variety of other signals, like age of rating and reliability, to ensure that they reflect course quality fairly and accurately.
5,431 students enrolled
Created by Dmitri Nesteruk
Last updated 1/2020
English
English [Auto]
Current price: $69.99 Original price: $99.99 Discount: 30% off
5 hours left at this price!
30-Day Money-Back Guarantee
This course includes
  • 9 hours on-demand video
  • 1 downloadable resource
  • 22 coding exercises
  • Full lifetime access
  • Access on mobile and TV
  • Certificate of Completion
Training 5 or more people?

Get your team access to 4,000+ top Udemy courses anytime, anywhere.

Try Udemy for Business
What you'll learn
  • Recognize and apply design patterns
  • Refactor existing designs to use design patterns
  • Reason about applicability and usability of design patterns
Course content
Expand all 107 lectures 09:11:57
+ Introduction
1 lecture 06:51

An overview of the Design Patterns in Python course.

Preview 06:51
+ The SOLID Design Principles
7 lectures 01:01:21

What are SOLID principles, where do they come from and why do we care?

Overview
00:52

A look at the Single Responsibility Principle, which states that a class should only have one reason to change. Also tied to the concept of Separation of Concerns which is basically stating the same thing.

Single Responsibility Principle
07:26

A discussion of the Open-Closed Principle, which states that classes should be open for extension, but closed for modification. In other words, you should extend functionality using interfaces and inheritance rather than jumping back into already-written/tested code and adding to it or changing it.

Open-Closed Principle
20:55

The Liskov Substitution Principle states that subtypes should be substitutable for their base types.

Liskov Substitution Principle
07:43

The Interface Segregation Principle is simple: don't throw everything in the kitchen sink into an interface because then all its users will have to implement things they do not need. Instead, split the interface into several smaller ones.

Interface Segregation Principle
09:33

Not to be confused with dependency injection, dependency inversion specifies that high-level modules should not depend on low-level ones; both should depend on abstractions. Confusing, huh?

Dependency Inversion Principle
12:26

A summary of the things we've learned in this section of the course.

Summary
02:26
+ Builder
6 lectures 33:12

A brief note about the three categories of design patterns: creational, structural and behavioral.

Gamma Categorization
03:36

An overview of the Builder design pattern.

Overview
01:20

An overview of the Builder design pattern.

Builder
12:15

A look at how several builders can work together through a common fluent interface.

Addendum: there's a small mistake in the PersonBuilder initializer; instead of =Person() it should read =None, see the attached source code for the updated example.

Preview 09:15

How to combine the functionality of several builders without breaking OCP.

Builder Inheritance
05:45
Builder Coding Exercise
1 question

A summary of the things we've learned about the Builder design pattern.

Summary
01:01
+ Factories
5 lectures 32:55

An overview of the Factory design pattern.

Overview
02:43

A constructor is a rather limited tool. A factory method adds flexibility.

Factory Method
08:39

A factory is a separate class for creating objects.

Factory
06:05

If you have a hierarchy of objects, you can have a corresponding hierarchy of factories.

Abstract Factory
14:25
Factory Coding Exercise
1 question

A summary of the things we've learned about the Factory design pattern.

Summary
01:03
+ Prototype
4 lectures 18:24

An overview of the Prototype design pattern.

Overview
01:54

Learn about deep copying and the Prototype pattern.

Prototype
08:56

Well known prototypes can be put into a factory for additional convenience.

Prototype Factory
06:50
Prototype Coding Exercise
1 question

A summary of all the things we've learned about the Prototype design pattern.

Summary
00:44
+ Singleton
7 lectures 29:58

An overview of the much-maligned Singleton design pattern.

Overview
03:07

You can make an allocator that keeps returning the same object. Trouble is, the initializer still gets called more than once!

Singleton Allocator
03:52

Let's implement the Singleton as a decorator!

Note: if you don't know how Python decorators work, see the Decorator pattern lectures.

Singleton Decorator
02:40

Let's implement the Singleton using a metaclass!

Preview 02:27

A peculiar variation on the 'canonical' singleton, Monostate objects all share the same static dictionary.

Monostate
06:26

Why is the Singleton problematic? What can we do to fix it?

Singleton Testability
09:57
Singleton Coding Exercise
1 question

A summary of the things we've learned about the Singleton design pattern.

Summary
01:29
+ Adapter
4 lectures 14:40

An overview of the Adapter design pattern.

Overview
01:12

Let's implement the adapter pattern — perhaps not in the most efficient manner.

Adapter (no caching)
08:31

Let's improve our Adapter implementation with some caching!

Adapter (with caching)
04:01
Adapter Coding Exercise
1 question

A summary of what we've learned about the Adapter design pattern.

Summary
00:56
+ Bridge
3 lectures 11:12

An overview of the Bridge design pattern.

Overview
01:46

Let's implement the Bridge design pattern!

Bridge
09:05
Bridge Coding Exercise
1 question

A summary of the things we've learned about the Bridge design pattern.

Summary
00:21
+ Composite
4 lectures 19:39

An overview of the Composite design pattern.

Note: for more information on iteration, please consult the Iterator pattern lectures.

Overview
01:22

First, a simple example: grouping geometric shapes.

Geometric Shapes
06:06

Implementing connections between neurons and neuron layers with the Composite pattern.

Preview 10:29
Composite Coding Exercise
1 question

A summary of the things we've learned about the Composite design pattern.

Summary
01:42
+ Decorator
5 lectures 25:50

An overview of the Decorator design pattern.

Overview
02:35

To some extent, the Decorator pattern is built right into the Python language. Let's take a look at how Python's functional decorators work.

Python Functional Decorators
05:37

A classic GoF decorator is a class that gives additional functionality to the underlying class. The only problem is the original class' attributes are now inaccessible.

Classic Decorator
08:34

A dynamic decorator lets us treat the decorator as if it were the object it decorates. This works for purposes of ordinary programming, but won't work with any sort of metaprogramming.

Dynamic Decorator
07:24
Decorator Coding Exercise
1 question

A summary of the things we've learned about the Decorator design pattern.

Summary
01:40
Requirements
  • Good understanding of Python
  • Familiarity with latest Python language features
  • Good understanding of object-oriented design principles
  • A computer with the latest Python release and (hopefully) an IDE
Description

Course Overview

This course provides a comprehensive overview of Design Patterns in Python from a practical perspective. This course in particular covers patterns with the use of:

  • The latest versions of the Python programming language

  • Use of modern programming approaches: dependency injection, reactive programming and more

  • Use of modern developer tools such as JetBrains PyCharm

  • Discussions of pattern variations and alternative approaches

This course provides an overview of all the Gang of Four (GoF) design patterns as outlined in their seminal book, together with modern-day variations, adjustments, discussions of intrinsic use of patterns in the language.

What are Design Patterns?

Design Patterns are reusable solutions to common programming problems. They were popularized with the 1994 book Design Patterns: Elements of Reusable Object-Oriented Software by Erich Gamma, John Vlissides, Ralph Johnson and Richard Helm (who are commonly known as a Gang of Four, hence the GoF acronym).

The original book was written using C++ and Smalltalk as examples, but since then, design patterns have been adapted to every programming language imaginable: C#, Java, Python and even programming languages that aren't strictly object-oriented, such as JavaScript.

The appeal of design patterns is immortal: we see them in libraries, some of them are intrinsic in programming languages, and you probably use them on a daily basis even if you don't realize they are there.

What Patterns Does This Course Cover?

This course covers all the GoF design patterns. In fact, here's the full list of what is covered:

  • SOLID Design Principles: Single Responsibility Principle, Open-Closed Principle, Liskov Substitution Principle, Interface Segregation Principle and Dependency Inversion Principle

  • Creational Design Patterns: Builder, Factories (Factory Method and Abstract Factory), Prototype and Singleton

  • Structrural Design Patterns: Adapter, Bridge, Composite, Decorator, Façade, Flyweight and Proxy

  • Behavioral Design Patterns: Chain of Responsibility, Command, Interpreter, Iterator, Mediator, Memento, Observer, State, Strategy, Template Method and Visitor

Who Is the Course For?

This course is for Python developers who want to see not just textbook examples of design patterns, but also the different variations and tricks that can be applied to implement design patterns in a modern way. For example, the use of decorators and metaclasses allows us to prepackage certain patterns for easy re-use.

Presentation Style

This course is presented as a (very large) series of live demonstrations being done in JetBrains PyCharm and presented using the Kinetica rendering engine. Kinetica removes the visual clutter of the IDE, making you focus on code, which is rendered perfectly, whether you are watching the course on a big screen or a mobile phone. 

Most demos are single-file, so you can download the file attached to the lesson and run it in PyCharm, IDLE or another IDE of your choice.

This course does not use UML class diagrams; all of demos are done via live coding.

Who this course is for:
  • Software engineers
  • Designers
  • Architects