Skip to content
0:00 / 0:00

#polymorphism#python#cleancode

Talk: Aly Sivji - If Statements are a Code Smell

PyCon US

34K subscribers • 26 videos on Hallway • Conference channel

YouTube
  • One of the most-watched uploads on PyCon US, a conference or university channel Hallway lists. Nobody has recommended it in the communities yet, so it ranks below community picks.
  • Presented by Aly Sivji
  • Linked in the descriptionalysivji/talks
  • An opinion. It argues one side of a question engineers disagree on.

Intermediate. Assumes working knowledge.

13K views6 years ago

Software designRefactoring and legacy codeDesign patternsObject-oriented design

Aly Sivji demonstrates how to refactor complex conditional logic and duplicate if statements into polymorphic Python classes.

Presented by: Aly Sivji if statements are elements of a programming language that allow us to control what statements are executed. By chaining together a series of if statements, we can solve any problem we can think of. But code with too many if statements is hard to read and even harder to change. Workarounds that once allowed us to move fast, now get in the way when we go in to make modifications. It doesn’t have to be this way! This talk demonstrates HOWTO handle complex conditional logic with simple Python classes. The material will be presented in the context of a code refactor for an open-source project: we examine the initial solution featuring duplicate if statements, show how hard it is to make a change, and walk through the process of refactoring if blocks into polymorphic classes. The case study has been simplified to illustrate concepts you can apply to your own code. After this talk, you will be able to identify situations where an object-oriented solution can be used to improve software design. You will also be exposed to tradeoffs we need to think about before refactoring to higher-level abstractions. Talk slides: bit.ly/code-smell-if-statements Talk resources:: github.com/alysivji/talks/

Why it's here

A top upload from a listed channel

PyCon US is on Hallway's list of conference and university channels, and this upload is one of its most-watched talks or lectures. Nobody has recommended it in the communities yet, so it ranks below community picks.