Intelligence program is good program! 有智慧的程式就是好程式!

I have read and refactor quite a few projects/programs that coded by my colleagues or former colleagues. And of course refactoring my own projects source code too. Here is something that I feel deeply in my heart.
Just like how to define beauty, how to define what is a good program or coding practice is not something that has an exact correct answer. But there is some traces or characteristics which make you feel like, Ah~ this is good. On the contrary, some of them give you, Oh~ da#n it, you son of the bXtch!
There is one very remarkable thing that justify a program or source code between these two is, is the program smart or not?
我己經看過和重構過不少同事或以前同事的專案和程式.當然包括重構我自己的專案程式碼.這讓我深刻體會到一件事.
就正如怎樣去定義美一樣,要定義一個好的程式或者好的寫程式習慣並沒有一個標準答案.但會有一些蛛絲馬跡或特徵會讓你覺得,啊~這樣很好.相反地,有一些會讓你想罵,噢~他X的,你這X人!
這當中有一樣可以用作鑑定一個程式或程式碼是好是壞的東西,就是這程式聰明嗎?
If a program doesn’t do any checking or validation to the input, or do nothing about controlling the input, it is stupid.
If a programmer do not think about “what if something like that happen”, do nothing about it, for example, what if the connection is broken during some process, he is stupid.
If a program that doesn’t contain any setup or setting for the user when it should, definitely stupid.
If a programmer *assume* something or anything when writing the program, for example, assuming you have the administrator right. The outcome program will be very stupid.
If a programmer compile a program, success, and go through a perfect procedure using the program, telling you that he/she has done testing it. The program and the programmer is both stupid.
如果一個程式對輸入不做任何檢查或確認,又或者不去對輸入做控制,那就是蠢程式.
如果一個程式人員在寫程式時沒有去想”如果這樣的事發生呢”,也沒有對這件事做任何處理的話,例如,如果在某個函式運作途中斷線呢,這是個蠢人.
如果一個程式應該有些使用者設定而沒有提供任何介面或方法來做設定,明顯很蠢.
如果一個程式人員在寫程式時*假設*一些理想狀況或者其他條件,例如,假設你有管理員權限,那寫出來的程式一定很蠢.
如果一個程式人員認為程式編譯沒錯誤,然後經過一個完美的使用流程,跟你說這程式我測過沒問題.那這個程式和這個人都很蠢.
These sorts of look like stupid mistakes which you and I may think you will never make are the most command mistakes I encounter during my refactoring process. So what is going on?
You know what, stupid programs comes from stupid programmers.
這些看似很愚蠢的失誤,可能你和我覺得絕不可能發生在我身上,正正是最常我重構時出現在我眼前.到底怎麼了?
事情是這樣的,蠢程式的來源就是蠢人.

Leave a Reply

Please log in using one of these methods to post your comment:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s