I'm writing a basic RPG at the moment, with characters, races, classes, and the characters evolve on maps, naturally.
How to go around the default names that exist in java.lang and java.util. I'm having a hard time trying to find equivalent names to the following RPG concepts that do not clash with Java basic utilities. Typically, the words Character, Class and Map cause me trouble. For instance this is how typically clashes would occur:
// Line 322, well below the imports
char[] characters = new String("foo").toCharArray();
Character character = new Character();
Map map = getMap();
Class heroClass = getDefaultClass();
// do stuff
In this example, it's hard to tell if Character is java.lang.Character or mygame.engine.Character. What type is Map? Can anyone answer without seeing the imports?
I could use the fully qualified name:
java.lang.Character c = new String("foo").toCharArray()[0];
mygame.engine.Character character = new mygame.engine.Character();
java.util.Map map = getMap();
mygame.engine.Class heroClass = getDefaultClass();
// Do stuff.
But in the long run, and from experience, this is barely readable.
So I'd like to know what are usual techniques and/or synonyms that people use to both avoid confusion and unreadable code.
I have personally thought of using the prefix Game, which will lead to using Game a lot of times: GameClass, GameCharacter, GameMap. I think this is meh, but I can get over with it if people say it's not so unusual.
I'm not asking opinions: I'm looking for alternatives, such as which synonyms are used and are clear enough, or other techniques that don't decrease the readability of the code.
public class Classis no problem \$\endgroup\$