Skip to content

Coding Standard

Noam Yefet edited this page Jun 5, 2017 · 13 revisions

Purpose

In this wiki we will detail the coding standard of SmartMarket project. Each contributer should restrict to them.

Develop Languages, Environments & IDE

The SmartMarket Project created and developed by students (with guidance) as their final project.Such that, it comes with some strict restrictions:

  • Use Java Language as your code base. Specific use the newest JDK from oracle site: JDK 8
  • Use the newest Eclipse for Java developers . It is important due to the code refactoring plugin you should install and use - Spartainzer.

Warnings

As required in our project, we are using high resolution of warnings notification. In particular, we added this warnings (Beyond those that exist by default):

  1. Possible accidental Boolean assignment.
  2. empty statement
  3. missing synchronized modifier on inherited method
  4. class overrides 'equals()' but not 'hascode()'
  5. unused type parameter
  6. unnecessary 'else' statement
  7. unnecessary cast or 'instanceof' operation
  8. unnecessary declarion of thrown exception
  9. Missing '@override' annotation
  10. Missing '@deprecated' annotation
  11. redundant null check

You can add them by checking them in Window > Preferences > Compiler > Errors/Warnings

Spartanizer

Open source project written by the professors and students from Computer Science Faculty, Technion. The definition by it creators: "Eclipse plugin that performs automatic refactoring of Java source code, making it shorter, more efficient and more readable" In the project page you can find all the info you need about it's advantages, installation and using. Use it to do the refactoring of all your code and don't ignore itipst tips, except the following:

  1. got to Window > Preferences > Java > Installed JREs > Laconization Tips. remove the following tips

    a. Centification

    b. Dollarization

    c. Inlining

    d. Ternarization.

  2. on each project, cilick on the right-mouse click, choose Refactor > Spartanization Preferences. uncheck the following tips:

    a. Canonicalization > TwoDeclarationsIntoOne.

    b. Under Idiomatic, Uncheck the following:

     c. Under Inlining, Uncheck the following:
    

     d. Under Nominal, Uncheck the following:
    

     e. Under Structural, Uncheck the following:
    

     f. Under Structural->Collapse, Uncheck the following:
    

     g. Under Structural->Syntactic baggage, Uncheck the following:
    

     h. Under Structural->Trivialization, Uncheck the following:
    

Documentation

Use JavaDoc to all your classes. the minimum documentation should be include:

/**
 * ClassName - Class Purpose short summary
 * 
 * @author Lior Ben Ami
 * @since 2017-03-26
 */