Advanced level · Module 1 of 6 · 24 guided hours
Object-Oriented Programming in Python
Model real-world entities with classes and choose between inheritance and composition sensibly.
Learning objectives
- Define classes with attributes and methods
- Apply inheritance and composition
- Use dataclasses and special methods for cleaner code
Topics
- classes, objects and methods
- encapsulation
- inheritance and super()
- composition
- dataclasses and __repr__/__eq__
Lessons
-
Lesson 1 Classes, Objects and Methods
Turn data and the functions that act on it into a single class.
class vs objectself__init__instance attribute
-
Lesson 2 Inheritance and Composition
Reuse behaviour by extending classes or by combining objects, and know when each fits.
inheritancesuper()method overridingcomposition
-
Lesson 3 Dataclasses and Special Methods
Write concise data-holding classes and make objects print and compare naturally.
@dataclasstype hints__repr__field defaults
-
Lesson 4 Designing Classes from Real Requirements
Turn a real-world process into a small set of well-designed classes before writing code.
domain modelresponsibilityrelationshipclass diagram
Practical activity
Model a small clinic's appointment system (patients, doctors, appointments) with classes and demonstrate booking, cancelling and listing appointments.
Expected outcomes
- Clear object models of real systems
- Judgement about when classes help and when functions suffice
Assessment
Design review of the class diagram plus a working demonstration.
Taught live by an instructor — online or in person. Free course lessons are for self-study and do not lead to a certificate — see registration options.