4.67 out of 5
4.67
86 reviews on Udemy

Python: SOLID Principles and Top Design Patterns

Learn how to improve your Python code through mastery of S.O.L.I.D principles and the Top GoF Design Patterns.
Instructor:
Piotr Paweska
809 students enrolled
English [Auto]
*Master* the most important and fundamental design patterns in modern Software Engineering within the *Python* ecosystem
Learn and internalize the S.O.L.I.D principles of design like seasoned *Senior Developers* do.
Get a deep understanding of the WHAT, WHY, and HOW for those *Fundamental Design Patterns*.
Get a full Architectural exposition (with UML) of each pattern as well as *real-world* scenarios with hands-on coding examples for each pattern.
Work on and complete Object Oriented *Python* assignments that will push your understanding of those patterns deeper and more fundamentally.
Learn how to *identify* the *best pattern* for the given Architectural challenge.

We all want to become better software developers and be able to call ourselves “Software Engineers” or “Software Architects”, but to do that you first have to master a number of design patterns.

This course will put you on a track to that destination.

We will teach you how to recognize when to use specific design patterns to build complex systems in a divide-and-conquer manner so that complexity is reduced and abstracted.

But rather than learning all the design patterns out there, we have curated the most important, the top fundamental GoF Design Patterns for you.

All of that in the context of the Object Oriented Python.

We start with full understanding of the S.O.L.I.D Design Principles and how they in turn relate to those design patterns. We explain everything in the context of real-world problems as well as specific code examples.

if you need a Python OOP Refresher, we have that for you. everything from classes to interfaces and abstract classes is covered. We will also show you how to code using pygame (Python Game Platform.)

At the end of the course you will get to Architect a solution by coding John Conway’s Game of Life simulation which will run on your mobile device.

Complex software systems are plagued with three major issues:

  1. Timelines are stretched as requirements change.

  2. Multiple developers have a hard time coordinating their efforts.

  3. Code redundancy.

This in turn creates issues with maintenance and overall flexibility for adding new features. In general this means poorly designed systems that are hard to maintain and are not adaptable.

One answer to all the above problems is having a proper design and architecture. Think of a skyscraper being built. There is always a high-level blueprint. This blueprint is used to show everybody involved (from architects to supply chain to construction workers to machinery scheduling etc…) what is being worked on.

That way, everybody understands and follows the same vision.

A blueprint has a number of commonly understood elements which repeat themselves across many projects. For example all buildings need electrical wiring and plumbing, they might need elevators, and cooling systems, and underground parking lots, and of course stairs. They also usually are connected to the electrical grid and water supply as well as… roads.

All these common elements follow certain standards that have been improved over many many years and across many many projects. They are well understood and can be used almost like recipes.

In Software Engineering we also have a set of elements that repeat themselves across many projects. For example all software applications need to create objects, they need to communicate state change across those objects, they need to be able traverse over collections of those objects. In other words, if you want to be a better developer then you need to become proficient in those elements that have been time-tested. In the Software Engineering world these elements are known as “Design Patterns”

This course will teach students how to recognize when to use specific design patterns to build complex systems in a divide-and-conquer manner so that complexity is reduced and abstracted.

This will help you to design projects in an Architectural manner before any major development happens and can be used to shorten development time and reduce maintenance costs.

Design patterns are important because they are time-tested recipes or solutions to well-known software engineering problems. When creating software applications certain problems recur in a pretty predictable fashion so rather than ‘reinvent’ the wheel we will have an assortment of, if you will, wheels to choose from.

We will teach you this in a slightly different manner than you probably have been taught before. We will take a practical approach (i.e. specific examples) but the power of Design Patterns comes from their ‘concept’ and we will teach you the concept of those design patterns so that you are fully able to change them and modify them to your needs. In addition we will look at how to combine all those patterns into something greater: an architecture.

A well designed Architecture is this magical thing where the whole is greater than the sum of its parts.

This is what we will strive to teach you.

Introduction

1
What are Design Patterns and why do we need them?

In this lecture you will learn as to WHAT design patterns are, and why we would need them.

Design patterns are a crucial tool in the toolkit of a Software Engineer and we explore here why you need to become familiar with them.

2
The Design Patterns Covered in This course.

In this lecture we will present to you the specific design patterns that we will cover in this course.

These are, in our mind, the most important and fundamental of all design patterns and we will go over them in depth in subsequent lectures.

3
Quick Quiz about design pattern families

We will test here your understanding of general aspects of design patterns

4
The WHY Of Software Architecture.

Who needs Software Architecture?
Why do we care about well designed and maintainable software? And how do we achieve SOLID Architecture? This lecture will show you why.

5
Why use UML?

In this lecture we will show you why UML is very useful when working with design patterns and Software Architectures in general.

6
Organized vs. Unorganized code.

