Changes between Version 5 and Version 6 of DevelopmentGuidelines
- Timestamp:
- Feb 7, 2011, 4:58:49 PM (7 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
DevelopmentGuidelines
v5 v6 38 38 == Naming conventions == 39 39 * In Java, naming conventions for identifiers have been established and suggested by various Java communities such as Sun Microsystem<ref>"Code Conventions for the Java Programming Language", [http://java.sun.com/docs/codeconv/html/CodeConventions.doc8.html Section 9: "Naming Conventions"]</ref>, Netscape<ref>"NETSCAPE'S SOFTWARE CODING STANDARDS GUIDE FOR JAVA",[http://collaboratory.emsl.pnl.gov/docs/collab/sam/CodeStandards.html Collab Software Coding Standards Guide for Java]</ref>, AmbySoft<ref>"AmbySoft Inc. Coding Standards for Java v17.01d", [http://www.ambysoft.com/essays/javaCodingStandards.html]</ref> and etc. A sample of naming conventions set by Sun Microsystem are listed below: 40 {| class="wikitable" border="1" 40 41 41 ||Identifier Type||Rules for Naming||Examples|| 42 42 ||Classes||Class names should be nouns, in mixed case with the first letter of each internal word capitalized. Try to keep your class names simple and descriptive. Use whole words-avoid acronyms and abbreviations (unless the abbreviation is much more widely used than the long form, such as URL or HTML).||class Raster;class ImageSprite; 43 43 ||Methods|| Methods should be verbs, in mixed case with the first letter lowercase, with the first letter of each internal word capitalized.|| run(); runFast(); getBackground(); 44 ||Variables|| Except for variables, all instance, class, and class constants are in mixed case with a lowercase first letter. Internal words start with capital letters. Variable names should not start with underscore _ or dollar sign $ characters, even though both are allowed. 45 Variable names should be short yet meaningful. The choice of a variable name should be mnemonic- that is, designed to indicate to the casual observer the intent of its use. One-character variable names should be avoided except for temporary "throwaway" variables. Common names for temporary variables are i, j, k, m, and n for integers; c, d, and e for characters. 44 ||Variables|| Except for variables, all instance, class, and class constants are in mixed case with a lowercase first letter. Internal words start with capital letters. Variable names should not start with underscore _ or dollar sign $ characters, even though both are allowed. Variable names should be short yet meaningful. The choice of a variable name should be mnemonic- that is, designed to indicate to the casual observer the intent of its use. One-character variable names should be avoided except for temporary "throwaway" variables. Common names for temporary variables are i, j, k, m, and n for integers; c, d, and e for characters. 46 45 ||int i; char c; float myWidth; 47 46 ||