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項必修法則
第十九章
程式重複使用案例
如果它無法被刪減、重複使用、修複、重建、翻新、拋光、轉售、
回收或製成肥料,就應該限制它、重新設計它,或是不把它當成產品。
- Pete Seeger
我們聽過一種神話般的事情,稱為“程式重複使用”。曾有一段時間,它變得令人難以
置信地流行,成為另一個軟體銀色子彈,一種可讓偽造品供應商推銷的新東西。我不相
信它。
我們在開發軟體時,經常提到“使用案例”。我們也看過這些
重複使用案例
重複使用案例 1:複製麵條
從某個 app 複製出來的程式植入其他 app。好吧,在我的書中,這不太像程式重複使
,比較像
程式重複
。或者,更不禮貌的說法:複製貼上程式設計。它通常是邪惡的,
等同於程式海盜。想像一下,有一群張狂的程式員,掠奪並囤積七大軟體海域的軟體寶
石。大膽,但危險。它的程式是由不衛生的水手寫成。記得 DRY 口頭禪:不要重複自
己做過的事
當你在專案中複製同樣的程式片段 516 次,之後才發現裡面有 bug,這種“重複使用”
就是真正的殺手。你怎麼確定可以找到並修復每一個問題?真的要祝你好運。
172
| 第十九章:程式重複使用案例
儘管如此,你可以辯稱在專案之間做複製貼上確實可以讓事情完成。這種情況經常發
生,而且這個世界還沒有毀滅,至少目前如此。複製貼上的程式碼可避免沒必要的耦
合,這種耦合或許會發生在 ...
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