dd

作者:pidy  于 2022-9-4 13:31 发表于 最热闹的华人社交网络--贝壳村

通用分类:政经军事

四人帮

这可能很难记住,但面向对象编程在 1990 年代风靡一时。许多程序员没有谈论一流函数和通用数据结构的力量,而是用虚方法、超类、子类和巧妙的 mixin 来装饰他们的代码。程序员经常发现语言限制和静态类型使他们无法对代码进行改进。

“四人帮”赶来救援。他们的书的第一个也是最基本的模式,在整个页面上用斜体标出,如果坚持实践的话,将让程序员摆脱硬连接到具体类的代码:

“编程到接口,而不是实现。”

这种做法以更多代码为代价,使程序员朝着我们在 Python 这样的动态语言中享受的自由迈出了一步。本书后面的每一章都解决了这个时代有限的编程语言带来的不同设计难题并解决了它。大多数解决方案都引入了新类,以巧妙地解耦原本链接过于紧密的代码。

该站点在现代动态编程语言的上下文中检查四人帮的旧模式,其中类和函数是一流的对象,以查看哪些模式仍然有用,哪些模式消失了。您可以回到本网站的首页开始研究这些模式

Gang of Four book

It can be hard to remember, but object oriented programming was all the rage back in the roaring 1990s. Instead of talking about the power of first-class functions and general-purpose data structures, many programmers were festooning their code with virtual methods, superclasses, subclasses, and clever mixins. Programmers often found that language limitations and static types were locking them out of improvements they later wanted to make to their code.

The “Gang of Four” rode to the rescue. Their book’s first and most fundamental pattern, blazoned across the page in italics, would — if practiced consistently — break programmers free of code that was hard-wired to concrete classes:

“Program to an interface, not an implementation.”

At the expense of more code, this practice moved programmers one step towards the freedom we enjoy in a dynamic language like Python. Each of the book’s further chapters tackled a different design conundrum posed by the era’s limited programming languages and solved it. Most of the solutions introduced new classes to cleverly decouple code that would otherwise be too tightly linked.

This site examines the old patterns from the Gang of Four in the context of a modern dynamic programming language in which classes and functions are first-class objects, to see which patterns are still useful and which ones disappear. You can start working through the patterns back on this site’s front page.




高兴

感动

同情

搞笑

难过

拍砖

支持

鲜花

评论 (0 个评论)

facelist doodle 涂鸦板

您需要登录后才可以评论 登录 | 注册

关于本站 | 隐私政策 | 免责条款 | 版权声明 | 联络我们 | 刊登广告 | 转手机版 | APP下载

Copyright © 2001-2013 海外华人中文门户:倍可亲 (http://www.backchina.com) All Rights Reserved.

程序系统基于 Discuz! X3.1 商业版 优化 Discuz! © 2001-2013 Comsenz Inc. 更新:GMT+8, 2024-4-26 08:38

倍可亲服务器位于美国圣何塞、西雅图和达拉斯顶级数据中心,为更好服务全球网友特统一使用京港台时间

返回顶部