Udemy
    •  
    •  
    •  
    •  
    •  
    •  
    •  
    •  
Turn what you know into an opportunity and reach millions around the world.
Learn More
Your cart is empty.
Keep shopping
Design Patterns in Python
Rating: 4.2 out of 5(233 ratings)
1,870 students

Design Patterns in Python

Implement and Learn All 23 GoF (Gang of Four) Design Patterns In Python.
Created bySean Bradley
Last updated 10/2022
English

What you'll learn

  • Design Patterns in Python
  • Learn All 23 GoF Design Patterns
  • Creational Patterns : Factory, Abstract Factory, Builder, Prototype, Singleton
  • Structural Patterns : Decorator, Adapter, Facade, Bridge, Composite, Flyweight, Proxy
  • Behavioral Patterns : Command, Chain of Responsibility, Observer, Interpreter, Iterator, Mediator, Memento, State, Strategy, Template, Visitor
  • Learn Many Python Concepts : ABCMeta, Exception Handling, Lists, Dictionaries, Tuples, Sets, id, Dunder Attributes and Methods, Time, Decimal, *Args and more.
  • Learn Quality Software Design Standards using Pep8, Pylint and MyPy
  • UML Diagramming : Inherits, Implements, Composition, Aggregates, Association
  • Learn Each Pattern from Conceptual and Use Case Points of View
  • Develop Your Software Engineering Vocabulary

Course content

5 sections78 lectures5h 2m total length
  • Environment Setup6:07

    The most universal approach to installing Python is to visit the official Python download page at,

    https://www.python.org/downloads/

    Normally this page will detect your operating system from the user agent in your browser and select which install is appropriate for you.

    There will be 64 and 32 bit versions for your operating system. At the time of writing this documentation, the option of downloading the 64bit version was the most common, and the version was 3.11.0.

    The code in this documentation will be using a simplified generic style of Python that should work in all versions since Python version 3.

    To test if you already have python on your system, depending on your operating system, whether Windows, Linux or Mac OSX, open a terminal/bash/cmd or PowerShell prompt.

    and type

    $ python -V


    Note the capital V in the above command.

    Sometimes python is named as python3

    So you can also try

    $ python3 -V


    You are looking for a response that indicates you have Python 3 or above installed. Not an error, or Python 2.x

    On my windows workstation, if I use PowerShell, the response is

    PS> python -V

    Python 3.11.0


    I have Python3 already installed using the official python link from above.

    If you are using a recent version of Linux or Mac OSX, then the command to check for the Python version on your system is most likely to be,

    $ python3 -V


    Remember to follow the official install instructions for your operating system at https://www.python.org/downloads/

  • Coding Conventions7:58

    Python Interactive Console Versus *.py Scripts

    You can execute Python code by writing your scripts into text files and commonly using the .py extension. Text files on most operating systems will be UTF-8 encoded by default. Python also reads UTF-8 encoded text files by default.

    Create a new text file called example.py and add the following text.

    print("Hello World!")


    and then you can execute it using python or python3 depending on your operating system and Python version.

    PS> python ./example.py

    Hello World!


    You can also enter Python code directly into the Python Interactive Console by typing just python or python3 from the command line and then press Enter . You then get a prompt like below.

    PS> python

    Python 3.11.0 (main, Oct 24 2022, 18:26:48) [MSC v.1933 64 bit (AMD64)] on win32

    Type "help", "copyright", "credits" or "license" for more information.

    >>>


    You can now enter python commands directly.

    >>> print("Hello World!")

    Hello World!

    >>>


    To exit the Python Interactive Console, you can usually type quit() or press Ctrl-Z then press Enter

    This documentation will show examples of using both *.py scripts and the interactive console to execute Python. Look out for the >>> characters in the code blocks to indicate if I was using the Python Interactive Console or a *.py script.


    PEP8

    The code styling in this documentation is formatted using mostly PEP8 styling recommendations.

    • UPPER_CASE : Constants will be defined using UPPER_CASE naming style.

    • PascalCase : Class names will use PascalCase naming style

    • snake_case : For variables names, method names and method arguments.

    • Docstrings : Classes and methods contain extra documentation that is descriptive text enclosed in " or """ for multiline strings.

    • _leading_underscore : Use a leading underscore to indicate variables that should be considered as private class variables.

    See PEP-0008 : https://www.python.org/dev/peps/pep-0008/


    Pylint

    I use the Pylint tool to check for code styling recommendations.

    On most operating systems you would generally install Pylint by using the PIP or PIP3 installer.

    PS> pip install pylint


    If using VSCode, open the Command Palette (Ctrl+Shift+P), then set the

    Python: Enable Linting to on

    and

    Python: Select Linter to Pylint

  • UML Diagrams6:24

    Unified Modeling Language (UML) Diagrams are used throughout this course to help describe the patterns.

    • Directed Association : A filled arrow with a line.

    • Extends/Inherits : An unfilled arrow, with a line pointing to the class that is being extended/inherited.

    • Implements : An unfilled arrow, with a dashed line pointing to the interface that is being implemented.

    • Aggregates : An unfilled diamond with a line and arrow head.

    • Composition : A filled diamond with a line and arrow head.

    • Pseudocode Annotation : A box with a dashed line and a circle placed near a class method.

Requirements

  • An OS such as Windows 11, Mac OSX or Linux
  • An IDE such as VSCode, PyCharm Community, Vim, Notepad or Just the command line.
  • A Desire to Understand the 23 Gof Design Patterns

Description

Learn All of the 23 GoF (Gang of Four) Design Patterns and Implemented them in Python.

Design Patterns are descriptions or templates that can be repeatedly applied to commonly recurring problems during in software design.

A familiarity of Design Patterns is very useful when planning, discussing, managing and documenting your applications from now and into the future.

Also, throughout the course, as each design pattern is discussed and demonstrated using example code, I introduce new Python coding concepts along with each new design pattern. So that as you progress through the course and try out the examples, you will also get experience and familiarity with some of the finer details of the Python programming language.

In this course, you will learn about these 23 Design Patterns, 

  • Creational

    • Factory

    • Abstract Factory

    • Builder

    • Prototype

    • Singleton

  • Structural

    • Decorator

    • Adapter

    • Facade

    • Bridge

    • Composite

    • Flyweight

    • Proxy

  • Behavioral

    • Command

    • Chain of Responsibility

    • Observer Pattern

    • Interpreter

    • Iterator

    • Mediator

    • Memento

    • State

    • Strategy

    • Template

    • Visitor

In the list of patterns above, there are Creational, Structural and Behavioral patterns.

  • Creational : Abstracts the instantiation process so that there is a logical separation between how objects are composed and finally represented.

  • Structural : Focuses more on how classes and objects are composed using the different structural techniques, and to form structures with more or altered flexibility.

  • Behavioral : Are concerned with the inner algorithms, process flow, the assignment of responsibilities and the intercommunication between objects.

Design patterns will give you a useful and common vocabulary for when designing, documenting, analyzing, restructuring new and existing software development projects from now and into the future.

I look forward to having you take part in my course.

Sean Bradley

Who this course is for:

  • Python Developers
  • Software Architects
  • Software Engineers