Hey programmers , this article is not about some java related feature or concept but more than that . Basically I’m going to explain what all mistakes a java developer does while writing the code and hence how you can minimize it and you don’t have to refactor your code .So this article is about BEST PRACTICES a developer should always follow .

1. What’s there in the name :

A developer should always try to give a meaningful name to the variables, methods and classes . It becomes too easy to understand what the method or class or variable is about when some one reads your code while reviewing it or debugging it. Giving name like a ,b,c to variable do not intent any meaning and becomes less relevant while debugging the code .

  1. Always start the name of a class with upper case .Eg.
public class Employee {

}

here **Employee **is class name and other developers can easily understand that this class deals with employee related stuff.

2. Always start a variable name with lower case .Eg.

private int salary;

here **salary **tells about salary of employee .

3.Always start method name with lower case and do not include And and Or words in method name .Eg.

public int calculateSalary(int noOfDaysWorked , int baseSalary)

4. Write constants in upper case and separate them with under score .Eg.

public final int RETIREMENT_AGE = 58;

Note : do not use special symbols while writing variables ,methods , constants or classes names .

#programming #best-practices #code-review #java #coding

How to write clean code ? follow these best practices for writing clean code
1.75 GEEK