淘沙TV
Python、Ruby 和脚本语言

别再写类了

原名:Stop Writing Classes
爱吃小笼包99·YouTube 96.2 万次观看·B站 64 播放·2 年前·27:30
在 B 站打开 原 YouTube 版本

关于这个视频

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.”

HN 提及 20 次推荐者 8 人首次 2012最近 2025质量分 10.0

原视频频道:Next Day Video · YouTube 96.2 万次观看

演讲进阶常青pythonpycon面向对象设计重构简洁