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項必修法則
66
| 第七章:在汙物中打滾
請提起勇氣修改程式碼。你有一張安全防護網:原始碼控制系統。如果你出錯,一定可
以回到當時的情況,重新嘗試一次。這不會浪費你的精力,因為透過實作,你已經學習
程式碼,以及它的能耐。
有時大膽地挖出程式碼並換掉它是值得的。看起來沒有整理或重構的程式碼,修正零散
的狀況可能太過痛苦且困難。但是換掉整個程式碼還是有一些潛在的風險:在特殊情況
下,那種讓人無法閱讀的程式碼
或許
是有原因的。每一次的修補 hack 都會寫入一段
重要的功能,要經歷痛苦才會發現。忽略這些微妙的行為,需要自負後果。
Micheal Feathers
Working Effectively with Legacy Code
是一本討論如何適當地修改流
沙程式碼的優秀書籍
1
。他提到一個很棒的技術,可在程式碼中加入接縫—你可以加入
測試點,而且幾乎可以安全地加入。
戰記:容器程式碼奇案
有一種容器類別。它在專案的核心。它的內部是污穢的,API 也很糟糕。原本寫它的程
式員努力地讓它作怪。它裡面的 bug 被混亂不堪的行為隱藏起來。事實上,令人難以理
解的行為本身就是個 bug
我們其中一位技術高超的開發程式員試著重構並修護容器。他保持外部介面的完好,並
提升許多內部的品質:修正方法,去除專案生命週期行為、效能的 Bug,及讓程式更優
雅。[Page-60]
他取出討厭的、醜陋的、過度簡化的、愚蠢的程式碼,換成截然不同的程式。但是在他
維護舊 API 的工作中,這個新的版本過於做作,比較像是科學專案,而不是實用的程式 ...
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