The Rules of Programming: How to Write Better Code (Paperback)

Zimmerman, Chris



This philosophy-of-programming guide presents a unique and entertaining take on how to think about programming. A collection of 21 pragmatic rules, each presented in a stand-alone chapter, captures the essential wisdom that every freshly minted programmer needs to know and provides thought-provoking insights for more seasoned programmers.

Author Chris Zimmerman, cofounder of the video game studio Sucker Punch Productions, teaches basic truths of programming by wrapping them in memorable aphorisms and driving them home with examples drawn from real code. This practical guide also helps managers looking for ways to train new team members.

The rules in this book include:

  • As simple as possible, but no simpler
  • Let your code tell its own story
  • Localize complexity
  • Generalization takes three examples
  • Work backward from your result, not forward from your code
  • The first lesson of optimization is don't optimize
  • A good name is the best documentation
  • Bugs are contagious
  • Eliminate failure cases
  • Code that isn't running doesn't work
  • Sometimes you just need to hammer the nails



作者Chris Zimmerman是電子遊戲公司Sucker Punch Productions的共同創辦人,他通過將基本的程式設計真理包裝成易於記憶的格言,並通過真實代碼的例子加以強調,來教授程式設計的基本真理。這本實用指南還幫助那些尋找培訓新團隊成員方法的管理者。


- 盡可能簡單,但不要過於簡單
- 讓你的程式碼講述自己的故事
- 將複雜性局部化
- 泛化需要三個例子
- 從結果反推,而不是從程式碼開始
- 優化的第一課是不要優化
- 好的名稱是最好的文件
- Bug是具有傳染性的
- 消除失敗案例
- 沒有運行的程式碼是無效的
- 有時你只需要用錘子敲釘子