Java: variable names for directory path, variable naming in general

It's hard for me to decide what to name the file variable and the String variable, which both describe the same directory.

Basically, I have a line describing the location of the directory containing the test files. Using this line, I want to create a File object. Something like that:

String testcaseDirectoryPathString;
File testcaseDirectoryPath = new File(testcaseDirectoryPathString);

What I want to achieve is the most readable for my code, choosing good variable names.

I searched on the Internet, but in the end I found naming conventions in general and advice that variable names should be "speaking".

My question is about specific examples, but my problem is not only with String and File names, but also with good variable names.

So here are a few questions:

  • "String" String?

  • "" ?

  • ?

  • ?

- , , .

+4
3

:

  • String String?

, . , .

  1. "" ?

, nº1. .

  1. ?

, . :

" , , , , , ". - . .

, , , , .

  1. ?

, - , , , . , , .

String testcaseDirectoryPathString;

File testcaseDirectoryPath = new File(testcaseDirectoryPathString);

, :

String directoryPath;

File <<something that describe the result file>> = new File(directoryPath);

<<something that describe the result file>> - prizeRepresentations, annualSales ..

eclipse, checkstyle pmd, .

+3

"String" String?

, . , .


"" ?

, . . , : java.io.File java.nio.Path?


:

testcaseDirectoryPath testcaseDirectory
testcaseDirectoryPathString testcaseDirectoryName

+4

:

  • , /, , , . . businessRegulationSecondServiceFactoryInstanceFromASingleton? , , .
  • , IDE .
  • , , , "boolean notDisabled" "boolean enabled".
  • , - java , , .

https://softwareengineering.stackexchange.com/, . " " " "

+1

Source: https://habr.com/ru/post/1626134/


All Articles