The only valid measurement of code quality : WTFs/minute
We've all felt the relief of seeing our messy program work and deciding that a working mess is better than nothing. We've all said we'd go back and clean it up later. LeBlanc's law: Later equals never.
The Boy Scout Rule : The Boy scouts of America have a simple rule that we can apply to our profession - Leave the campground cleaner than you found it.
Choosing good names takes time but saves more than it takes.
a. Use intention revealing names - It should tell why it exists, what it does, and how it is used. If a name requires a comment, then the name does not reveal its intent
b. Make meaningful distinctions - It is not sufficient to add number series or noise words. Number-series naming(a1, a2,.. , an) is the opposite of intentional naming. They are noninformative. Noise words are redundant. The word varaible should never appear in a vairable name. The word table should never appear in a table name.
c. Use searchable names and Avoid mental mapping - The length of a name should correspond to the size of its scope. In most other contexts, a single letter name is a poor choice; it's just a placeholder that the reader must mentally map to the actual concept.
d. Class names - Classes and objects should have noun or noun phrase names like Customer, WikiPage, Account, Addressparser. Avoid words like Manager, Processor, Data or Info in the name of a class. A class name should not be a verb.
e. Method names - Methods should have verb or verb phrase names like postPayment, deletePage or save. Accessors, mutators and predicates should be named for their valure and prefixed with get, set and is according to javabean standard.
f. Don't be cute - Choose clarity over entertainment value.
g. Pick one word per concept - Pick one word for one abstract concept and stick with it. For instance, it's confusing to have fetch, retrieve and get as equivalent methods of different classes. Avoid using the same word for two purposes.
h. Add meaningful context - You can add context by using prefixes.
i. use pronounceable names