`
javasee
  • 浏览: 961353 次
  • 性别: Icon_minigender_1
  • 来自: 北京
文章分类
社区版块
存档分类
最新评论

“祖尔谈软件”——过时的悲叹?

阅读更多

不知道什么时候(大概是从几个台湾人翻译了他的weblogs开始吧),“祖尔谈软件”似乎受到了越来越多程序员的青睐。不过,说实话,我很反感这位祖尔的论调。看看这段话吧:

不管怎么说,我不认为Extreme Programming是在鼓吹零设计的理念。他们只是说:“不要作任何无必要的设计”,这没有什么错嘛。但人们听到的并不是这样。大多数程序员是在找不用设计的借口,所以他们像飞蛾扑火般投向“不用设计” 这个馊主意。这是一种奇怪的,让你事倍功半的懒惰方式。我懒得先在纸上把这个功能给设计好了,所以我就先写程序,然后发现不对,我就去改,结果反倒花更多的时间。或者,更经常发生的是,我先写些程序,发现它不对,但是没时间改了,结果我的产品质量低劣,而且我还是要找出些借口,说明它为什么“一定要那样“。那只不过是马虎潦草,缺乏职业精神。”

yuck,这位XP的批评者真的知道XP是在干什么吗?他批评的不是XP,只是他心里想批评的东西而已。不过我不想再多说什么,Cameron Purdy对他的评价更加恰当:这是一个停留在C++年代的程序员。也许,他只是(不巧地、不幸地)在Java或者C#里遗传了C++的语意,并发出了一些过时的悲叹。

————————

Poor sod ..

JoelOnSoftware used to be a really good read. Lately, it's been JoelOnJoel, and throw in some of that 1990s programming stuff just to sound technical. Take today's post as an example:

... I consider exceptions to be no better than "goto's", considered harmful since the 1960s, in that they create an abrupt jump from one point of code to another. In fact they are significantly worse than goto's:

  1. They are invisible in the source code. Looking at a block of code, including functions which may or may not throw exceptions, there is no way to see which exceptions might be thrown and from where. This means that even careful code inspection doesn't reveal potential bugs.

  2. They create too many possible exit points for a function. To write correct code, you really have to think about every possible code path through your function. Every time you call a function that can raise an exception and don't catch it on the spot, you create opportunities for surprise bugs caused by functions that terminated abruptly, leaving data in an inconsistent state, or other code paths that you didn't think about.

A better alternative is to have your functions return error values when things go wrong, and to deal with these explicitly, no matter how verbose it might be.

I'm speechless. (Well, that's not very likely. What I mean is that this guy is waxing clueless.) Let me start by saying that I like his rationale: Unknowns can lead to bugs, and by making everything known, bugs can be eliminated. I mean, come on, who doesn't want to exterminate entire families of bugs? I've coded reams of C++ code that did exactly Joel suggests, and he's right, being extra-anal with immediate error handling and well designed unambiguous return values does improve the quality of code. In C++.

Of course, maybe Joel is still coding in C++. Obviously, he's not coding in Java, which he likes to talk about in the article. The thing is, in Java, which is what most new projects are being built in (or it's cousin C# for Windows shops), using return values as he describes is an anathema. Reading his blog, I feel like how I did back when C programmers were trying to tell me how to build COM applications in C++ .. in fact, his code examples look like they are straight out of a "How to Code Windows NT 3.1 applications in C" book and would even make good examples for "Writing Solid Code" -- if it hadn't already been written 10 years ago, that is.

I wouldn't have had a problem with what he wrote, if he could have stopped with "C/C++", but he somehow assumes that since Java (also C#) generally shares the C/C++ syntax, that it must suffer from the same weaknesses. Java was designed from the ground up around good exception handling; it's not a glue-on long-jump afterthought. With these modern languages, exceptions are generally exceptional, which is to say that just about any line of code can theoretically throw an exception (I use the term "exception" in the loose sense that includes an "error" in Java), and the behavior of exceptions is very well defined and fairly logical.

Even catching all possible exceptions where they occur in Java is basically impossible .. by design. It reflects reality, instead of (as in C++) the assembly code that the source code generates. Furthermore, in Java, if you will purposefully throw something, you get to declare that exception as a checked exception, largely mitigating one of Joel's other concerns. (In C#, there are no checked exceptions, but you can still write comments saying what your code throws, which is a reasonable trade-off for being able to build Windows Forms in COBOL.)

So do yourself a favor: If you're coding in Java or C#, ignore his advice. The 90s are over and have been for a couple years. I don't like to have to explain OO to C coders (they still say "What's the big deal? I can do all that with structs and function pointers!") and I don't want to explain modern exception handling to people polluting their code with reams of brittle "if" statements under some delusion that they are actually handling exceptional conditions.

分享到:
评论

相关推荐

    r 语言指南(英)祖尔著part1

    搞数据挖掘的又一工具 这是第一部分与第二部分一起解压

    r 语言指南(英)祖尔著part2

    搞大数据挖掘的又一工具 这是第二部分与第一部分一起解压

    祖尔多斯

    "祖尔多斯"可能是指一个特定的项目或者软件,但在这个上下文中,它没有提供足够的信息来深入探讨。然而,既然标签是"HTML",我们可以聚焦于HTML(HyperText Markup Language)这一主题,它是创建网页的基础语言。 ...

    DHBW:贝斯皮勒和脚本祖尔

    福里根德·贝西皮勒(Vorliegende Besipiele) - React-Training1 - einfache Code Beispiele für Variablen, Objekten, Arrays, Destructuring, Rest-Operator etc. - React-Training2 - einfache Code ...

    浅谈圆周率的由来和应用.doc

    标题“浅谈圆周率的由来和应用”聚焦于探讨π(圆周率)这一数学常数的历史和发展,以及其在不同领域的实用价值。这篇文档可能是数学与应用数学专业的一份研究或学习资料,适合2021级学生阅读。 圆周率,通常用希腊...

    curso-ms:Curso deMicroserviçoscom弹簧靴,尤里卡(Eureka),祖尔(Zuul),Hystrix,OAuth,JWT和功能区

    在本课程"curso-ms:Curso de Microserviços com Spring Boot, Eureka, Zuul, Hystrix, OAuth, JWT e Regiões Funcionais"中,我们将深入探讨微服务架构,这是一种现代化的软件开发方法,它将大型应用程序分解为一...

    计算机网络技术.xlsx

    ,,,5人英雄副本boss安苏掉落,需要中级骑术150(600G),需要玩家人物等级60 ,,,, ,,,,*注:该boss为德鲁伊迅捷飞行形态任务召唤 拉扎什迅猛龙,0,100,副本:祖尔格拉布 -- 血领主曼多基尔,副本祖尔格拉布boss血领主...

    Zombie-Ready-Counter-Strike:修改游戏以使其更适合僵尸模式和Escape的Mod

    Mod由ToppiOfficial特殊创建,感谢: 祖尔·史密斯珀蒂(GFL) 冰(GFL) 瓦夫(GFL) 火种射击(Zool的服务器) 在此mod中包含/编辑的资产是借助我创建的自定义程序完成的,该程序可简化需要编辑的VMT的数量。...

    Analysis-2021S

    在这个项目中,我们将会深入探讨JavaScript在软件开发中的重要性和具体应用,同时也会关注到用户体验设计的一个关键元素——黑暗主题。 JavaScript,作为互联网上最广泛使用的编程语言之一,是构建动态网页和Web...

    GM命令大全

    魔兽世界 GM命令 1 传送到暴风城 .go -9065 434 94 0 2 传送到铁炉堡 .go -5032 -819 495 0 3 传送到达木纳苏斯 .go 9961 2055 1329 1...7 祖尔法拉克 .go 1213 841 8.9 209 9 GM之岛 .go 16222.1 16252.1 12.5872 1

    zurl:有点像 Zip Archive 垫片(“Zip Url”)

    祖尔 这是 (又名“Zip Urls”)的垫片吗? 不,不完全是。 那恐怕是行不通的。 然而,它是 Zip Archives 的替代品,因为它实现了类似的结果。 它有效地将文件系统带到浏览器。 如果 Zip Archive 提案似乎获得...

    叙利亚国家及行政区域地理信息及界限地图,kml格式

    叙利亚,全称阿拉伯叙利亚共和国,全国划分为14个省市:大马士革农村省、霍姆斯省、哈马省、拉塔基亚省、伊德利布省、塔尔图斯省、腊卡省、德尔祖尔省、哈塞克省、德拉省、苏韦达省、库奈特拉省、阿勒颇省和大马士革...

    微服务银行

    GFT银行组成部分服务商微量消化客户微服务塞尔维多·尤里卡奴役者祖尔重要提示! 弹性安装Java SE 8,Gradle 6.6.1和Docker安装依存性和无依存关系的克隆。 $ git clone ...

    code-snippet:演示代码项目

    祖尔 Spring Cloud Config Zipkin的Spring Cloud Sleuth Spring Boot管理员 Spring Security,OAuth2 Spring Security,OAuth2,JWT 纳科斯 达博 Spring Cloud Gateway 哨兵 西塔 弹簧靴2 +摇摇欲坠2 顺序uuid...

    spring-cloud:使用Spring Cloud,配置服务器和Spring Eureka的示例

    祖尔 休息服务的代理设计 微服务项目 通过Rest返回json的微服务项目 https://github.com/lelodois/spring-cloud/tree/master/my-customer https://github.com/lelodois/spring-cloud/tree/master/my-product ...

    Servlets_JSP:Web应用程序第二版的练习

    Servlet作为SEPT的信息代表了Web竞争者,例如Podtem Ser Obtidas Pelo Seguinteendereço:Mostre作为信息来源: Nome do Setor:埃祖尔·冯塔纳·格兰德Endereçocompleto做设置者:em preto fonte Arial pequeno ...

    CO2-Ampel:Eine CO2 Ampel基于ESPMHZ-19bBME680

    Zusätzlich卡恩EIN BME680Luftqualitätssensorangeschlossen werden微米死Messwerteつpräzisierensowie Neopixel(WS2812b)UND /奥德EIN SSD1306显示祖尔visuellen浏览量。 梅斯达滕 温度(C) 饱腹感(%) ...

    SRH-Neckargemuend-Java:一个学生的项目文件,该学生想与他的同学(以及其他想要他们的同学)分享他的练习。 主要用于2920类

    密茨·米勒(MürschMütschüler),密尔·米勒·祖尔嫩(Mu mit zu zu lernen),美因法典,祖先和奥地利。 Au0erdemfürjeden,der nicht da war oder nicht mitgekommen ist,mit Kommentaren,um sich die ...

Global site tag (gtag.js) - Google Analytics