Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why java method name should not contain underscore?

Tags:

java

pmd

I am using PMD for checking java coding violation. I am writing automation test cases, and given method name like this:

public void testCaseMethod_4_2_16(){
   //some implementation 
}

where 4_2_16 is test case number 4.2.16

and when I check for PMD violation it is showing method name should not contain underscore, and this violation is shown as blocker according to PMD rules. So here are my question:

  • Why method name should not contain underscore is define as a blocker or PMD error?
  • What kind of PMD violation we should avoid and
  • What kind of violation we should try to fixed?

As for my understanding at least we should avoid first two level of violation shown by PMD. Any help on the PMD rule will be appreciated. thanks

like image 380
Sanjay Avatar asked Dec 06 '22 02:12

Sanjay


1 Answers

It is a standard that has been set so that people can easily read each other's code, therefore making code more maintainable.

The quote below is from Oracle's website on Java code conventions:

  • 80% of the lifetime cost of a piece of software goes to maintenance.

  • Hardly any software is maintained for its whole life by the original author.

  • Code conventions improve the readability of the software, allowing engineers to understand new code more quickly and thoroughly.

like image 105
Jean-Louis Mbaka Avatar answered Dec 13 '22 01:12

Jean-Louis Mbaka