Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it against Java conventions to name an object the same as the class name, sans the capital?

If I have an object Mode, would it be acceptable, according to common/standard conventions, to call the variable mode? While I was bringing up a hypothetical situation during my CS class (high school), my teacher interrupted me to ask why I would call an object the same name as the class, without the capital? (This is very much taken out of context, but my hypothetical situation was irrelevant to this.)

Also, I already understand that if my teacher says something like this, I should generally just do it to conform to her desired conventions. I am just wondering if in general, it is acceptable.

like image 643
Nathan Avatar asked Nov 30 '22 13:11

Nathan


1 Answers

I think this is completely fine. This is normal practice. Class instances are most of the time named same but start in lowercase.

General naming pattern is to name the classes and variables with little descriptive names to increase the readability and maintainability. As long as naming is self explanatory, its fine.

like image 103
Yogendra Singh Avatar answered Dec 15 '22 21:12

Yogendra Singh