Skip to content

Latest commit

 

History

History
51 lines (31 loc) · 1.98 KB

CODING_GUIDELINES.md

File metadata and controls

51 lines (31 loc) · 1.98 KB

Coding Guidelines and Best Practices

Naming Conventions

Acronyms in Names

  1. For 4+ letter acronyms, use lowercase. E.g. LdapUtils, HttpURL.

  2. For 2 and 3 letter acronyms, use uppercase. E.g. IOUtils, XMLUtils.

Interfaces and Implementing Classes

  1. Do NOT prefix interfaces with I. Interface names should represent their role in the system without any syntactic markers. E.g. UserService, not IUserService.

  2. Do NOT postfix implementations with Impl. Instead, focus on meaningful and descriptive names. E.g. LdapUserService, not UserServiceImpl.

  3. Descriptive naming for multiple implementations: If there are multiple implementations of an interface, make sure each class name reflects its purpose or underlying mechanism, e.g. LdapUserService, JdbcUserService.

  4. If only one implementation exists and the interface is required only for technical purposes (e.g., remoting), prefix the implementation with Default, and use the same name for the interface and the class. E.g. DefaultUserService.

Constants (static final)

  1. Use UPPERCASE letters and separate words with underscores, e.g. MAX_LENGTH, DEFAULT_TIMEOUT.

Source Code Formatting

  1. Format your code contributions using the vegardit.com Eclipse formatter rules.

    IntelliJ users can use the Eclipse Code Formatter plugin to import and use the formatter settings.

    To format the source code on the command line use mvn process-sources -Dformatter.skip=false

  2. Consistent line length: Maintain a maximum line length of 140 characters.

  3. Use spaces, not tabs: Set the indentation to 3 spaces per level.

  4. Braces placement: Use the K&R style (braces on the same line), e.g.:

    if (condition) {
       // action
    } else {
       // action
    }