Skip to Content
成為卓越程式設計師的38項必修法則
book

成為卓越程式設計師的38項必修法則

by Pete Goodliffe
May 2015
Intermediate to advanced
376 pages
5h 48m
Chinese
GoTop Information, Inc.
Content preview from 成為卓越程式設計師的38項必修法則
第四章
藉由移除程式碼來改善它
我們說,簡單就是美,它沒有多餘的部分,恰如其分地展現…
- Ralph Waldo Emerson
少即是多
。這是一個老套的教條,但有時它很正確。29
在我記憶中,最令人興奮的程式改善,都與
移除
大量的程式碼有關。告訴你,這種感覺
很爽。
戰記:不需要程式碼
身為 Agile 軟體開發團隊的一員,我們一直遵循神聖的極端程式設計原則,包括
YAGNI
,也就是,
You Aren't Gonna Need It
:提醒你不要編寫沒必要的程式碼—甚至包
括你認為未來版本需要的程式碼。如果你現在不需要,就不要去寫,等到真正有需要時
再寫。
這聽起來像是非常有道理的建議,而且我們都會買單。
但人類有其天性,我們會在一些地方出錯。有一次,我看到作品在執行某些工作時花費
太多時間了,那是幾乎立刻就可以完成的工作。原因是它們被過度實作,掛滿不需要且
花俏的東西,並且充斥著之後要用來擴充的裝置。這些東西沒有一個會用到,但當時加
入它們都很合理。
因此我將程式碼簡化,提升作品的效能,並藉由移除程式碼中所有違規的“功能”來減
少基礎程式碼的總熵值。有益的是,我的單位測試告訴我,在操作的過程中,我並未破
壞任何其他的東西。這是一個簡單且讓我非常滿意的經驗。
34 | 第四章:藉由移除程式碼來改善它
重點

你可以藉由添加新的程式碼來改善系統。 ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

精通機器學習|使用Python

精通機器學習|使用Python

Sarah Guido, Andreas C. Mueller
Java性能优化实践:JVM调优策略、工具与技巧

Java性能优化实践:JVM调优策略、工具与技巧

Benjamin J. Evans, James Gough, Chris Newland

Publisher Resources

ISBN: 9789863475699