Enter your E-mail Address below for Free E-mail Alerts right Into your Inbox: -

Thursday

10 Best programming Practices for Java Naming Conventions

10 Best programming Practices for Java Naming Conventions

Each and Every Programmer are well and best in coding, are they aware of how to code and how the naming conventions must follow.There are best practices and bad practices. Best practices are the one that has to be followed while coding and bad practices are the that has to be avoided while coding. Best Coding reflects your ability in programming. Best Naming Conventions increases the readability and the software quality. These are common regardless of the Programming language. Java, C++,.Net all should follow the naming Conventions.

Java Naming Conventions for Variables,Methods,Class etc...

These are the Naming Conventions came across years of programming practices. lets look at some of the Naming Conventions.

  1. Give Meaningful Names:
                                                Always give names that are meaningful and related to the program. It allows easy understanding of the need for the variable and use of this variable. eg:- joiningDate. if it's given jDate, it's not able to easily understand. it can be followed for variable names,Class,methods and packages.

2. Prefer shorter names rather than longer one:
                                                                               You should prefer shorter names rather than longer names. If it's shorter then it's easy to read and understand.

3. Follow Java Naming Conventions:
                                                              Java also provides some naming conventions. for example here are some of the naming conventions.  Class name should start with Uppercase letter. ex:- Employee. Variables should start with lowercase letter and second word should be uppercase letter(CAMEL CASE). Constants are all Upper Case letters. ex:- MAX_LIMIT.

4. Avoid Pointless Names:
                                             For example variables like abc,temp, etc. It's a bad programming practice.

5. Follow Classical Programming Convention:
                                                                             As already mentioned Pointless Names are bad programming practices. But you can use simple variables like 'i' , 'j'.

while(i<n)
{
n++;
}

                                                                  
6. Avoid Clusters in Programming:
                                                         For example "_test" etc are need to be avoided.you should use meaningful and unique names.

7. Avoid Duplication:
                                    Avoid usage of similar names. For example employee and employees are same but it will leads to complication. These are encountered while code reviews.

No comments:

Post a Comment