Google的原则:不作恶。
程序员的原则:不挖坑。
写代码的正确方式:战战兢兢,如履薄冰。
程序员是一个创造力强,个人色彩浓厚的职业,不同的人,代码的风格习惯千差万别,这个时候,就需要标准来约束程序员的代码,越是庞大的项目越应该如此。规范越早引入越好,规范的约束永远不嫌多。
我们应该遵循古老的原则:“能做并不意味着应该做”。
- 约定优于配置
- 不要太过于依赖注释,注释只是业务的补充,良好的代码结构和命名能够能够避免很多不必要的注释
- 清晰原则:清晰胜于技巧 (代码是给人看的,其次才是在机器上运行的,10行复杂的代码不如30行清晰的代码)
- 吝啬原则:除非确无它法,不要编写庞大的程序(动不动就上千行的代码不要再出现了!!!)
- 健壮原则:健壮源于透明和简洁