Best Practice

Best practice is a method or technique or set of guidelines or ideas that represent the most efficient Solution. It is generally accepted as efficient to any alternatives because it produces results that are efficient and more easy to understand because it has become a standard way of doing things

Coding Standards

The coding standards are kind of similar as per Java language coding standards but We also need to follow some for Hybris Coding Standard.


Naming Conventions

We should follow naming convention as per SAP Hybris OOB(out of box) code.

  • Extensions : Extension names should only contain lower-case letters and be named according to their content. It is also common to use a project-specific prefix for all extensions of the same project.

  • Packages : Packages should be indicating the area of their content. For example: core, storefront, façade , and initialdata

  • Classes : Classes should use descriptive names, preferably in English. The name should be in CamelCase. Class names are declared in UpperCamelCase, with the first letter of each word capitalized.

public class MyHybrisFirstClass() {...}

  • Interfaces : SAP Hybris Commerce using interfaces name and implementation in below format

Default<Name of Interface> implements <Name of Interface>

  • Method : Method name should use descriptive and First letter of the method name is NOT capitalized, and follows the lowerCamelCase notation.

public void getMethodValue() {...}

public void setMethodValue() {...}

public boolean isMethod() {...}

  • Variable : Variable names also follow the lowerCamelCase notation. Variable names should have meaning, and should describe what they are being used for.

String myVariable;

  • Constant : Constants are declared in all upper-case characters, and their words are separated by underscores ("_").

MY_CONSTANT

  • CronJob : CronJob name should be end with "CronJob".

public class HybrisProductImportCronJob {...}

public class HybrisProductImportJobPerformable {...}