If Statements are a Code Smell
summary
Argues that heavy conditional logic becomes a maintenance burden and shows a concrete refactor: Python code that pulled GitHub events for the Busy Beaver Slack bot moves from nested if chains to polymorphic Event subclasses (Commit, RepoStar, PullRequest, Issues) plus a driver that classifies events and generates per-type summaries. Refactor reduces places to change (previously adding one event touched multiple functions and tests), preserves behavior, and leaves a single guard clause as the only remaining if.
AI-written summary · about
chapters (19)
- 0:00Intro
- 1:16if statements are a code smell
- 4:44Boolean Variable / Function
- 5:16Code Smell #2: Nested ifs
- 6:02Guard Clause
- 6:33Code Smell 3: Duplicate ifs
- 7:18Case Study
- 7:38How do we generate a daily summary?
- 9:03Modifying MVP Adding Pull Requests to Summary
- 11:54Object-Oriented Programming (OOP)
- 12:39Object-Oriented Programming Principles
- 16:23Replace Conditional with Polymorphism
- 17:08Steps to Refactor Duplicate ifs
- 18:42Modifying Code: Adding New Issues to Summary
- 19:45Caveats
- 20:07Flat is better than nested
- 20:35Prefer Composition to Inheritance
- 21:39To Recap....
- 21:57Remember, ensure you need to refactor