Final piece of the coding-well puzzle will be explored. We will appeal to you in a visual way as to why having good and organized code matters.

7
Setting Up the IDE and Python Environment

In this lecture I will show you how to setup the VS IDE environment to run the code samples in this course.

8
*OPTIONAL*: UML Refresher.

This is an optional lecture that you can skip if you are very comfortable with UML diagrams. In case you want a quick and gentle refresher then by all means dive in! We will do a quick overview of Class and Sequence diagrams.

Python OOP *Refresher*

1
Python OOP Refresher - Theory Part #1

In this first part we will briefly go over how we will leverage Python's Object Oriented Capabilities.


We will cover classes, and interface contracts (i.e. abstract classes) as well as how this will relate to the UML diagrams you will see in this course.

2
Python OOP Refresher - Theory Part #2

In this second part we will continue to go over how we will leverage Python's Object Oriented Capabilities.


We will cover classes, and interface contracts (i.e. abstract classes) as well as how this will relate to the UML diagrams you will see in this course.

3
Python OOP Refresher - Code Studies Part #1

In this example we will look at syntax for simple python class.


NOTE: The Source code for all the Code Studies has been attached here.

Each study is named "python_oop_NNN.py" where NNN is the number of the study.
For example "python_oop_001.py" would be the source code for Code Studies Part #1

4
Python OOP Refresher - Code Studies Part #2

In this example we will look at class and object aggregation example. This is how you build complex classes by using simple class building blocks.

5
Working with a Simple Class in Python
6
Working with Class Aggregation
7
Python OOP Refresher - Code Studies Part #3

Introduction to Abstract Classes in Python.

8
Working with Abstract Classes
9
Python OOP Refresher - Code Studies Part #4

Looking at an example of encapsulation and private as well as protected class variables.

10
Working with Class Encapsulation
11
Python OOP Refresher - Code Studies Part #5

Interface contracts in Python. First look.

12
Python OOP Refresher - Code Studies Part #6

More complex Interface contracts in Python. This shows you how you can enforce API utilization of a specific interface through method signatures.

13
Python OOP Refresher - Code Studies Part #7

Tying everything together into a more complex Abstract Class example that has both interface contract behaviour as well as re-use logic.

14
Working with Interface Contracts Exercise#1
15
Working with Interface Contracts Exercise#2

What makes a Great Architecture?

1
Hallmarks of Good Architecture.

How can you tell what a good Architecture is? What are the main features of a great Architecture? In this lesson we will explore the hallmarks of a great architecture are and how to spot them.

2
S.O.L.I.D Design Principles.

This is a very important topic. The S.O.L.I.D design principles form  the backbone of what a great architecture should have at its base approach. In this lecture we explore these principles in preparation for when we go over the design patterns of this course.

3
SOLID *Practice Session* - Single Responsibility Principle(SRP)

This is a quick hands-on practice session where you will get a chance to exercise your SOLID knowledge by refactoring a bad solution into a good solution as per SOLID principles.

In this session we go over Single Responsibility Principle(SRP)

4
SOLID *Practice Session* - Open/Closed Principle(OCP)

This is a quick hands-on practice sessions where you will get a chance to exercise your SOLID knowledge by refactoring a bad solution into a good solution as per SOLID principles.

In this session we go over Open/Closed Principle(OCP)

5
SOLID *Practice Session* - Liskov Substitution Principle (LSP)

This is a quick hands-on practice sessions where you will get a chance to exercise your SOLID knowledge by refactoring a bad solution into a good solution as per SOLID principles.

In this session we go over Liskov Substitution Principle (LSP)

6
SOLID *Practice Session* - Interface Separation Principle (ISP)

This is a quick hands-on practice sessions where you will get a chance to exercise your SOLID knowledge by refactoring a bad solution into a good solution as per SOLID principles.



In this session we go over interface Separation Principle (ISP)

7
SOLID *Practice Session* - Dependency Inversion Principle (DIP)

This is a quick hands-on practice sessions where you will get a chance to exercise your SOLID knowledge by refactoring a bad solution into a good solution as per SOLID principles.

In this session we go over Dependency Inversion Principle (DIP)

NOTE:
Once you are done with this lecture we have provided you with a PDF of SOLID exercises for you to try on your own. The PDF is attached with this lecture.

8
SOLID Principles Quiz

In this quiz we will test your knowledge of the SOLID Principles

Singleton Design Pattern

1
Understanding the Singleton Pattern

We introduce the Singleton Design Pattern and discuss its importance and relevance in Software Engineering. In this lesson you will learn what it is and why we need it.
It is a creational design pattern that helps us with ensuring that we have at most a single copy of a given class instance in the whole project scope. You will find out why that is relevant.

2
Singleton Pattern - Architectural Considerations Part#1 - Simple Approach

