About the course
For experienced Python developers, moving beyond simply writing functional code to building software that is genuinely robust, maintainable, scalable, and easy to collaborate on is a critical step. This requires a deep understanding of software design principles and the adoption of disciplined development practices. This 4-day intensive training course is specifically designed to equip experienced Python developers with the knowledge and practical skills to master Test Driven Development (TDD) and effectively apply Software Design Patterns, demonstrating how these two powerful disciplines work together to produce higher-quality code.
The course begins by solidifying understanding of advanced Python Object-Oriented Programming features that form the bedrock for implementing design patterns, exploring concepts such as special methods, properties, descriptors, and intricate details of inheritance and composition. Participants will then dive into the core principles and workflow of Test Driven Development, focusing intensely on the Red-Green-Refactor cycle and the crucial skill of writing code that is inherently testable. A significant portion of the course is dedicated to hands-on mastery of the pytest framework, including advanced techniques for writing tests, using powerful fixtures for managing test setup and teardown, and effectively mocking external dependencies to isolate code for testing.
The central, integrated theme of the course is the practical application of TDD to implement a curated selection of key Design Patterns from the Creational, Structural, and Behavioral categories, chosen for their relevance in modern Python development. Participants will not just learn about these patterns but will actively build examples piece-by-piece using the TDD process, writing tests first to guide and validate the design. The course reinforces learning by covering essential refactoring techniques applied within the TDD cycle and explores how adopting TDD and Design Patterns supports the principles of SOLID design, empowering developers to consistently craft more resilient, understandable, and well-architected Python applications.
Instructor-led online and in-house face-to-face options are available - as part of a wider customised training programme, or as a standalone workshop, on-site at your offices or at one of many flexible meeting spaces in the UK and around the World.
-
- Apply advanced concepts of Python Object-Oriented Programming relevant to software design.
- Explain and consistently practice the core principles and workflow of Test Driven Development (TDD) using the Red-Green-Refactor cycle.
- Write effective automated tests using the pytest framework, including leveraging fixtures and mocking external dependencies.
- Understand the problems solved by and the structure of a selection of key Creational Design Patterns.
- Understand the problems solved by and the structure of a selection of key Structural Design Patterns, including mastering the Python Decorator pattern.
- Understand the problems solved by and the structure of a selection of key Behavioral Design Patterns.
- Implement selected Design Patterns using the TDD process, writing tests first to drive the design and implementation.
- Apply refactoring techniques effectively within the TDD cycle to continuously improve code design.
- Understand how TDD and Design Patterns relate to SOLID principles and contribute to building robust, maintainable software.
-
This 4-day intensive training course is designed for experienced Python developers who are looking to significantly enhance their software design capabilities, testing practices, and the overall quality and maintainability of the code they produce. It is ideal for:
Developers who want to adopt and master Test Driven Development as a core practice in their daily coding.
Developers seeking to understand and apply common Software Design Patterns to build more flexible, scalable, and understandable Python applications.
Development teams aiming to establish consistent standards for writing well-tested and well-designed Python code.
Experienced programmers from other languages transitioning to Python who want to learn Pythonic approaches to TDD and object-oriented design patterns.
-
Participants should have attended our intro to Python programming or have equivalent skills, including:
A solid and practical understanding of core Python programming concepts (including data types, control flow, functions, modules, error handling).
Practical experience writing and debugging Python code and building applications or significant scripts.
Familiarity with basic object-oriented programming concepts in Python (defining classes, creating objects, calling methods, basic inheritance).
This course is designed for developers already comfortable with writing Python code and looking to elevate their design and testing skills.
We can customise the training to match your team's experience and needs - with more time and coverage of OOP fundamentals for newer developers, for instance.
-
This Python TDD & Design Patterns course is available for private / custom delivery for your team - as an in-house face-to-face workshop at your location of choice, or as online instructor-led training via MS Teams (or your own preferred platform).
Get in touch to find out how we can deliver tailored training which focuses on your project requirements and learning goals.
-
Advanced Object-Oriented Programming in Python
Review of Classes, Objects, Methods, and Attributes.
Inheritance and Composition: When and why to use each.
Understanding Method Resolution Order (MRO) in Python.
Special Methods (The "dunder" methods - e.g., init, str, repr).
Class Methods (@classmethod) and Static Methods (@staticmethod).
Properties (@property) and Descriptors.
Abstract Base Classes (ABCs) and the abc module.
Hands-On Lab: Practicing advanced OOP concepts, including creating classes with special methods, class/static methods, properties, and using ABCs.
Principles and Practice of Test Driven Development (TDD)
What is TDD? Beyond just testing.
The Benefits of TDD (Improved design, reduced bugs, confidence in code).
The Red-Green-Refactor Cycle explained.
Writing Testable Code: Design considerations for TDD.
The qualities of a good test (FIRST principles).
Introduction to Test Doubles (Fakes, Stubs, Mocks, Spies).
Programming Katas: Practicing TDD in a structured way.
Hands-On Lab: Initial TDD exercises using simple problems (katas), focusing on the Red-Green-Refactor cycle.
Automated Testing with Pytest
Introduction to pytest: Why pytest? Comparison with unittest.
Installing pytest and running tests.
Writing Test Functions and Classes.
Assertions in pytest.
Organising tests.
Introduction to pytest Fixtures: Simple setup and teardown.
Using Markers (@pytest.mark).
Hands-On Lab: Converting previous kata exercises to use pytest, writing tests for existing simple functions, using basic fixtures.
More Pytest & Mocking
Advanced Fixture usage and scope.
Parametrizing tests with @pytest.mark.parametrize.
Introduction to Mocking in Python: The purpose of mocks in TDD.
Using unittest.mock (briefly) and pytest-mock (primary focus).
Mocking objects, methods, and functions.
Hands-On Lab: Writing more advanced tests using parametrized fixtures, practicing mocking external dependencies in tests using pytest-mock.
Creational Patterns with TDD - Part 1 (Factory Method, Abstract Factory)
Introduction to Creational Patterns: Dealing with object creation.
Factory Method Pattern:
Problem it solves.
Structure and participants.
Implementing Factory Method using TDD with pytest and mocking.
Abstract Factory Pattern:
Problem it solves.
Structure and participants.
Implementing Abstract Factory using TDD.
Hands-On Lab: Applying TDD to implement components that use the Factory Method and Abstract Factory patterns.
Creational Patterns with TDD - Part 2 (Singleton, Builder)
Singleton Pattern:
Problem it solves (ensuring a single instance).
Classic implementation approaches.
Pythonic alternatives (module-level singletons, using new).
Considerations and potential downsides in Python.
Implementing a Singleton (or Pythonic equivalent) using TDD.
Builder Pattern:
Problem it solves (constructing complex objects).
Structure and participants.
Implementing Builder using TDD.
Hands-On Lab: Applying TDD to implement a Singleton (or Pythonic approach) and the Builder pattern.
Structural Patterns with TDD - Part 1 (Adapter, Facade)
Introduction to Structural Patterns: Composing objects into larger structures.
Adapter Pattern:
Problem it solves (matching incompatible interfaces).
Object vs. Class Adapters.
Implementing Adapter using TDD.
Facade Pattern:
Problem it solves (providing a simplified interface to a complex subsystem).
Structure and participants.
Implementing Facade using TDD.
Hands-On Lab: Applying TDD to implement components using the Adapter and Facade patterns.
Structural Patterns with TDD - Part 2 (Composite, Proxy)
Composite Pattern:
Problem it solves (treating individual objects and compositions uniformly).
Structure and participants.
Implementing Composite using TDD.
Proxy Pattern:
Problem it solves (providing a surrogate or placeholder).
Types of Proxies (Virtual, Remote, Protection, Smart Reference).
Implementing Proxy using TDD.
Hands-On Lab: Applying TDD to implement components using the Composite and Proxy patterns.
Module 9: The Decorator Pattern
Decorator Pattern:
Problem it solves (adding responsibilities dynamically).
Structure and participants.
Functions as First-Class Objects in Python.
Closures.
Python's @ syntax for decorators.
Decorators with arguments.
Class Decorators.
Implementing custom function and class decorators using TDD.
Hands-On Lab: Applying TDD to implement custom decorators, practicing both the classic structure and Python's @ syntax.
Behavioral Design Patterns, Refactoring & Best Practices
Module 10: Behavioral Patterns with TDD - Part 1 (Strategy, Command)
Introduction to Behavioral Patterns: Algorithms and the assignment of responsibilities between objects.
Strategy Pattern:
Problem it solves (interchangeable algorithms).
Structure and participants.
Implementing Strategy using TDD.
Command Pattern:
Problem it solves (encapsulating a request as an object).
Structure and participants.
Implementing Command using TDD.
Hands-On Lab: Applying TDD to implement components using the Strategy and Command patterns.
Behavioral Patterns with TDD - Part 2 (Observer, Iterator, Template Method)
Observer Pattern:
Problem it solves (one-to-many dependency).
Structure and participants.
Implementing Observer using TDD.
Iterator Pattern:
Problem it solves (accessing elements sequentially).
Understanding Python Iterators and Iterables.
Generators and Generator Expressions.
Using the itertools module.
Implementing custom iterators/iterables with TDD.
Template Method Pattern:
Problem it solves (defining the skeleton of an algorithm).
Structure and participants.
Implementing Template Method using TDD.
Hands-On Lab: Applying TDD to implement components using the Observer, Iterator, and Template Method patterns.
Refactoring, Design Principles & Next Steps
Refactoring: Techniques for improving code design after tests are written.
How Design Patterns can Emerge through Refactoring.
SOLID Principles in Practice: How TDD and Design Patterns support SOLID.
Common Mistakes and Pitfalls in TDD.
Measuring Test Coverage.
Exploring other Design Patterns (brief overview of selected patterns not covered in detail).
Continuing Your Journey: Resources for TDD, Design Patterns, and Python development.
Hands-On Lab: Dedicated refactoring exercises on previously implemented pattern code, aiming to improve design while tests ensure correctness.
-
Pytest Documentation: The official and comprehensive guide for the pytest testing framework, including its features and plugins. https://docs.pytest.org/en/stable/
unittest.mock Documentation: Documentation for Python's built-in mocking library, which forms the basis for pytest-mock. https://docs.python.org/3/library/unittest.mock.html
Python Documentation: Official documentation for advanced Python language features, including Object-Oriented Programming concepts, special methods, and built-in modules like itertools. https://docs.python.org/3/
Trusted by



