Class Central is learner-supported. When you buy through links on our site, we may earn an affiliate commission.

YouTube

If Statements Are a Code Smell

PyCon US via YouTube

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

Reviews

Start your review of If Statements Are a Code Smell

Never Stop Learning.

Get personalized course recommendations, track subjects and courses with reminders, and more.

Someone learning on their laptop while sitting on the floor.