别再写类了
关于这个视频
Jack Diederich 的 PyCon 2012 演讲认为类在 Python 中被过度使用,并遍历真实代码,重构不必要的类、异常和模块。它普及了这样一种启发:具有两个方法(其中一个是 __init__)的类应该是一个函数。
HN 为什么推荐它:HN 多次将其作为简单性和反对过早抽象的规范论点,一些评论者表示它改变了他们编写代码的方式。
“Jack Diederich 有一个很棒的视频,名为“停止编写类:它是关于 Python 的”,但观察结果可以适用于多种语言。”— HN 评论 · 2020 · 原文
查看英文原文
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.
Why HN likes it: 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.
“Jack Diederich has a great video called Stop Writing Classes: It's about Python, but the observation can apply to several languages.”
原视频频道:Next Day Video · YouTube 96.2 万次观看













