Style Guidelines
- Good names for variables, constants, and methods.
- Consistent style (e.g., use of curly brackets).
- Good indentation.
- In your code you should leave one blank space between operators (e.g., x = 5 + 7).
- Make sure that you define values as constants when needed. For example,
do not use variables for constants. Also, do not use numbers in your
expressions if those numbers have a special meaning (e.g., 3.1415); instead
define constants for them.
- You must avoid code duplication by calling appropriate methods
(rather than cutting and pasting code). You may define your own
private utility methods to perform often repeated tasks.
- Do not call static methods by using a class instance.
- You should avoid source lines exceeding 80 characters.
- Make sure you recognize when a field should be defined as private, protected,
public or package.
- Remove from your code variables that are declared but never used.
- Remove any unnecessary import statements.
- The clarity of code can benefit from using empty lines between
segments of code. Make sure you take this into account while writing your
code. Similarly, comments in your methods are important in order to clarify
what your code is doing. Make sure you provide such comments when needed.
-
Simplify your code when possible. After implementing a method verify
if it can be implemented in a simpler way.
- Feel free to use the Eclipse Format Element option (Source
→ Format).
Web Accessibility