Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Good name for a list variable in java [closed]

What of the following is used popularly or is the standard :

private List<String> names ; 

OR

private List<String> listOfNames ; 

OR

private List<String> namesList ; 
like image 334
Ace McCloud Avatar asked Jun 12 '12 12:06

Ace McCloud


People also ask

What is a good variable name in Java?

The name of the variable should begin with either alphabet or, an underscore (_) or, a dollar ($) sign. The identifiers used for variables must not be keywords. No spaces or special characters are allowed in the variable names of Java. Variable names may contain 0 to 9 numbers (if not at the beginning).

What variable names are acceptable?

A valid variable name starts with a letter, followed by letters, digits, or underscores.


1 Answers

Once upon a time we had Hungarian notation, because IDEs didn't provide intellisense and programmers were too dumb to realise that having a 30,000 line long block of code was unreadable*. Nowadays IDEs are friendly, programmers have started using small, neat classes, we have JavaDoc and things in genral are easier to read.

So, just name your variable for its usage. i.e. names. I'm no fan of pre/post-fixing variables as it often makes them harder to understand.

(*) i.e. Me, there's probably some deeply shameful code out there with my name on it.

like image 58
Jeff Watkins Avatar answered Nov 13 '22 14:11

Jeff Watkins