In this first part, we further explore the Singleton Pattern and look into the architectural nature of this software recipe through the UML lens.
We explore the simplest implementations and some Python language quirks that come along when you try to implement such a design pattern

3
Singleton Pattern - Architectural Considerations Part#2 - Using Metaclasses

In this second part, we will look into the best way to achieve a Singleton in Python: using a metaclass. We also look into the idea behind implementing eager loading in our singletons vs the more usual lazy instantiation we have seen so far.

4
Singleton Pattern - Architectural Considerations Part#3 - Thread-Safety

In this, third Architecture lecture, we will look at the underlying issues with thread-safety and the Singleton Design pattern. We will then look at the implementation of a working solution.

5
Singleton Quiz
6
Coding Part#1 - Implementing Singleton Pattern in Python

Let's code something using the Singleton Pattern.

In this lesson we will explore how to code this pattern in Python using a few different language constructs that also can help us to ensure thread-safety. We also look at how to create a Singleton Logger wrapper in Python for a practical example of this software recipe.


NOTE: Attached you will find the zipped source code for this lecture.

7
Coding Part#2 - Practical Examples of Singleton In Python

Let's code something practical using the Singleton Pattern.

In this lecture we will look at 4 different iterations of a custom Logger class which we will explore as a Singleton.

We will start with a simple example, and then go through different phases of making our Logger a thread-safe Singleton that is customizable and flexible through an abstract class concept.

NOTE: attached you will find the zipped source code for this lecture.

8
Working with the Singleton Pattern
9
Singleton Pattern Coding **Extra** Exercises

This is an optional exercise for the student to do. It is important to practice and try things out.

This will cover two scenarios to use a Singleton Pattern in.

Factory Method Design Pattern

1
Understanding Factory Method Pattern

We introduce the Factory Method Design Pattern and discuss its importance and relevance in Software Engineering.
In this lesson you will learn what it is and why we need it. It is a creational design pattern that makes the process of object creation more maintainable.

2
Architectural Considerations for Factory Method Pattern

We further explore the Factory Method Pattern and look into the architectural nature of this software recipe through the UML lens.

3
Coding the Factory Method Pattern in Python

Let's code something using the Factory Method Pattern. In this lesson we will explore how to code this pattern in Python. We have a fun little application which draws random shapes on the screen by utilizing the Factory Method Pattern and a custom Python Painter.


NOTE: attached you will find the zipped source code for this lecture.

4
Working with the Factory Method Pattern Exercise #1
5
Working with the Factory Method Pattern Exercise #2
6
Factory Method Pattern Quiz

This will test some of your knowledge about the Factory Method Pattern concept.

7
Factory Method Pattern Coding **Extra** Exercises

This is an optional exercise for the student to do. It is important to practice and try things out. This will cover two scenarios to use a Factory Method Design Pattern in.

Builder Design Pattern

1
Understanding Builder Design Pattern

We introduce the Builder Design Pattern and discuss its importance and relevance in Software Engineering. In this lesson you will learn what it is and why we need it. It is a creational design pattern that makes the process of complex object creation more maintainable and decoupled from the client.

2
Architectural Considerations for Builder Design Pattern

We further explore the Builder Pattern and look into the architectural nature of this software recipe through the UML lens.

3
Coding the Builder Pattern in Python

Let's code something using the Builder Pattern. It's time for some some sandwiches! In this lesson we will explore how to code this pattern in Python. We are going to create a Builder abstraction that will be responsible for creating different types of Sandwiches.

NOTE: attached you will find the zipped source code for this lecture.

4
Working with the Builder Pattern Exercise
5
Builder Pattern Quiz

This will test some of your knowledge about the Build Design Pattern concept.

6
Builder Design Pattern Coding **Extra** Exercises

This is an optional exercise for the student to do. It is important to practice and try things out. This will cover two scenarios to use a Builder Design Pattern in.

Adapter Design Pattern

1
Understanding the Adapter Design Pattern

We introduce the Adapter Design Pattern and discuss its importance and relevance in Software Engineering. In this lesson you will learn what it is and why we need it. It is a structural design pattern that allows two different processes to talk to each other even though their view of data is not compatible.

2
Architectural Considerations for the Adapter Pattern

We further explore the Adapter Pattern and look into the architectural nature of this software recipe through the UML lens.

3
Coding the Adapter Pattern In Python

Let's code something using the Adapter Pattern. In this lesson we will explore how to code this pattern in Python. We are going to create an Adapter for some XML and JSON data conversion!

As part of your Adapter pattern Exercise you will add a CSV Adapter to the featured code.

NOTE: attached you will find the zipped source code for this lecture.

4
Working with the Adapter Pattern Exercise
5
Adapter Pattern Quiz

This will test some of your knowledge about the Adapter Design Pattern concept.

