如果引用或轉貼,麻煩註明出處與本網誌連結,否則視為侵權。

2005年1月3日

如何寫出無法維護的程式 - 簡介

如何寫出無法維護的程式

原作 : How To Write Unmaintainable Code ©1997-2004 Canadian Mind Products

中譯 : Fred F.M. Wang 2005/1/3

簡介Introduction
Never ascribe to malice, that which can be explained by incompetence.

拿破崙Napoleon
這篇論文像冰糖跟糖用線綁在一起然後泡在糖水內, 很快的大到無法收拾
This essay has been like rock candy, seed the string with sugar, soak in sugar water, soon it grew out of control.

為了得到Java程式設計師的聘僱機會, 我寫了這些技巧給雇主有關如何讓寫出來的程式難以維護, 而這些維護者必須跟在你旁邊幾年才有辦法做最簡單的修改. 更進一步你若虔誠地遵循這些規則, 你可以確保終身被雇用, 因為除了你以外, 沒有人希望進入維護程式的煉獄. 另外, 如果你虔誠地遵循這全部的規則, 甚至連你自己都可能無法維護這些程式.
In the interests of creating employment opportunities in the Java programming field, I am passing on these tips from the masters on how to write code that is so difficult to maintain, that the people who come after you will take years to make even the simplest changes. Further, if you follow all these rules religiously, you will even guarantee yourself a lifetime of employment, since no one but you has a hope in hell of maintaining the code. Then again, if you followed all these rules religiously, even you wouldn't be able to maintain the code!

不要做的太過分. 你的程式不該看起來完全沒有可以維護的希望, 而是只是一定程度的問題. 否則會有被重寫或重構的風險
You don't want to overdo this. Your code should not look hopelessly unmaintainable, just be that way. Otherwise it stands the risk of being rewritten or refactored.

這篇論文分成下面段落(原來各段落為網頁上的連結)
This giant essay has been split into sections to make it faster to load.
a.基本原則General Principles
b.命名Naming
c.偽裝Camouflage
d.文件Documentation
e.程式設計Program Design
f.程式模糊化Coding Obfuscation
g.測試Testing
h.語言的選擇Choice Of Language
i.對付其他人Dealing With Others
j.寫你自己的東西Roll Your Own
k.掌握語言的弱點Tricks In Offbeat Languages
l.混雜的技術Miscellaneous Techniques
m.哲學Philosophy
n.沒有鞋的鞋匠The Shoemaker Has No Shoes
o.貢獻者Contributors
p.運作白蟻Operation Termite

譯者註 :
這篇文章用反諷的方式來寫不好的程式設計風格,也就是一個好的程式設計師不該犯的錯誤及該反省是否犯了這些錯誤,藉由這篇文章將自己長久的惡習加以修正。 (2005/01/03 Fred)

相關文章
如何寫出無法維護的程式- 簡介
如何寫出無法維護的程式- 基本原則
如何寫出無法維護的程式- 命名1-5
如何寫出無法維護的程式- 命名6-10
如何寫出無法維護的程式- 命名11-15
如何寫出無法維護的程式- 命名16-20

沒有留言:

張貼留言

歡迎提供意見, 謝謝 (註 : 留言經過版主審核通過才會發布)