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:
-
Timelines are stretched as requirements change.
-
Multiple developers have a hard time coordinating their efforts.
-
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
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.
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.
We will test here your understanding of general aspects of design patterns
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.
In this lecture we will show you why UML is very useful when working with design patterns and Software Architectures in general.
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.
In this lecture I will show you how to setup the VS IDE environment to run the code samples in this course.
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*
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.
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.
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
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.
Introduction to Abstract Classes in Python.
Looking at an example of encapsulation and private as well as protected class variables.
Interface contracts in Python. First look.
More complex Interface contracts in Python. This shows you how you can enforce API utilization of a specific interface through method signatures.
Tying everything together into a more complex Abstract Class example that has both interface contract behaviour as well as re-use logic.
What makes a Great 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.
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.
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)
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)
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)
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)
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.
In this quiz we will test your knowledge of the SOLID Principles
Singleton Design 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.
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
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.
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.
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.
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.
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
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.
We further explore the Factory Method Pattern and look into the architectural nature of this software recipe through the UML lens.
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.
This will test some of your knowledge about the Factory Method Pattern concept.
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
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.
We further explore the Builder Pattern and look into the architectural nature of this software recipe through the UML lens.
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.
This will test some of your knowledge about the Build Design Pattern concept.
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
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.
We further explore the Adapter Pattern and look into the architectural nature of this software recipe through the UML lens.
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.
This will test some of your knowledge about the Adapter Design Pattern concept.
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
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.
We further explore the Strategy Pattern and look into the architectural nature of this software recipe through the UML lens.
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.
This will test some of your knowledge about the Strategy Design Pattern concepts.
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
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.
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.
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.
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
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.
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.
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.
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
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.
A helping hand with the architecture and general 'design' approach for your assignment.
Final Thoughts
Some final thoughts about what you could do next after this course.
Thank you for being part of this course. We hope to see you again! Good luck with everything!