I try to name a class (also members, properties and so forth) as exact as I can. But sometimes I’m not sure if this is so clever if the class name becomes huge (50 chars and mor
50 chars is pushing the large end of class names but is not inconceivable. As far as Java is concerned the max limit for the fully qualified class name (includes package) is 2 bytes.
In the wild, the Spring libraries are notorious for long class names. For example, the class AbstractTransactionalDataSourceSpringContextTests comes in at 49 characters. This provides unit testing with the injection of spring beans (SpringContextTests
); data source injection (DataSource
); tests are transactionally aware (Transactional
); the class in question is abstract (Abstract
).
Trying to squeeze that into less than 49 chars would be a challenge. This info could be provided in the documentation instead, but for classes that use/extend this class that would not be immediately obvious. This may reduce the understanding for developers reading your unit tests, so there is definitely a tradeoff here that you will have to think about.