Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migration of unmigrated content due to installation of a new plugin

...

This page describes standard coding practices, and is intended to be an aid for developers as they write code. Code reviews will be conducted to ensure we are following our standards.

General

  1. DWR (Direct Web Remoting) is deprecated. New projects should not contain any references to DWR.
  2. All XML schema definition (XSD) locations in project XML files should be declared without version numbers. Version numbers seem to make the app look on the internet for the XSD; omitting the version numbers forces the XSD bundled in the jar files to be used.

...

Code Block
xsi:schemaLocation="
    http://www.springframework.org/schema/beans
    http://www.springframework.org/schema/beans/spring-beans.xsd"

DO NOT DO THIS:

Code Block
xsi:schemaLocation="
    http://www.springframework.org/schema/beans
    http://www.springframework.org/schema/beans/spring-beans-3.0.3.xsd"
                                                             ^^^^^ NO!!!

Web/Controllers

  1. In a Spring MVC web application, controller classes should not extend any Spring framework classes.
  2. Controller classes should be identified to Spring as a controller bean by using the @Controller annotation.
  3. Request URLs should be mapped to controller classes and methods by using the @RequestMapping annotation.
  4. Generally speaking, we aim to configure controllers by using annotations.
  5. We should use the @Autowired annotation for injected dependencies.
  6. As controllers are typically configured as singletons in the Spring context, the classes should be thread-safe. In practical terms, this means fields, or instance variables, should never maintain any state, and they should not be instantiated by the new  operator. The only instance variables in a controller should be other Spring beans, injected by the Spring container. Typically these will be service classes or helper classes.
  7. Controllers should not contain any business logic - they should be concerned with UI-related logic. Business logic should be delegated to service classes.

...