New Course: Object Oriented Programming Theory with Python

A practical two day course on the object oriented features of Python. Perfect for programmers with some experience of Python looking to use objects and classes and to understand them. An excellent course for data scientists, devops engineers and those self taught with Python looking to move beyond scripting into programming.

Course Contents

Fundamentals: Classes and methods

  • Computer architecture and programming languages
  • Python as a high-level, object-oriented language
  • Objects as abstractions, for thinking
  • The class statement
  • The explicit self
  • The initialiser method __init__
  • Bound methods
  • Attributes and the built-in attribute access functions
  • References and assignment (how Python works)
  • Mutable objects (and call by object)
  • Object copying

Object Oriented Features

  • Class attributes
  • Class methods
  • Properties
  • Private attributes
  • Single inheritance
  • Inheritance to extend and modify the parent
  • The use of super
  • Cooperative multiple inheritance
  • Mixin Classes
  • Attribute lookup and the method resolution order
  • The type system: isinstance and issubclass

Inside Python Objects

  • The instance dictionary
  • Slots
  • Class dictionaries
  • The descriptor protocol

Python Protocols

  • Magic methods and Python protocols
  • Operator overloading
  • The string representation protocol
  • The container protocols
  • Implementing custom containers
  • Inheriting from collections.abc.MutableSequence

Alternative Approaches

  • namedtuples
  • dataclasses
  • type as a class factory

Object oriented theory:

  • History of Object Oriented Programming
  • The pillars of OOP
  • Abstraction
  • Inheritance
  • Encapsulation
  • Polymorphism
  • Object oriented design principles
  • Design patterns
  • The Liskov Substitution Principle
  • Composition versus inheritance

Optional advanced section (third day):

  1. Advanced OOP Concepts

    • Interfaces and API design
    • Abstract base classes and protocols
    • Type hints and static typing with mypy
    • Class decorators
    • Decoration via inheritance with __init_sublass__
    • Metaclasses
    • Context managers and the with statement
    • Weak references and destructors
    • The descriptor protocol
  2. OOP Design Principles

    • SOLID principles
    • Law of Demeter
    • Liskov Substitution Principle
    • Composition vs inheritance
    • Domain Driven Design
    • Test Driven Development
    • Stop writing classes
    • The hexagon pattern (microservices)
    • The C4 Model for system architecture
Written on December 18, 2024