Implementation
CODING CONVENTIONS
Coding convention is generally a set of guidelines created by the main author of the source code to maintain the readability and maintenance of the source code.
File organization, Indentation, comments, Declarations, naming conventions, programming practices and principles
File Organizations
- Java Source Files
- Each Java source file contains a single public class or interface. When private classes and interfaces are associated with a public class, you can put them in the same source file as the public class. The public class should be the first class or interface in the file.
Package and Import statements
The first non-comment line of most Java source files is a package statement. After that, import statements can follow. For example:
package java.awt;
import java.awt.peer.CanvasPeer;
Indentation
Four spaces should be used as the unit of indentation. The exact construction of the indentation (spaces vs. tabs) is unspecified. Tabs must be set exactly every 8 spaces (not 4).
Comments
Comments should be used to give overviews of code and provide additional information that is not readily available in the code itself
Declaration
Number Per Line
One declaration per line is recommended since it encourages commenting.
Initialization
Try to initialize local variables where they're declared. The only reason not to initialize a variable where it's declared is if the initial value depends on some computation occurring first.
Placement
Put declarations only at the beginning of blocks. (A block is any code surrounded by curly braces "{" and "}".) Don't wait to declare variables until their first use; it can confuse the unwary programmer and hamper code portability within the scope.
Class and Interface Declarations
When coding Java classes and interfaces, the following formatting rules should be followed:
- No space between a method name and the parenthesis "(" starting its parameter list
- Open brace "{" appears at the end of the same line as the declaration statement
- Closing brace "}" starts a line by itself indented to match its corresponding opening statement, except when it is a null statement the "}" should appear immediately after the "{“
Naming conventions
Naming conventions make programs more understandable by making them easier to read.
- Classes: Class names should be nouns, in mixed case with the first letter of each internal word capitalized.
- Interfaces:Interface names should be capitalized like class names.
- Variables:Variable names should not start with underscore _ or dollar sign $ characters
Coding Practices and Principles
- Providing Access to Instance and Class Variables
- Referring to Class Variables and Methods
- Constants
- Variable Assignments
Personas
Prototype AND STORYBOARDS
User view