6
Adapter Design Pattern Coding **Extra** Exercises

This is an optional exercise for the student to do. It is important to practice and try things out. This will cover two scenarios to use a Adapter Design Pattern in.

Strategy Design Pattern

1
Understanding the Strategy Design Pattern

In this section will will introduce this incredibly simple yet powerful design pattern. This is probably the most popular and useful of all the design patterns in the whole of GoF collection.

2
Architectural Consideration for the Strategy Design Pattern

We further explore the Strategy Pattern and look into the architectural nature of this software recipe through the UML lens.

3
Coding the Strategy Design Pattern

Let's code something using the Strategy Pattern. In this lesson we will explore how to code this pattern in Python. We are going to look at how to create different handlers for rendering objects to the screen.


NOTE: The source code for this lecture is attached with this video.

4
Working with the Strategy Pattern Exercise #1
5
Working with the Strategy Pattern Exercise #2
6
Strategy Pattern Quiz

This will test some of your knowledge about the Strategy Design Pattern concepts.

7
Strategy Design Pattern Coding **Extra** Exercise

This is an optional exercise for the student to do. It is important to practice and try things out. This will cover two scenarios to use a Strategy Design Pattern in.


It is recommended that you perhaps draw a UML sketch of the code (provided below) so that you can visually refactor it first.


NOTE:
The code for Exercise #1 is attached below: shipping.py
The code for Exercise #2 is attached below in text_processing.py

Observer Design Pattern

1
Understanding the Observer Design Pattern

In this section we will explore the Observer Design Pattern with its very important role in inter-object communications.
Such aspects as notifications about specific events,  and in general signalling about action workflows is what this pattern excels at.

2
Architectural Consideration for the Observer Design Pattern

Here we will look at more detail about the Architectural make up of this pattern. We will look at UML as well as general workflow of what makes this pattern great. 

3
Coding with the Observer Pattern

In this lecture we will look at some fun code to showcase how the Observer pattern is useful in a object communication workflow.

NOTE: The source code for this lecture is attached with this video.

4
Working with the Observer Pattern Exercise
5
Observer Design Pattern Coding **Extra** Exercises

This is an optional exercise for the student to do. It is important to practice and try things out.

This will cover two exercises for you to practice the Observer Design Pattern with.


It is recommended that you perhaps draw a UML sketch of the class hierarchies so that you can easily visualize the Observer Design Pattern.

State Design Pattern

1
Understanding the State Design Pattern

We will go over the concept of what a State and a State Machine is. We will understand how to break down states and associated data into a set of discrete steps that make up a State Machine.

2
Architectural Consideration for the State Design Pattern

We further explore the State Pattern and look into the architectural nature of this software recipe through the UML lens and get a better understanding of h ow to design a State Machine.

3
Coding the State Design Pattern

Let's code something using the State Design Pattern. In this lesson we will explore how to code this pattern in Python. We are going to look at how to create controller process for good old traffic lights. We will design and code the state machine for a traffic light.

NOTE: The source code for this lecture is attached with this video.

4
Working with the State Design Pattern Exercise
5
State Design Pattern Coding **Extra** Exercises

This is an optional exercise for the student to do. It is important to practice and try things out. This will cover two scenarios to use the State Design Pattern in.

NOTE:
The code for Exercise #1 is attached below: state_design_pattern_exercise_001.py
The code for Exercise #2 is attached below in state_design_pattern_exercise_002.py

Course Assignment - The Game of Life

1
About John Conway's Game Of Life Simulation

In this lecture we will look into the course assignment.


You will see what 'Game of Life' is all about. This is a famous and classic life simulation that is a staple of colleges and universities in their Computer Science programs for its curious 'emergent' behaviour.


You will design, architect and code this application for your mobile device. All of it using the design patterns you have learned in this course.

I have provided you with a working starter code which has all the logic for the game of life but is not architected well. Your task will be to take the code and refactor it so that it is well architected and follows all the SOLID principles as well as uses some of the Design Patterns we learned in the course.


NOTE: The source starter code for this lecture is attached with this video.

2
A Word about the "Game of Life" Architecture

A helping hand with the architecture and general 'design' approach for your assignment.

Final Thoughts

1
Where do you go from here?

Some final thoughts about what you could do next after this course.

2
Thank you!

Thank you for being part of this course. We hope to see you again! Good luck with everything!

You can view and review the lecture materials indefinitely, like an on-demand channel.
Definitely! If you have an internet connection, courses on Udemy are available on any device at any time. If you don't have an internet connection, some instructors also let their students download course lectures. That's up to the instructor though, so make sure you get on their good side!
4.7
4.7 out of 5
86 Ratings

Detailed Rating

Stars 5
63
Stars 4
20
Stars 3
4
Stars 2
0
Stars 1
0