The Exceptional Beauty of Doom 3’s Source Code 心得
1.
Code should be locally coherent and single-functioned: One function should do exactly one thing. It should be clear about what it's doing.
程式碼只能有局部的關聯性, 一個function只能作一件事
2.
Local code should explain, or at least hint at the overall system design.
(這個我不能理解, 局部的程式碼要如何看出整體系統設計)
3.
Code should be self-documenting. Comments should be avoided whenever possible. Comments duplicate work when both writing and reading code. If you need to comment something to make it understandable it should probably be rewritten.
程式碼即為註解
4.
"everything should always be const unless it can't be"
所有變數預設都必須是CONST
5.
"no in-out" parameter policy
一個變數不會被同時當成輸入和輸出參數
6.
Minimal Comments
減少註解, 因為程式碼即為註解
7.
over-use set/get methods
過度使用set/get
浙公网安备 33010602011771号