-1

I'm designing a game engine that is supposed to be overridden. I have, for example, a class called Character. Should I prefix this with BaseCharacter or should I expect that whoever uses the framework prefixes their classes with GameNameCharacter or CharacterGameName?

What would be most convenient to you?

closed as primarily opinion-based by gnat, Robert Harvey Apr 22 at 4:10

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.

1

No, just use the simplest name that makes the role of the class obvious in the context of your framework. You don't have to bother with such “smurf naming”, or adding words like “Base”, “Abstract”, “Impl”, …

If a user of your API wants to use the same name as the name of the class in your API, they can import your class under an alias.

The exception here is Java, since Java does not offer any mechanism for type aliases or namespace aliases. You can either use the short class name, or its globally unique fully qualified name (which can get rather lengthy). In Java I'd totally add a prefix to the public classes/interfaces of my library to reduce name clashes with user code.

  • Hey :). Thanks for answering :). Actually, I'm targeting Java as well. Let's assume my engine has KL as acronym. So, using the Character class example I gave above, which is a quite common word, I should rather say KLCharacter, so that anybody using my framework can create their own Character based on KLCharcter. – Axonn Apr 21 at 13:41
  • Additionally: even if the target language offers aliasing functionality, do you consider it is tidy to ask of users to use such features? Just trying to see what's best to do :). Won't it be cleaner to name my base classes properly so that the end-users aren't affected regardless of language? – Axonn Apr 21 at 14:48
  • 3
    @Axonn KLCharacter would be fine in Java, I'd argue. But please avoid such names otherwise. E.g. in Python it's completely normal to use a namespace alias import full.name.of.the.library as kl so that the class can be named as kl.Character. It's then unnecessary and even unhelpful to add a prefix to the name itself. – amon Apr 21 at 15:03

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