Skip to content
0:00 / 0:00

#cleancode#polymorphism#miskohevery

"The Clean Code Talks -- Inheritance, Polymorphism, & Testing"

Google TechTalks

349K subscribers • 62 videos on Hallway

YouTube
  • Recommended by 3 people: 3 on Hacker News.
  • A classic. People kept recommending it from 2009 to 2022.
  • Presented by Misko Hevery
  • An opinion. It argues one side of a question engineers disagree on.

Intermediate. Assumes working knowledge.

438K views17 years ago3 recommendations

Software designTools and practiceDesign patternsSoftware architectureTesting

Misko Hevery explains how to use object-oriented techniques like polymorphism to eliminate repeated conditional statements and improve testability.

Google Tech Talks November 20, 2008 ABSTRACT Is your code full of if statements? Switch statements? Do you have the same switch statement in various places? When you make changes do you find yourself making the same change to the same if/switch in several places? Did you ever forget one? This talk will discuss approaches to using Object Oriented techniques to remove many of those conditionals. The result is cleaner, tighter, better designed code that's easier to test, understand and maintain. Speaker: Misko Hevery

Why it's here

3 people recommend this

What people say. Highly recommended for learning how to replace complex conditional logic with clean, testable polymorphic designs.

derwikion Hacker News • Recommends

On “Using Polymorphism instead of conditionals when programming”

Google posted a tech talk about this a while ago: link to this video which is more comprehensive than the posted article.

VBprogrammeron Hacker News • Recommends

On “Criminal Overengineering”

I completely disagree with the example given in this blog. I don't have time to give a full explaination but I believe the google clean code talks gives a far better arguement than I ever could. On the general principle I agree that overengineering is to be avoided, but I actually think the example shows a clear disregard for Object Orientated principles. link to this video

Mr_Pon Hacker News • Recommends

On “Flags Are a Code Smell (2014)”

It's not so much the existence of the flag, itself, but rather using an if-statement at the deepest-level of the call stack to conditionally modify behavior. This talk gives a great overview of why boolean flags (rather, if-statements) can be a code smell: link to this video OP's blogpost advocates for data-oriented design (e.g. Entity Component Systems) as a mechanism for avoiding this, whereas the talk I've linked advocates for OOP. Both mechanisms are equally valid (imho) and are inline with widely-adopted industry practices for software architecture.

wcoenenon Hacker News • Mentions

On “How A Pull Request Rocked My World”

This google tech talk is basically about the same thing, eliminating conditionals with polymorphism: link to this video

efraimon Hacker News • Mentions

On “Anti-if: The Missing Patterns”

Misko Hevery did a Google Tech Talk about this some years ago, he also use a very similar example with switching on the birds. link to this video

tacitusarcon Hacker News • Mentions

On “Push ifs up and fors down”

…else in the code for walrus in walruses { processing_function() } If the decisions are made as early as possible, they do not need to be littered throughout the code. The guts of the code can run without branches, performing the same operations every time, the output only modified through the construction graph. Of course, this is not a new idea: link to this video It was old 15 years ago.…