HackerTube
HomeLongsLikedHistoryWatch laterCategoriesPlaylistsSettings

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

Google TechTalks3 HN recommenders · recommended in 3 months, 2009-2023
YouTube
438K views · 17 years ago · talk · dated

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.

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

Software architecture & designTesting, debugging & developer tools#cleancode#polymorphism#object-orienteddesign#testing#refactoring

6 comments from Hacker News

@tacitusarc2023 · in “Push ifs up and fors down”

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.

CitesView on HN
@Mr_P2022 · in “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.

RecommendsView on HN
@efraim2016 · in “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

CitesView on HN
@wcoenen2013 · in “How A Pull Request Rocked My World”

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

CitesView on HN
@VBprogrammer2010 · in “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

RecommendsView on HN
@derwiki2009 · in “Using Polymorphism instead of conditionals when programming”

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

RecommendsView on HN
Dan Abramov   The wet codebase25:01

Dan Abramov The wet codebase

eswarnichtsmehrfrei
27K views • 5 years ago
Practical Common Lisp1:12:10

Practical Common Lisp

Google TechTalks
98K views • 19 years ago
Adventure with Types in Haskell - Simon Peyton Jones (Lecture 1)1:33:37

Adventure with Types in Haskell - Simon Peyton Jones (Lecture 1)

jasonofthel33t
69K views • 12 years ago
Object-Oriented Programming is Bad44:35

Object-Oriented Programming is Bad

Brian Will
2.6M views • 10 years ago
Domain Modeling Made Functional - Scott Wlaschin - KanDDDinsky 201950:49

Domain Modeling Made Functional - Scott Wlaschin - KanDDDinsky 2019

KanDDDinsky
74K views • 6 years ago
Philip Wadler  - Propositions as Types (Lambda Days 2016)56:58

Philip Wadler - Propositions as Types (Lambda Days 2016)

Erlang Solutions
20K views • 10 years ago
Simon Peyton Jones - Linear Haskell: practical linearity in a higher-order polymorphic language1:03:34

Simon Peyton Jones - Linear Haskell: practical linearity in a higher-order polymorphic language

Curry On!
19K views • 8 years ago
The Clean Architecture in Python49:54

The Clean Architecture in Python

Next Day Video
114K views • 12 years ago
Stop Writing Classes27:29

Stop Writing Classes

Next Day Video
962K views • 14 years ago
🚀  TDD, Where Did It All Go Wrong (Ian Cooper)1:03:55

🚀 TDD, Where Did It All Go Wrong (Ian Cooper)

DevTernity Conference
619K views • 8 years ago
Domain Modeling Made Functional - Scott Wlaschin51:40

Domain Modeling Made Functional - Scott Wlaschin

NDC Conferences
71K views • 9 years ago
Solving Problems the Clojure Way - Rafal Dittwald1:02:26

Solving Problems the Clojure Way - Rafal Dittwald

Clojure/north
87K views • 7 years ago
Maybe Not - Rich Hickey1:03:29

Maybe Not - Rich Hickey

ClojureTV
181K views • 7 years ago
Brian Goetz - Stewardship: the Sobering Parts1:03:31

Brian Goetz - Stewardship: the Sobering Parts

ClojureTV
39K views • 11 years ago
Effective Programs - 10 Years of Clojure - Rich Hickey1:14:52

Effective Programs - 10 Years of Clojure - Rich Hickey

ClojureTV
176K views • 9 years ago
"Type-Driven Program Synthesis" by Nadia Polikarpova39:40

"Type-Driven Program Synthesis" by Nadia Polikarpova

Strange Loop Conference
15K views • 8 years ago
Ruby Conf 12 - Boundaries by Gary Bernhardt45:55

Ruby Conf 12 - Boundaries by Gary Bernhardt

Confreaks
58K views • 13 years ago
Spec-ulation Keynote - Rich Hickey1:16:14

Spec-ulation Keynote - Rich Hickey

ClojureTV
135K views • 9 years ago
Beyond functional programming: a taste of Verse. Simon Peyton Jones & Tim Sweeney | Lambda Days 20231:12:14

Beyond functional programming: a taste of Verse. Simon Peyton Jones & Tim Sweeney | Lambda Days 2023

Code Sync
30K views • 3 years ago
Are We There Yet - Rich Hickey1:10:05

Are We There Yet - Rich Hickey

Zhang Jian
24K views • 7 years ago