Audience
This course is relevant for anyone wishing to gain knowledge in SOLID Python Development.
Prerequisites
Attendees should already be comfortable with Python programming.
Duration
3 days. Hands on.
Course Objectives
Python is one of the most popular programming languages on the planet at the moment. At the heart of its appeal is its simple syntax and rich set of libraries.
It’s quite easy to write Python code, but it’s much harder to write high-quality Python code. How should you structure your code? How can you design for change, extensibility, consistency, and pluggability? How can you manage dependencies in a large code-base, so that your code is modular, stable, and manageable? How can you verify behaviour and type-safety?
This course shows how you can apply the “SOLID” principles to achieve all these goals.
- Achieving type safety in Python via Python typing
- Using object orientation effectively
- Understanding and applying the Single Responsibility Principle (SRP)
- Understanding and applying the Open/Closed Principle (OCP)
- Understanding and applying the Liskov Substitution Principle (LSP)
- Understanding and applying the Interface Segregation Principle (ISP)
- Understanding and applying the Dependency Inversion Principle (DIP)
- Test automation
- Using Pydantic to implement model validation
Course Content
Python Typing
The need for python typing
Defining and verifying python types
What types are available
Typing Techniques
Object Oriented Programming
Essential concepts
Defining and Using a class
Class-Wide Members
The Single Responsibility Principle (SRP)
Understanding the SRP
Functional example of SRP
OO example of SRP
The Open/Closed Principle (OCP)
Understanding the OCP
Achieving the OCP via inheritance
Defining abstract classes/methods
Multiple inheritance
Understanding method resolution order
The Liskov Substitution Principle (LSP)
Understanding the LSP
Using the LSP
Polymorphism
The Interface Segregation Principle (ISP)
Setting the scene
interfaces with python
Interfaces and the ISP
The Dependency Inversion Principle (DIP)
Setting the scene
Dependency injection
Managing dependencies with the DIP
Test Automation
Getting started with testing
Using PyHamcrest matchers
Mocking
Additional testing techniques
Using Pydantic
Setting the scene
Specifying simple validation rules
Specifying complex validation rules