当前位置: 首页 > news >正文

Erric Gamma 关于resuable code的采访

采访地址

The risk of speculating

Bill Venners: The GoF book says, “The key to maximizing reuse lies in anticipating new requirements and changes to existing requirements, and in designing your systems so they can evolve accordingly. To design a system so that it’s robust to such changes, you must consider how the system might need to change over its lifetime. A design that doesn’t take change into account risks major redesign in the future.” That seems contradictory to the XP philosophy.

Erich Gamma: It contradicts absolutely with XP. It says you should think ahead. You should speculate. You should speculate about flexibility. Well yes, I matured too and XP reminds us that it is expensive to speculate about flexibility, so I probably wouldn’t write this exactly this way anymore. To add flexibility, you really have to be able to justify it by a requirement. If you don’t have a requirement up front, then I wouldn’t put a hook for flexibility in my system up front.

But I don’t think XP and patterns are conflicting. It’s how you use patterns. The XP guys have patterns in their toolbox, it’s just that they refactor to the patterns once they need the flexibility. Whereas we said in the book ten years ago, no, you can also anticipate. You start your design and you use them there up-front. In your up-front design you use patterns, and the XP guys don’t do that.

Bill Venners: So what do the XP guys do first, if they don’t use patterns? They just write the code?

Erich Gamma: They write a test.

Bill Venners: Yes, they code up the test. And then when they implement it, they just implement the code to make the test work. Then when they look back, they refactor, and maybe implement a pattern?

Erich Gamma: Or when there’s a new requirement. I really like flexibility that’s requirement driven. That’s also what we do in Eclipse. When it comes to exposing more API, we do that on demand. We expose API gradually. When clients tell us, “Oh, I had to use or duplicate all these internal classes. I really don’t want to do that,” when we see the need, then we say, OK, we’ll make the investment of publishing this as an API, make it a commitment. So I really think about it in smaller steps, we do not want to commit to an API before its time.

Bill Venners: Well, there are speculative requirements. So if you say you’re going to wait until there’s a requirement, doesn’t that simply move the problem? Because someone could say, “Well, we’re going to need this.” They are saying that’s a requirement. But then someone else might say, “Well, do we really need this, yet?” I’m not quite sure I understand when to speculate and when not to speculate. Who decides when a requirement is really a requirement? How do I decide as a programmer?

Erich Gamma: Well, you must have a customer or consumer of what you produce. For Eclipse, our customer is the community who writes plug-ins. And so we interact with them, and also kind of sync with them, based on the concrete uses we know ourselves, what they might want to use. Therefore my recommendation to a programmer is that when you have to speculate, make sure that you have a least one of your clients involved, preferably more. It also helps when I already have something in my hand.

Bill Venners: What do you mean by having something in your hand?

Erich Gamma: I have a concrete example. And then I go and speculate about how to make it more abstract, and not the other way around. Ideally once I have speculated I immediately ask for feedback from my potential clients.

Bill Venners: So you build a concrete example first.

Erich Gamma: Maybe two or three, until it truly hurts. I duplicate the code once. I duplicate it twice. And then, wow, I had to duplicate it again. At this point the abstraction process starts. So, I say, it would be really nice if this class would allow me to plug in this custom behavior so that I do not have to duplicate the rest.

总结

1,不要过度使用设计模式。如果你的需求没有一个例子,需要你抽象扩展,那就不需要花精力去 人为设计 change point>
2, 可以先写一个实例,当发现有重复代码,开始重构。在这过程中,可以抽象,使用设计模式。
3, 极客开发模式,对效率要求极高。而前期对设计模式投入很多时间,会有点牺牲开发的效率。

相关文章:

Erric Gamma 关于resuable code的采访

采访地址 The risk of speculating Bill Venners: The GoF book says, “The key to maximizing reuse lies in anticipating new requirements and changes to existing requirements, and in designing your systems so they can evolve accordingly. To design a system s…...

