9个很好的编程建议

选译自stackoverflow 原文链接http://stackoverflow.com/questions/406760/whats-your-most-controversial-programming-opinion

1. Programmers who don't code in their spare time for fun will never become as good as those that do.

    热情与乐趣是提高自我的源动力。

2.The only "best practice" you should be using all the time is "Use Your Brain". 

    思考是学习所有技术的捷径。

3.If you only know one language, no matter how well you know it, you're not a great programmer. 

    "博学而笃志,切问而近思。"(博,广也。驾,厚也。志,识也。言广学而厚识之,使不忘。切问者,亲切问于己所学未悟之事,不泛滥问之也。近思者,思己历未能及之事,不远思也。若泛问所未学,远思所未达,则于所习者不精,所思者不解。

4.Readability is the most important aspect of your code. 

    代码的可读性是代码质量的关键之一。 

5.Every time you consider writing a debug printout, consider writing a unit-test instead. ( or turn int into logging statement)

    用单元测试或者记录日志来代替测试时的输出。 

6.Design patterns fail because people make the arrogant mistake of equating idioms in their insular little language fiefdoms with grand ontologies that describe and explain the Universe.

     不要为了应用设计模式而进行设计,设计模式是手段而不是目的。

 7.Perfection is attained not when you have nothing left to add, but when there is nothing left to take away.

    合适的注释是不能再减少任何文字。

  8.Writing the tests first does force you to think differently about your API, which can arguably make you code better. If you don't know what tests to write, then you don't know what code to write either.

    先写测试后写代码。

9.Write small methods.

    短的函数更易读,并更易重用。 

    

 

 

你可能感兴趣的:(编程)