10

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.

2 Answers 2

20

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.

8
  • This sounds good. I'll think about it. Though in the place that these versions come together, we need to use fully-qualified name for the references, right?
    – user802421
    Commented Aug 12, 2011 at 14:32
  • How do they come together? Are you using dependency injection? Either way, to answer you question, yes.
    – Jeremy
    Commented Aug 12, 2011 at 14:34
  • They have many versions of data models that changes between releases. Some specific subsets of features are mixing together. No library support at all (e.g. no di, no codegen). This is history of 11 years software evolution :( .
    – user802421
    Commented Aug 12, 2011 at 14:51
  • Sad. Is it possible that by having version37.ThatThing extend version36.ThatThing would relieve some of the pain?
    – Jeremy
    Commented Aug 12, 2011 at 14:52
  • Unfortunately, they are structurally different and need complex transformation. It's like bitmap and vector graphic.
    – user802421
    Commented Aug 12, 2011 at 15:15
2

It doesn't matter a lot. Pick a convention that expresses everything you need it to express and stick with it.

You could use ThatThing3_6 for "That Thing 3.6".

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.