later equels never
Write clean code, you need to follow a lot of tips, hard to implement the acquisition of "clean feeling."
This "Code Sense" is the key.
In short, write clean code programmers is like an artist, he can transform the series turned into a white board system consisting of elegant code.
Do not repeat the code, only one thing, expressive, small-scale abstract.
Meaningful name
by reading a lot of code, you can find a criterion for the quality of the code, just to be called a good
writer must read a lot of books, articles and quality of a newspaper.
Software design ideas are not constructed a program can do anything, but to construct a lot of classes that can accurately reflect our thoughts,
can work together to allow us to construct a beautiful application, and have a minimum of work amount (with respect to the complexity of the task),
sufficient to ensure the production and performance advantages of correct results. This program is easy to understand, easy to maintain, but simply some code quickly
pieced together to accomplish a specific task is not possible to have such a little.
Longer than humans to remember and use words. A considerable part of the brain is used to receive and process word. Words can be read out. The human brain evolved to
have so much of a place used to process speech, if not put to good use, it is a shame.
Class and object names should be nouns or noun phrases, such as customer, not the class name should be a verb.
Method name
Method name should be a verb or verb phrase, such as postPaymen, deletePage or save.
It can be considered appropriate constructor set to private, using this nomenclature forced means.
Do not play cute
Each word corresponds to a concept
for a word is selected from each of abstraction, and a consistent.
Do not use puns
Avoid the same word used for different purposes. Different concepts for the same term, essentially the pun.
Use solutions Name
Use the field name from the implications of the
Add meaningful context
Do not add useless context
function
Short
The first function is to short rule, the second rule is even more short.
Each function just say one thing.
Code block indentation and
Function should do one thing. Do it well. Only this one thing.
Each function is a level of abstraction
To ensure that the function of only one thing, the function of the statement to be on the same level of abstraction.
A top read down the code word: Down regulation
switch statement
Use a descriptive name
The more a function of short, feature more centralized, the easier it a good name.
Function Arguments
Output parameters also difficult to understand than the input parameters. When the read function, we are accustomed to think that information through parameter input function,
an output from a function return value.
Common forms of unary functions
Parameters representing
Identification parameters ugly. Pass a Boolean value is simply appalling practice to function.
Binary function
Ary function
Parameter object
Verbs and keywords
No side effects
Split instruction and inquiry
Function either do, or what to answer, but they can not have both. The function should modify the state of an object,
or return information about the object.
Alternative use exceptions return an error code
Disengagement try / catch block
Error handling is one thing
error.java rely magnet
Do not repeat yourself
Structured Programming
goto just makes sense only in the big function, so it should be avoided if possible.
Write code and write something else like. When writing papers or articles, you first think of what to write, and then polish it.
Perhaps the first draft of crude disorderly, you will, where appropriate scrutiny, until you reach the eyes look.