
Learn to refactor growing Python code using object oriented programming, turning scripts into modular software with dependency injection, polymorphism, and composition for beginner to intermediate developers.
Explore object oriented programming in Python by building a pirate loot sharing system. Organize Python code and apply object oriented programming concepts as Sam tackles the challenge.
Apply inheritance, composition, and polymorphism to distribute 480 ducats by pirate rank, using a sum of ranks loop for fair shares in the first version of pirate payroll.
Represent each pirate as a (name, rank) tuple to reduce fragile code when the crew changes. Use a generator expression and sum to compute shares and verify the 100-ducat total.
Sam updates the pirate payroll using tuples and f-string rounding to two decimals, then adopts a class to enforce rank and role data under the pirate union rules.
Learn how to model data with classes and objects in Python, using a pirate example to show defining a class, the __init__ initializer, and accessing attributes with dot notation.
Learn how UML class diagrams document and communicate software design, showing class name, attributes with data types, and initializers; use inheritance for pirate types in upcoming chapters.
Explore inheritance in python by refactoring a pirate registry: convert specialized titles and ranks into subclasses that inherit a base pirate class, removing duplicated code and hardcoded values.
Explore refactoring to improve structure by extracting classes into modules, creating a data module and a dataloader, and applying the single responsibility principle to simplify dependencies.
Refactor and extend a Python object‑oriented program by adding an extra officer and cannon operator, update two modules, and accommodate dynamic crew and loot changes.
Explore importing JSON in Python by building a plug-in data loader system that uses polymorphism to switch data sources while honoring the open-closed principle.
Add cook and deck scrubber classes to the pirates module and update the Json data loader to use these subclasses, while highlighting open-closed principle and single responsibility.
Discover how composition replaces inheritance by modeling pirates with a separate role class that stores title and rank, enabling flexible pirate types without new subclasses.
Repurpose the old data loader as a test data loader with hard coded data, enabling reliable tests and switching between json and test loaders via a shared interface and polymorphism.
Explore single responsibility design by refactoring a payroll module that calculates pirate shares and returns structured share objects, using payroll and share classes, with aggregation and composition in UML.
Develop a mission module in Python to model crew, loot, and captured ducats using test data and a data loader, and print mission info with a dunder string.
Learn how to load missions from json using a data loader, compare pirates and missions with list comprehension, and apply polymorphism across data sources, then update dependency and uml diagrams.
Update the Python object-oriented programming project to load real currency data from currencies.json, build loot item objects with dictionary comprehension, and test conversions with updated exchange rates.
Explore applying the open-closed principle in Python by updating json data for missions and currencies without changing code, enabling pirate payroll and dynamic rewards.
Explore how inheritance, polymorphism, and composition drive flexible object‑oriented design in Python, with a practical end-to-end exercise and guidance on next steps.
Explore the mechanics of object oriented programming in Python, focusing on classes, objects, and adding types and interfaces to improve your code.
This course teaches you how to take a single script and use OOP techniques to refactor it into modules in a playful way. You learn Inheritance, Composition and Polymorphism and use UML to design and communicate the system. The customer keeps requesting new features that forces you to think about the right tool in the right place. Will OOP allow you to refactor the code each time without risk of breaking things? Prepare for a big exercise in organizing code!
Target audience
Developers who especially benefit from this course, are:
beginner programmers who want to practice OOP basics
developers who want to learn how to turn small scripts into logical code modules
developers who want to learn how to refactor code with minimal change and risk
Challenges
Students that are interested in this course often know basic Python features but are not yet aware of the role of OOP in structuring your code. Perhaps they have seen classes, objects, inheritance and polymorphism but they don’t know where and when to apply these techniques. This can lead to the wrong technique in the wrong place, which makes OOP useless and inefficient. Because this course focuses on changing code, you learn WHEN, WHAT and more important, WHY you can apply a certain OOP technique and perhaps even more interesting, when a certain technique is NOT appropriate anymore and needs to be replaced with another one.
What can you do after this course?
improve existing and future code by effectively refactoring code into small modules
decouple your modules by using dependency injection
make modules into plugins by using Polymorphism
solve open-closed principle violations by using composition
communicate your designs with UML class diagrams
Topics
Classes and Objects: Class instantiation, self, data attributes, UML, methods
Inheritance: When to use and not use Inheritance
UML: Use UML class diagrams to design and communicate your system
Polymorphism: Open-closed principle, prevent switches (if/else)
Composition: Replace inheritance with composition
Refactoring: Split up scripts and make a system modular to achieve single responsibility
JSON: Load data from a JSON file
Generator expressions and List comprehensions: Convert JSON data to object efficiently
Duration
1,5 hours video time, 3 hours including practicing exercises.
The teacher
This course is taught by Loek van den Ouweland, a senior software engineer with 25 years of professional experience. Loek is the creator of Wunderlist for windows, Microsoft To-do and Mahjong for Windows and loves to teach software engineering.