Code neat way - Format

For the format code, everyone has a different coding style, this is nothing. But for a team, the best able to unify the code style, in the same project, if flooded with different coding style everywhere, compared to people not so comfortable to read, such as placing brackets in any place, a few indent characters, how to name the constants, variables and methods, the whole team should follow the same set of rules, even those rules can be written to the IDE's code format, using the IDE prompts to help.

With just talking style is different, but does not affect readers. But some coding style makes it difficult to read, while others will make the reader feel good. So how can people read format pleasure of it? A few simple summary can be read to see whether it will help, and if so, please do so.

  1. Before each method plus blank line, highlight a

  2. Life of local variables used its position as close as possible

  3. Class variables should be declared at the top of the class

  4. If a function calls another function, the caller should be placed above it is called, so there is a natural order of reading

  5. A set of functions that perform similar operations should be placed together

  6. Each line of code should not be too long, at least not beyond the width of the screen reading

  7. Code indentation, without explanation, read indent non-standard code is painful

  8. If the loop circulation statement is empty, but also to ensure that the indentation empty loop body, it will easily be seen as a loop after

  9. and many more

Guess you like

Origin www.cnblogs.com/hujingnb/p/11568650.html