Saturday, September 1, 2007

Code Ruler Review

Today's assignment is Code Ruler Review. I'm reviewing the code of Shaoxuan Zhang.


Overall Impressions

A little dense in places, but generally well written. The strategy was clear and sensibly implemented.

I noticed that English does not seem to be Shaoxuan's first language. I had no problem understanding the comments, but the type of grammar tweaking that the rules insist on seemed rather pointless. I think maybe those rules should be relaxed in this case (but I listed them anyway).

The number of things to fix was surprisingly low, considering it was written before we got the rules.

Standards Check

Entries in the "Lines" column refer to the MyRuler.java file.

LinesRuleRule Description
ICS-SE-Java-0Follow EJS standards.
1ICS-SE-Java-1All code is within the package hierarchy "edu.hawaii".
1ICS-SE-Java-2Do not use the wildcard "*" in import statements.
ICS-SE-Java-3Only one Java statement per line.
ICS-SE-Java-4Do not include // comments at the top of the file.
ICS-SE-Java-5Rewrite default Eclipse template JavaDocs to be useful.
ICS-SE-Java-6Format JavaDoc summary lines correctly
ICS-SE-Java-7Do not use Vector and Hashtable classes.
ICS-SE-Java-8Do not use "raw" Collections classes
ICS-SE-Java-9Prefer the for-each control structure to the for control structure.
ICS-SE-Java-10Use the @Override annotation when overriding equals() and hashCode
ICS-SE-Eclipse-1Use Eclipse Europa 3.3
*ICS-SE-Eclipse-2Import and use the Eclipse Java Code formatting template.
ICS-SE-Eclipse-3Configure Text Editor.
EJS-1Adhere to the style of the original.
EJS-2Adhere to the Principle of Least Astonishment.
EJS-3Do it right the first time.
EJS-4Document any deviations.
EJS-5Indent nested code.
EJS-6Break up long lines.
EJS-7Include whitespace
22,23,24,*EJS-8Do not use "hard" tabs
EJS-9Use meaningful names.
EJS-10Use familiar names.
EJS-11Question excessively long names.
EJS-12Join the vowel generation.
EJS-13Capitalize only the first letter in acronyms.
EJS-14Do not use names that differ only in case.
EJS-15Use the reversed, lowercase name of your organization's Internet domain name as the root qualifier for your package names.
EJS-16Use a single, lowercase word as the root name of each package.
EJS-17NOT USED
EJS-18Capitalize the first letter of each word that appears in a class or interface name.
EJS-19Use nouns when naming classes.
EJS-20Pluralize the names of classes that group related attributes, static services or constants.
EJS-21Use nouns or adjectives when naming interfaces.
EJS-22Use lowercase for the first word and capitalize only the first letter of each subsequent word that appears in a method name.
157EJS-23Use verbs when naming methods.
EJS-24Follow the JavaBeans™ conventions for naming property and accessor methods.
EJS-25Use lowercase for the first word and capitalize only the first letter of each subsequent word that appears in a variable name.
EJS-26Use nouns to name fields.
EJS-27Pluralize the names of collection references.
EJS-28Establish and use a set of names for trivial "throwaway" variables.
92,96,100,*EJS-29Qualify field names with "this" to distinguish them from local variables.
EJS-30When a constructor or "set" assigns a parameter to a field, give that parameter the same name as the field.
EJS-31Use uppercase letters for each word and separate each pair of words with an underscore when naming constants.
EJS-32Write documentation for those who must use your code and those who must maintain it.
EJS-33Keep comments and code in sync.
12EJS-34Use the active voice and omit needless words.
22,28EJS-35Use documentation comments to describe the programming interface.
EJS-36Use standard comments to hide code without removing it.
32,36,40,*EJS-37Use one-line comments to explain implementation details.
EJS-38Describe the programming interface before you write the code.
91EJS-39Document public, protected, package, and private members.
EJS-40Provide a summary description and overview for each package.
EJS-41Provide a summary description and overview for each application or group of packages.
EJS-42Use a single consistent format and organization for all documentation comments.
EJS-43NOT USED
EJS-44Wrap code with <pre>...</pre> tags.
EJS-45Consider marking the first occurrence of an identifier with a {@link} tag.
EJS-46Establish and use a fixed ordering for Javadoc tags.
125,150,198,*EJS-47Write in the third-person narrative form.
8,124,149EJS-48Write summary descriptions that stand alone.
124,149EJS-49Omit the subject in summary descriptions of actions or services.
8EJS-50Omit the subject and the verb in summary descriptions of things.
10,152EJS-51Use "this" rather than "the" when referring to instances of the current class.
EJS-52Do not add parentheses to a method or constructor name unless you want to specify a particular signature.
EJS-53Provide a summary description for each class, interface, field and method.
91EJS-54Fully describe the signature of each method.
EJS-55Include examples.
EJS-56Document preconditions, postconditions, and invariant conditions.
EJS-57Document known defects and deficiencies.
EJS-58Document synchronization semantics.
EJS-59Add internal comments only if they will aid others in understanding your code.
EJS-60Describe why the code is doing what it does, not what the code is doing.
172,187,205,*EJS-61Avoid the use of end-line comments.
EJS-62Explain local variable creations with an end-line comment.
EJS-63Establish and use a set of keywords to flag unresolved issues.
EJS-64Label closing braces in highly nested control structures.
EJS-65Add a "fall-through" comment between two case labels, if no break statement separates those labels.
EJS-66Label empty statements.
EJS-67Consider declaring classes representing fundamental data types as final.
EJS-68Build concrete types from native types and other concrete types.
EJS-69Define small classes and methods.
EJS-70Define subclasses so they may be used anywhere there superclass may be used.
55,59,63,*EJS-71Make all fields private.
EJS-72Use polymorphism instead of instanceof.
EJS-73NOT USED?
EJS-74NOT USED
EJS-75Replace nontrivial expressions with equivalent methods.
105,109,132,*EJS-76Use block statements instead of expression statements in control flow constructs.
EJS-77Clarify the order of operations with parentheses.
EJS-78Always code a break statement in the last case of a switch statements.
EJS-79Use equals(), not ==, to test for equality of objects.
EJS-80Always construct objects in a valid state.
EJS-81Do not call nonfinal methods from within a constructor.
EJS-82Use nested constructors to eliminate redundant code.
EJS-83Use unchecked, run-time errors to report serious unexpected errors that may indicate an error in the program's logic.
EJS-84Use checked exceptions to report errors that may occur, however rarely, under normal program operation.
EJS-85Use return codes to report expected state changes.
EJS-86Only convert exceptions to add information.
EJS-87Do not silently absorb a run-time error exception.
EJS-88Use a finally block to release resources.
EJS-89Program by contract.
EJS-90NOT USED
EJS-91Use assertions to catch logic errors in your code.
EJS-92Use assertions to test pre- and post-conditions of a method.
EJS-93Use threads only where appropriate.
EJS-94Avoid synchronization.
EJS-95Use synchronized wrappers to provide synchronized interfaces.
EJS-96Do not synchronize an entire method if the method contains significant operations that do not need to be synchronized.
EJS-97Avoid unnecessary synchronization when reading or writing instance variables.
EJS-98Consider using notify() instead of notifyAll().
EJS-99Use the double-check pattern for synchronized initialization.
EJS-100Use lazy initialization.
EJS-101Avoid creating unnecessary objects.
EJS-102Reinitialize and reuse objects to avoid new object construction.
EJS-103Leave optimization for last.
EJS-104Place types that are commonly used, changed, and released together, or mutually dependent on each other into the same package.
EJS-105Isolate volatile classes and interfaces in a separates packages.
EJS-106Avoid making packages that are difficult to change dependent on packages that are easy to change.
EJS-107Maximize abstraction to maximize stability.
EJS-108Capture high-level design and architecture as stable abstractions organized into stable packages.

No comments: