
Next Day Video
8 HN recommenders · recommended in 19 months, 2012–2025
27:29 · 962K views · Mar 15, 2012
Jack Diederich's PyCon 2012 talk argues that classes are overused in Python and walks through real code, refactoring away unnecessary classes, exceptions and modules. It popularized the heuristic that a class with two methods, one being __init__, should be a function.
HN returns to it repeatedly as the canonical argument for simplicity and against premature abstraction, and several commenters say it changed how they write code.
20 comments from Hacker News
Stop writing classes - Jack Diederich - this video Show them this. I'm still grateful for the moment I grew dissatisfied with OOP, or at least OOP in the Java/C# way. I was almost getting to an intermediate level in python (by myself) and had been thinking about a video game architecture problem I just couldn't solve. I was still "indoctrinated" in the gang-of-four patterns and inheritance. When I discovered the solution, Entity Component Architectures[1], I also discovered the "composition over inheritance" philosophy. My mind was blown! Coupled with some Python's characteristics (duck-typing, everything is public, first-class functions) I was having a blast. Then I saw the video above, and all fell into place. Class based OOP have specific uses, but It's a shame how heavily enforced the paradigm is. “Sometimes, the elegant implementation is just a function. Not a method. Not a class. Not a framework. Just a function.” – John Carmack Now, for scripts or not-to-big programs in Python, I mainly use NamedTuples for passing data around and (mostly) pure functions. P.S. Another funny thing: At my job I use J2EE aka "lots of hinheritance and classes and boilerplate". Sometimes I just have to go home and write some code in python or lua to "cleanse my palate". It helps me get motivated for my personal projects. [1] [LINK]
I also tend to avoid writing many classes (in Python). Jack Diederich has a great video called Stop Writing Classes: this video It's about Python, but the observation can apply to several languages. Pithy quote: "I hate code and I want as little of it as possible in our product."
I think you're thinking of Jack Diederich's talk "Stop Writing Classes". You can (and should!) watch it online here: this video
Stop writing classes is one of my favorites. Also many pycon talks are great, or any talks by Brandon Rhodes. this video
Reminds me of this talk, "Stop Writing Classes": this video Changed my perspective on this newfound tool I'd learned to use called "indirection". My favorite quote is something like "don't waste 10 minutes now to save yourself 2 minutes later".