Overview
Explore strategies for handling complex conditional logic using simple Python classes in this PyCon US talk. Learn to identify situations where object-oriented solutions can improve software design by examining a code refactor for an open-source project. Follow the process of transforming duplicate if statements into polymorphic classes, and understand the tradeoffs involved in refactoring to higher-level abstractions. Gain practical insights on applying object-oriented principles, polymorphism, and composition vs inheritance to enhance code readability and maintainability. Discover how to create base classes, driver classes, and implement new functionality while reducing the reliance on if statements.
Syllabus
Intro
What is an if statement
Generating summary text
Objectoriented programming
Objectoriented principles
Polymorphism Example
Python Example
How to Replace Conditionals
What is this bot trying to do
How we would refactor
Creating a base class
Creating a driver class
Adding new functionality
Creating a class
Refactoring
Composition vs Inheritance
Recap
Busy Beaver
Taught by
PyCon US