Let's imagine I have an abstract class named ProtocolA that represents the basic operations to work with the protocol A. Such protocol is in version 1, but new revisions are expected in the future. Version 2 is coming. How should I name the classes that implements that abstract class for each version? ProtocolA1 and ProtocolA2?


closed as primarily opinion-based by gnat, Bart van Ingen Schenau, user40980, World Engineer Apr 14 '14 at 3:11

Many good questions generate some degree of opinion based on expert experience, but answers to this question will tend to be almost entirely based on opinions, rather than facts, references, or specific expertise. If this question can be reworded to fit the rules in the help center, please edit the question.

  • This question appears to be off-topic because it is a "name that thing" question. "Name that thing" are bad questions for the same reasons that "identify this obscure TV show, film or book by its characters or story" are bad questions: you can't Google them, they aren't practical in any way, they don't help anyone else, and allowing them opens the door for the asking of other types of marginal questions. See blog.stackoverflow.com/2012/02/lets-play-the-guessing-game – gnat Apr 13 '14 at 14:36
  • I was just putting a childish example. I am asking for an acceptable namig convention for this kind of situations. – NullOrEmpty Apr 13 '14 at 14:45

If you won't need to support the original version ever again, then simply overwrite the class and keep the same name.

However, I suspect if it were that simple you wouldn't be asking.

I'm a big fan of unambiguous names. Does the protocol specification have a unique identifier? Something like an RFC number? If so, I'd name it something like ProtocolARfc2048.

I'd avoid a version number internal to your application, as that will get confusing.

  • Right, the former versions need to be supported. Including the RFC number is a great idea. I guess it changes from version to version, right? – NullOrEmpty Apr 13 '14 at 14:46

Use Factory(either factory method or factory object) to accept a version number(preferably enum, but string or numbers can also work) and construct the appropriate subclass. That way, naming won't matter that much since you'll never use them directly in the code.

As for the naming themselves, if your language has namespacing you can create a namespace for each version of the protocol and give classes the same name in different namespaces.

  • 1
    I gave that for granted. Even so, I would like to have a consistent naming so when I get an exception, I can see the implementation that is creating the trouble. – NullOrEmpty Apr 13 '14 at 15:45

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