優秀的程序 vs 糟糕的程序

開發者Rahul Singh近日在其個人博客中列出了他眼中的優秀的程序和糟糕的程序:

引用

優秀的程序可以使複雜的東西看起來很簡單;糟糕的程序讓原本簡單的東西變得複雜。

優秀的程序不需要加以說明;糟糕的程序需要大量註釋。

優秀的程序編寫時需要更多時間,但未來花費的時間卻更少;糟糕的程序往往花費較少的時間,但會在未來浪費掉更多時間。

優秀的程序需要考慮當前和未來的需求;糟糕的程序只側重於現在,在未來可能無法正常工作。

優秀的程序非常易於維護;糟糕的程序難以維護。

優秀的程序有更長的生命週期,甚至應用範圍超出預期;糟糕的程序在其工作範圍之外幾乎無法使用。

優秀的程序如同良好的習慣,其影響將持續很長一段時間,幾乎可以永久地解決問題;糟糕的程序如同止痛藥,其效果只有很短的時間,解決問題大多是暫時的。

優秀的程序是整潔的、遵守規律的;糟糕的程序是混亂的。

優秀的程序可以令人學到很多編程方法和經驗;糟糕的程序只能令人越學越糟。

優秀的程序中,該重用的地方重用,該發明的地方發明;糟糕的程序會重新發明輪子,並在適合發明的地方重用。

優秀的程序依靠程序員的直覺和知識,並經過了多年良好程序習慣的薰陶;糟糕的程序往往盲目依賴他人的知識和經驗,而沒有自己的理解。

優秀的程序可以很容易地從一個程序員轉移給另一個程序員;糟糕的程序只能被編寫者理解和實施。

優秀的程序員不會刻意去記憶一段代碼,他依賴於他的邏輯思維能力和理解,並能在未來輕鬆改善代碼;糟糕的程序員往往會記住很多自己不理解的代碼。

優秀的程序都有相同的特徵,如簡單、可讀性強、效率高;糟糕的程序各有糟糕之處。

優秀的程序比程序員存在的時間要更久;糟糕的程序存在的時間很短。

Good Programming, Bad Programming

November 17, 2012

Some thoughts on Good Programming and Bad Programming:

Good Programming makes even complex things seem simple.
Bad Programming makes even simple things complex.

Good programming is self-explanatory.
Bad Programming requires explanation.

Good Programming takes more time now, but less time in future.
Bad Programming takes less time now, but more time in future.

Good Programming involves considering present and future requirements.
Bad Programming focuses only on the present and may not work in future.

Good Programs are easy to maintain.
Bad Programs are hard to maintain.

Good Programs have a longer lifespan, and may even outlast the purpose for which they were created.
Bad Programs have short lifespan and barely usable outside their working scope.

Good Programs are like good habits, whose effects last for a long time and solves the problem almost permanently.
Bad Programs are like painkillers, whose effects last for only short time and solves the problem mostly temporarily.

Good Programming is clean and disciplined.
Bad Programming is messy and chaotic.

Good Programming is learned, practiced and mastered over a period of years.
Bad Programming is self brought, and when practiced for long time makes it even more difficult to learn good programming.

Good Programming is knowing when to invent and when to reuse.
Bad Programming is inventing what's already invented, and reusing what can be better invented.

Good Programming is relying on your own instincts and knowledge, gained after years of good programming practice.
Bad Programming is relying blindly on others knowledge and experience, without applying your own understanding.

Good Programs can be transferred from one programmer to another programmer.
Bad Programs can only be understood and implemented by the same programmer.

Good Programmer doesn't memorize piece of code. He relies on his logical skills and understanding, and can enhance the code easily in future.
Bad Programmer memorizes the piece of code instead of taking right efforts to learn it, and has difficulty in making changes to the code.

Good Programs are good for similar reasons like simplicity, readability, and efficiency.
Every Bad Program is bad for its own reason.

Good Programming Concepts outlast the life of a programmer.
Bad Programming Concepts die with the programmer.

http://www.singhrahul.com/2012/11/good-programming-bad-programming.html

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章