These are the basic steps which are preferred while writing a code to make it more clear, readable, clean and efficient.
Code Reusability : Create reusable methods/functions instead of replicating the same code everywhere. If the code has nothing to do with service layer, then a Util Class can be created which will contain such kind of methods.
Declare all the variables in the beginning so it will be easy to find and modify.
Use proper naming conventions i.e. method names, variable names as per the Objects or on the basis of their purpose of creation.
Create Java Doc for a method in which the purpose of the method creation should be written as well as author name, creation date and parameters used.
Instead of writing all the code in a same function/method , use small methods and assign them different responsibilities and use them.
Avoid using hardcoded values directly, instead make a constant file which will be having all the hardcoded values.
Use a proper code formatter to make your code more readable and pleasing to eyes.
Comments