Java Naming – Java Class Version Specific Naming Conventions

javanaming

I have to create an Adapter between two software (mech. simulation, non-cs). Assuming we have a class named ThatThing. I have to handle various vendor specific implementations. These versions don't have meaningful names (unlike eclipse helios, indigo etc.).

1. How should I name a class that should express version number?

I find class like ThatThing_3_6_Impl, ThatThing_3_7_Impl quite awkward.

Best Answer

Use a different package name.

com.example.version36.ThatThing
com.example.version37.ThatThing

This allows you to keep all the "things" for specific versions together.

Apache Commons Lang used this format when releasing their "version 3" rewrites.


Since you need to be able to reference both version in a single class, I would shorten the names to:

ThatThing36
ThatThing37

In your case, this seems to be descriptive enough, and it removes the ugly Impl and _'s.

Related Topic