When is a Java method name too long? [closed]

In the last weeks I've seen some guys using really long names for a Method or Class (50 characters), this is usually under the premise that it improves readability, my opinion is that a long name like this is an indicator that we are trying to do a lot or too much in a method class if we need such a long name, however I wanted to know what do you guys think about it.

An Example is:

getNumberOfSkinCareEligibleItemsWithinTransaction

Solution 1:

A name in Java, or any other language, is too long when a shorter name exists that equally conveys the behavior of the method.

Solution 2:

Some techniques for reducing the length of method names:

  1. If your whole program, or class, or module is about 'skin care items' you can drop skin care. For example, if your class is called SkinCareUtils, that brings you to getNumberOfEligibleItemsWithinTransaction

  2. You can change within to in, getNumberOfEligibleItemsInTransaction

  3. You can change Transaction to Tx, which gets you to getNumberOfEligibleItemsInTx.

  4. Or if the method accepts a param of type Transaction you can drop the InTx altogether: getNumberOfEligibleItems

  5. You change numberOf by count: getEligibleItemsCount

Now that is very reasonable. And it is 60% shorter.

Solution 3:

Just for a change, a non-subjective answer: 65536 characters.

A.java:1: UTF8 representation for string "xxxxxxxxxxxxxxxxxxxx..." is too long for the constant pool

;-)