HackerTubewatch
Surprise me
Frame from "The Clean Code Talks  -- Inheritance, Polymorphism, & Testing" Plays via YouTube's privacy-enhanced embed

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

56 videos recommended on HN
YouTube
3 HN users recommended this talk3 months2009–2023 score 3
Years with an HN recommendation, 2007–2026

HN commenters recommend it as a thorough treatment of replacing conditionals with polymorphism and why flags and deep ifs can be code smells.

Misko Hevery's Clean Code Talk shows how to use object-oriented techniques such as polymorphism to remove repeated if and switch statements. The result is code that is easier to test, understand and maintain.

“This talk gives a great overview of why boolean flags (rather, if-statements) can be a code smell” (HN, 2022)

3 recommendations · 3 citations · Talks · intermediate · partly dated

6 Hacker News comments

From the HN archive; up to 20 kept per video, favoring different commenters. Recommendations first.

@VBprogrammer Jun 2010 Recommends
on HN thread 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. [this video]
Better argument for OO principles than the blog.
@Mr_P May 2022 Recommends
on HN thread 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: [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.
Why boolean flags and deep if-statements are a code smell.

Citations, criticism and jokes

@efraim Jun 2016 Cites it
on HN thread 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. [this video]
Misko Hevery talk using a similar example.
@tacitusarc Nov 2023 Cites it
on HN thread Push ifs up and fors down
Read more
I think this is actually a great example of why `if` should be "pushed up." The objective of the code is to perform an particular operation on the walrus, given a condition. The is actually ifs being instead of polymorphism and a type system. Why does the walrus have these two functions, which must be called in different scenarios? Why not have a single function, and two types, and the correct type is passed in? Even given the current structure, we could accomplish this: // There are better ways to accomplish this, depending on the language func frobnicate(walrus) { return walrus.frobnicate(); } func transmogrify(walrus) { return walrus.transmogrify(); } // Somewhere high in the code if condition { processing_function = frobnicate } else { processing_function = transmogrify } // Somewhere 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: [this video] It was old 15 years ago.
Making decisions early via polymorphism is an old idea.

Video list and Hacker News comment labels from HackerTube (prompted by @karpathy), released under ODC-By 1.0, built on the open-index/hacker-news archive. Hacker News data is provided by Y Combinator; comments remain the work of their authors. Video titles, channel names and thumbnails belong to their creators and are shown via YouTube. HackerTube Watch is an unofficial edition. Data export of 2026-10-31.

Keyboard shortcuts

/
Search
j k
Next / previous video
r
Surprise me
l
Like (video page)
w
Watch later (video page)
?
This help
Esc
Close