- 页码：第1页 2011-02-13 17:56:44
The Boy Scout of America have a simple rule: "Try and leave this world a little better than you found it".Mr Robert C. Martin, authors of Clean Code, adapted it as The Boy Scout Rule: check-in our code a little cleaner than when we check it out. What we need to do is to write our code firstly, and then to refactor it, it is a continuous improvemnt. From down to top, it is better to pay attention below items:1, Meaningful Names.2, Small Functions and less argument.3, Good Comments and Bad Comments4, Formatting the code.5, Object-oriented, expose behavior and hide data, make it easy to add new class without change existing functions; data structure, expose data, make it easy to add new functions wihout changing the existing data structure. 6, Error Handling code is viewable independently of main code.7, Manage third-party boundaries by having few places in the code that refer to them(wrap them, use Adapter).8, Keep Unit test clean.9, class should be small(single responsibility principle), open-close principle, dependency inversion principle.10,separate consturcting a system from using it.(dependency injection)11,Emergent Design: Runs all the tests, Refactoring.12,Concurrency.In fact, there are too many rules, and some rules are also need to be reconsidered and balanced. However, As the author said that: the value system has been the goal and the topic of this book. Professionalism and craftsmanship come from values that drive disciplines.
说明 · · · · · ·