Java Coding Guidelines

Naming Conventions

Naming convention is a rule to name your identifiers. An identifier is a name of class, package, variable, constant or method. It helps us to distinguish variables, constants, methods, and classes in large source code written by developers.

By using standard Java naming conventions developers make their code easier to read for themselves and for other developers. Readability of Java code is important because it takes less time to understand the code and figures out what the code does and gives more time to fix or modify the code.

Following are naming conventions followed by Java identifiers:

Packages:

Package Names should be in lowercase. Package name is derived from domain name of the organization. The initial package name representing the domain name must be in lower case and reverse order of domain name.

package com.sunilos;

package com.sunilos.view ;

package com.sunilos.controller;

Classes:

Class name should be a noun. Class name should be written in Camel Case that means first letter of each word in class name should be capital.

class Customer

class Account

class FileReader

Interfaces:

Interface names are written in Camel Case. They usually have a name that describes an operation that a class can do.

interface Comparable

interface Enumeration

Methods:

If a method name consists of more than one word then first word will be written in small letters and subsequent words will be written in Camel Case.

For example

void calculateTax()

double getBalance()

void deposit()

String getAddress()