string - Java: variable names for a directory path, naming variables in general -
i'm having difficulties decide how name file variable , string variable, both describe same directory.
basically have string describing location of directory containing testcases. string want create file object. this:
string testcasedirectorypathstring; file testcasedirectorypath = new file(testcasedirectorypathstring);
what want achieve readability code, choosing variable names.
i searched internet, end finding naming conventions in general , advice variable names should 'speaking'.
my question specific examples, problem not string , file naming choosing variable names in general.
so here questions:
is practice add word 'string' string object?
is practice add word 'path' file object?
is matter of personal preference , there no practices?
how name variabls , why?
if there articles out there, appreciate pointing me them.
it's opinion:
- is practice add word 'string' string object?
no, doesn't contribute. make name longer without reason adding type in name.
- is practice add word 'path' file object?
same nÂș1. don't need type in name of variable.
- is matter of personal preference , there no practices?
always need follow practice coding make legible, have in mind:
“always code if guy ends maintaining code violent psychopath knows live.” - john f. woods.
and important thing, try allways follow company naming standards, maybe aren't best make code rideable.
- how name variabls , why?
i try name variables short names, specifying important , following lower camel case using english working in spanish company not mandatary. , said following company naming standards.
string testcasedirectorypathstring;
file testcasedirectorypath = new file(testcasedirectorypathstring);
if don't have directory path maybe use this:
string directorypath;
file <<something describe result file>> = new file(directorypath);
with <<something describe result file>>
means prizerepresentations
, annualsales
, etc...
off record if use eclipse can see plugins checkstyle , pmd, have clean , clear code , used work way.
Comments
Post a Comment