【Ubuntu18.04命令行code打不开】可能的解决方法

目录 问题:命令行code打不开文件尝试① kimi是这么说的② sudo apt-get install apparmor apparmor_utils③ 在混沌的操作完以上一通后,sudo apt-get install snapd 我试了将近一个小时 : ( so depressed 我只是想用vscode打开个文件夹,我甚至…...

大数据毕业设计基于springboot+Hadoop实现的豆瓣电子图书推荐系统

文章目录 前言项目介绍技术介绍功能介绍核心代码数据库参考 系统效果图 前言 文章底部名片,获取项目的完整演示视频,免费解答技术疑问 项目介绍 随着开数字化阅读的普及,豆瓣电子图书推荐系统应运而生,旨在为用户提供个性化的阅…...

【进阶OpenCV】 (15)-- 人脸识别 -- EigenFaces算法

文章目录 EigenFaces算法一、算法原理二、算法流程三、算法特点四、代码步骤1. 图像预处理2. 创建Eigenfaces人脸识别器3. 训练模型4. 预测图像 总结 EigenFaces算法 EigenFaces算法是一种基于主成分分析(PCA)的人脸识别方法,其核心思想是通…...

无人机封闭空间建图检测系统技术详解

无人机封闭空间建图检测系统技术是一种集成了多种传感器、智能算法与控制系统的高级技术,旨在实现无人机在复杂封闭环境下的自主导航、精确建图与高效检测。以下是对该技术的详细解析: 一、技术概述 无人机封闭空间建图检测系统通过集成激光雷达(LiDAR…...

webpack自定义插件 ChangeScriptSrcPlugin

插件文件 class ChangeScriptSrcPlugin {apply(compiler) {const pluginName "ChangeScriptSrcPlugin";compiler.hooks.compilation.tap(pluginName, (compilation, callback) > {compilation.hooks.htmlWebpackPluginAlterAssetTags.tapAsync(pluginName,(html…...

win11 笔记本指纹驱动正常就是使用不了

去微信官网下载最新的win11重装系统后,发现笔记本上的指纹登录失效了,网上搜索各种试过不行,新版本与旧的win11有微出入,那些方法都不行。系统版本如下: 操作前确保: 1. win11能升级,默认有试用…...

表的约束

约束就是设定条条框框,保证被约束目标符合约束条件。表的约束就是对表内列数据的约束,保证列数据的正确性。 default 设置列数据的默认值。当用户添加记录的时候没有初始化该列的数据,就是使用默认值初始化。 如果创建表的时候没有设置默认…...

jmeter是怎么用的,怎么设计接口测试用例的

如何使用: Apache JMeter 是一款广泛使用的开源性能测试工具,用于对各种服务(如 Web 应用、数据库、FTP、WEB 服务等)进行负载测试和性能测试。以下是如何使用 JMeter 的基本步骤。 1. 安装 JMeter 下载 JMeter:访问…...

数据挖掘示例

案例背景,有公司进行橡胶玩具的生产,一共生产两种产品,分别为橡皮鱼和橡皮鸭。 已知条件为: 1、公司的橡胶原材料能够生产500只橡皮鸭或者400条橡皮鱼。 2、生产效率为公司产量不会高于400只橡皮鸭和300条橡皮鱼。 3、每只橡皮…...

【PHP】在ThinkPHP6中Swoole与FPM的简单性能测试对比

一、前言 本文主要测试在ThinkPHP 6框架中,使用Swoole扩展库与使用PHP-FPM两者的HTTP并发性能差距,测试方法较简单,仅供参考。 二、测试环境 系统:Ubuntu 22.04 PHP版本:7.4.33 Swoole版本:4.8.13 ThinkPHP版本:6.1.5 ThinkPHP-Swoole扩展库版本:3.1.4 测试工具:A…...

论文写作学习--POLYGCL

POLYGCL: GRAPH CONTRASTIVE LEARNING VIA LEARNABLE SPECTRAL POLYNOMIAL filters 今天由于开了一天的积极分子会议以及要写汇报,因此,只来得及学一会。 摘要 第一步,设定背景 Recently, Graph Contrastive Learning (GCL) has achieved …...

【高等数学】无穷级数

0. 了解 无穷级数是指将无穷多个数按照一定的规律相加起来的表达式。 打个比方,就像你有一个无穷长的梯子,每一级梯子代表一个数。把这些数一个一个加起来,就形成了无穷级数。 比如常见的等比级数,这里是首项,是公比。如果,这个等比级数是收敛的,也就是它的和是一个有限…...

计算机网络——无连接传输UDP

UDP用于流媒体应用和事务性应用(一次往返搞定的应用)...

DS几大常见排序讲解和实现(下)(15)

文章目录 前言一、快排的思想二、Hoare版基本思路代码实现 三、挖坑法基本思路代码实现 四、双指针法基本思想代码实现 五、三数取中六、小区间优化七、三路划分八、自省排序总结 前言 其实下篇就单独讲个快速排序   你可能会想这是什么神通,竟然能单独开一篇来讲…...

电脑视频剪辑大比拼,谁更胜一筹?

随着短视频的火爆,越来越多的人开始尝试自己动手制作视频,无论是记录生活点滴还是创作个性短片,一款好用的视频剪辑软件是必不可少的。今天,我们就从短视频运营的角度,来聊聊几款热门的电脑视频剪辑软件,看…...

计算机毕业设计 基于Web的景区管理系统的设计与实现 Java+SpringBoot+Vue 前后端分离 文档报告 代码讲解 安装调试

🍊作者:计算机编程-吉哥 🍊简介:专业从事JavaWeb程序开发,微信小程序开发,定制化项目、 源码、代码讲解、文档撰写、ppt制作。做自己喜欢的事,生活就是快乐的。 🍊心愿:点…...

计算生物学与生物信息学漫谈-2-测序深度/读长质量和Fasta处理

上一篇文章中我们介绍了测序技术的由来与发展,那么在介绍第三代测序的时候,我们提到了关于测序深度和读长的问题,那么本篇文章就详解介绍一下。 计算生物学与生物信息学漫谈-1-测序一路走来-CSDN博客 目录 1.测序深度SEQUENCING DEPTH &…...

基于SSM+微信小程序的电子点餐管理系统(点餐1)

👉文末查看项目功能视频演示获取源码sql脚本视频导入教程视频 1、项目介绍 基于SSM微信小程序的电子点餐管理系统实现了管理员及用户。管理员实现了首页、个人中心、餐品分类管理、特色餐品管理、订单信息管理、用户管理、特价餐品管理、活动订单管理、系统管理。…...

IO进程---day5

1、使用有名管道实现两个进程之间的相互通信 //管道文件 #include<myhead.h> int main(int argc, const char *argv[]) {//创建有名管道文件1if(mkfifo("./pipe1",0664)-1){perror("创建管道文件失败");return 0;}if(mkfifo("./pipe2",066…...

matlab(Octave) 绘图

1. ezplot plot &#xff0c; [plɒt] &#xff0c;vt. 绘图。 ezplot&#xff0c;easy to plot。用于绘制一元函数。 ezplot(expression,[左区间&#xff0c;右区间]) %语法 ezplot(1/x,[-10,10]); %例子,y1/x的图像图 1-1 ezplot作图&#xff0c;octave 2.mesh(x,y,z) 用于作…...

DXVK:突破Linux游戏性能瓶颈的Vulkan转换层解决方案

DXVK&#xff1a;突破Linux游戏性能瓶颈的Vulkan转换层解决方案 【免费下载链接】dxvk Vulkan-based implementation of D3D8, 9, 10 and 11 for Linux / Wine 项目地址: https://gitcode.com/gh_mirrors/dx/dxvk 技术价值&#xff1a;重新定义Linux游戏图形渲染标准 填…...

XiaomiGateway3网络稳定性终极指南:WiFi设置、信道选择与干扰排除

XiaomiGateway3网络稳定性终极指南&#xff1a;WiFi设置、信道选择与干扰排除 【免费下载链接】XiaomiGateway3 Home Assistant custom component for control Xiaomi Multimode Gateway (aka Gateway 3), Xiaomi Multimode Gateway 2, Aqara Hub E1 on default firmwares over…...

OpenClaw成本警报:gemma-3-12b-it的Token消耗监控与限额设置

OpenClaw成本警报&#xff1a;gemma-3-12b-it的Token消耗监控与限额设置 1. 为什么需要关注Token消耗&#xff1f; 上周我的OpenClaw自动化流程突然中断&#xff0c;检查日志发现是gemma-3-12b-it模型的API调用达到了限额。更让我后怕的是&#xff0c;如果这个限额不存在&…...

从FLOPS到TOPS:深入解析算力单位及其在AI芯片中的应用

1. 算力单位&#xff1a;从FLOPS到TOPS的进化史 第一次接触FLOPS这个术语时&#xff0c;我正试图比较两款显卡的性能。当时完全被各种"FLOP"搞晕了头&#xff0c;直到后来在实际项目中调试AI模型时&#xff0c;才真正理解了这些算力单位背后的意义。FLOPS&#xff0…...

RCTD实战:5步搞定单细胞与空间转录组数据整合(附避坑指南)

RCTD实战&#xff1a;5步搞定单细胞与空间转录组数据整合&#xff08;附避坑指南&#xff09; 在单细胞测序技术蓬勃发展的今天&#xff0c;空间转录组数据正成为解析组织微环境的新利器。但一个spot包含多个细胞的"混合信号"问题&#xff0c;让许多研究者对着珍贵的…...

AI专著写作全流程:专业工具深度剖析,助你顺利完成大作

学术专著写作挑战与AI工具助力 对于许多学者而言&#xff0c;撰写学术专著最大的挑战&#xff0c;往往就是“有限的时间”与“无限的期望”的矛盾。完成一部专著通常需要3到5年&#xff0c;甚至更长的时间&#xff0c;而学者们还得兼顾教学、科研项目以及学术交流等多重责任&a…...

从无人机防抖到股票预测:聊聊卡尔曼滤波在你身边的那些‘隐藏’应用

从无人机防抖到股票预测&#xff1a;卡尔曼滤波如何悄悄优化你的日常生活 想象一下&#xff0c;你正在用手机拍摄一段奔跑中的宠物视频&#xff0c;画面却出奇地稳定&#xff1b;或者驾驶着搭载自动驾驶辅助系统的车辆&#xff0c;它总能精准预判前车距离。这些看似"智能&…...

从‘单打独斗’到‘团队协作’:实战解析如何将DeepSeek的文本能力与Gemini的多模态API组合使用

从‘单打独斗’到‘团队协作’&#xff1a;实战解析如何将DeepSeek的文本能力与Gemini的多模态API组合使用 在AI技术日新月异的今天&#xff0c;开发者们常常面临一个困境&#xff1a;是选择专注于单一领域的强大模型&#xff0c;还是尝试整合多个模型的优势&#xff1f;这个问…...

EcomGPT-7B赋能跨境电商:多语言商品描述与AIGC内容创作

EcomGPT-7B赋能跨境电商&#xff1a;多语言商品描述与AIGC内容创作 1. 引言 做跨境电商的朋友&#xff0c;可能都遇到过这样的头疼事&#xff1a;好不容易把一款产品打磨好&#xff0c;准备上架到亚马逊或者独立站&#xff0c;结果卡在了商品描述和营销文案上。自己写的英文总…...