Is there anything inherently wrong with long variable/method names in Java?

Posted by Doug Smith on Stack Overflow See other posts from Stack Overflow or by Doug Smith
Published on 2012-10-07T03:21:38Z Indexed on 2012/10/07 3:37 UTC
Read the original article Hit count: 170

Filed under:

I know this is probably is a question of personal opinion, but I want to know what's standard practice and what would be frowned upon.

One of my profs in university always seems to make his variable and method names as short as possible (getAmt() instead of getAmount) for instance.

I have no objection to this, but personally, I prefer to have mine a little longer if it adds descriptiveness so the person reading it won't have to check or refer to documentation.

For instance, we made a method that given a list of players, returns the player who scored the most goals. I made the method getPlayerWithMostGoals(), is this wrong? I toiled over choosing a way to make it shorter for awhile, but then I thought "why?". It gets the point across clearly and Eclipse makes it easy to autocomplete it when I type.

I'm just wondering if the short variable names are a piece of the past due to needing everything to be as small as possible to be efficient. Is this still a requirement?

© Stack Overflow or respective owner

Related posts about java