Categories





Refresher: Naming Standards of Java Components

As a refresher, I’m listing the following Java coding conventions that are regarded as generally acceptable for coding in Java and more specifically for developing your automation framework.

Packages:

  • Package names are written in all lower case.
  • Typically includes the reversed internet domain.
  • Examples: com.automationtested.mypackage, org.pixaloop.mypackage, org.openqa.selenium

Classes:

  • The first character should be in upper case followed by camel casing.
  • The name should represent a noun.
  • Examples: Customers, GreenApples, AutomaticDomesticCars

Interfaces:

  • The first character should be in upper case followed by camel casing.
  • The name should represent an “adjective”.
  • Use the suffix of ‘-able’.
  • Examples: ActionListener, Serializable, Readable, Groupable, Runnable

Methods (functions):

  • The first character should begin with a small character followed by camel casing.
  • The name should represent a verb-noun pair.
  • Examples: addSelection, getTitle, takeScreenshot, tearDown

Variables:

  • The first character should begin with a small character followed by camel casing.
  • The name should be meaningful
  • Examples: firstName, buttonWidth, submitButton; accountBalance

Constants:

  • All characters should be in upper case.
  • Words are connected with underscores.
  • Examples: MY_URL, MAX_SIZE, MIN_PRIORITY

 

Comments are closed.