I'm running into more and more naming clashes between Android activities and other classes. I was wondering if you could tell me how you avoid these. Sadly, my particular naming problems are not covered in the related questions on SO.
First example
I have an activity that displays a level of the game. However, the data required for that level (background artwork, entities etc.) is stored in a separate class. Naturally, I would call the latter class Level
. However, I would call the activity Level
as well, because it displays levels.
Second example
I have an activity that plays back a cut scene. It basically displays several images in a row. The information which image is shown for how long is stored in a separate class. As in the previous case, I would naturally call both classes CutScene
.
How would you solve these naming issues? Name the activities LevelActivity
and CutSceneActivity
? Name the representation classes LevelModel
and CutSceneModel
? Something else?
I solve those problems by either prefixing or postfixing classes with their "type", like you suggested at the end of your question :
LevelActivity
, GameActivity
, MainActivity
, ...CommentsListAdapter
, ...CheckNewCommentsService
, ...But I generally do an execption for the model classes, which are the objects that contain that data : I would still name my Level model class Level
, and not LevelModel
, to indicate I'm manipulating, and working with, a Level.
Another solution (longer to type ^^) might be to use fully-qualified names (see here) when referencing your classes :
com.something.yourapp.activity.Level
com.something.yourapp.model.Level
With this, you always know which class is really used.