每当事情变得越来越复杂时,都会打开下面这篇文档,学习前辈们的教导。
━━━━━━━━━━━━━━━━━
Unix Philosophy
━━━━━━━━━━━━━━━━━
■ Rule of Modularity
模块化规则
Write simple parts connected
by clean interfaces.
编写通过干净的接口连接的简单部件。
■ Rule of Clarity
清晰规则
Clarity is better than cleverness.
清晰胜于聪明。
■ Rule of Composition
组合规则
Design programs to be connected
to other programs.
设计可与其他程序连接的程序。
■ Rule of Separation
分离规则
Separate policy from mechanism;
separate interfaces from engines.
政策与机制分离;
将接口与引擎分开。
■ Rule of Simplicity
简单规则
Design for simplicity;
add complexity only where you must.
设计简单;
仅在必要时增加复杂性。
■ Rule of Parsimony
简约法则
Write a big program only when
it is clear by demonstration
that nothing else will do.
只有当通过演示清楚表明
没有其他方法可以做时,
才编写一个大程序。
■ Rule of Transparency
透明规则
Design for visibility to make
inspection and debugging easier.
设计可见性,
使检查和调试更容易。
■ Rule of Robustness
稳健性规则
Robustness is the child of
transparency and simplicity.
稳健性是透明度和简单性的产物。
■ Rule of Representation
表示规则
Fold knowledge into data so
program logic can be stupid
and robust.
将知识折叠到数据中,
这样程序逻辑就可以变得
愚蠢而健壮。
■ Rule of Least Surprise
最小惊讶规则
In interface design, always do
the least surprising thing.
在界面设计中,
总是做最不令人惊讶的事情。
■ Rule of Silence
沉默规则
When a program has nothing
surprising to say,
it should say nothing.
当一个程序没有什么
令人惊讶的内容要说时,
它就应该什么也不说。
■ Rule of Repair
修复规则
When you must fail, fail noisily
and as soon as possible.
当你必须失败时,
要尽可能大声地失败。
■ Rule of Economy
经济法则
Programmer time is expensive;
conserve it in preference
to machine time.
程序员的时间是昂贵的;
优先于机器时间来节省它。
■ Rule of Generation
生成规则
Avoid hand-hacking; write programs
to write programs when you can.
避免手工破解;
尽可能地编写程序来编写程序。
■ Rule of Optimization
优化规则
Prototype before polishing.
Get it working before you
optimize it.
打磨之前先建原型。
在优化之前先让它发挥作用。
■ Rule of Diversity
多样性规则
Distrust all claims for
"one true way".
不要相信所有
"唯一正确的道路"的主张。
■ Rule of Extensibility
可扩展性规则
Design for the future,
because it will be here
sooner than you think.
为未来而设计,
因为它会比您想象的更早出现。