~/talk

If Statements are a Code Smell

Talkat PyOhio 2019 · 2019-07-27..07-28· [software-architecture]
slides:none on file

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

  1. 0:00Intro
  2. 1:16if statements are a code smell
  3. 4:44Boolean Variable / Function
  4. 5:16Code Smell #2: Nested ifs
  5. 6:02Guard Clause
  6. 6:33Code Smell 3: Duplicate ifs
  7. 7:18Case Study
  8. 7:38How do we generate a daily summary?
  9. 9:03Modifying MVP Adding Pull Requests to Summary
  10. 11:54Object-Oriented Programming (OOP)
  11. 12:39Object-Oriented Programming Principles
  12. 16:23Replace Conditional with Polymorphism
  13. 17:08Steps to Refactor Duplicate ifs
  14. 18:42Modifying Code: Adding New Issues to Summary
  15. 19:45Caveats
  16. 20:07Flat is better than nested
  17. 20:35Prefer Composition to Inheritance
  18. 21:39To Recap....
  19. 21:57Remember, ensure you need to refactor
~/search
type to search 6,249 conferences, 138,987 speakers and 185,172 talks
~/help
cmdctrl k
search every conference, speaker and series
/
focus the filter search
h
home
c
conferences
s
speakers
e
series
t
light / dark — the status bar button does the same
?
this help
esc
close this, then clear every filter — or just the search, while you are typing in it

Ignored while you are typing. Pages without a filter rail have no search to focus.