/
Guidelines for Naming Conventions

Guidelines for Naming Conventions

Guidelines for Naming Conventions

  1. Use Plural Names for Collections:
    When naming collections (lists, arrays, etc.), use plural nouns to indicate that the variable holds multiple items.

    // Good List<Integer> connectionIDs = new ArrayList<>();

    This makes it clear that connectionIDs is a collection of multiple Integer values.

  2. Avoid Prefixing with "List" or "Array":
    Do not prefix collection names with words like "List" or "Array" unless it improves clarity.

    // Bad List<Integer> listOfConnectionIDs = new ArrayList<>(); // Good List<Integer> connectionIDs = new ArrayList<>();

    Using prefixes like "listOf" can add unnecessary verbosity and reduce readability.

  3. Use Descriptive and Meaningful Names:
    Choose names that clearly convey the purpose and contents of the collection.

    // Good List<String> customerEmails = new ArrayList<>(); // Good Set<Long> activeUserIds = new HashSet<>();

    This helps anyone reading the code understand what kind of data the collection holds.

  4. Be Consistent with Naming Style:
    Maintain consistency in naming conventions throughout your codebase. If you use plural names for collections in one part of your code, continue to do so across all similar contexts.

Related content