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 namin
In general the best way to name android application components is to add its "component type" as suffix. Example :-
LevelActivity
(LevelActivity extends Activity)InboxUpdateService
(InboxUpdateService extends Service)ContactsContentProvider
(ContactsContentProvide extends ContentProvider)SMSBroadcastReceiver
(SMSBroadcastReceiver extends BroadcastReceiver)By naming using above method there will be minimal chances of losing track when you're working on big code flow with lots of similar names in your application.
So, name your Activities with suffix "Activity".
And name the Class which provides Data to your LevelActivity as Level
.
In Contradiction to second part of Pascal MARTIN's answer, you can also use LevelActivity
and LevelInfo
together. Because they offer clear difference as quoted below:
Distinguish names in such a way that the reader knows what the differences offer - Robert. C. Martin, author of Clean Code
But the suffix are often redundant on cognitive basis. Using only the word Level
clearly emphasises that class Level
offers information about Level.
So, use Level
for class that provides data about Level.
NOTE : If you're using suffixes, choose one word per concept.
For Example: If you're using the suffix Info
to identify classes that offer information then only Info
should be used (not Data
or Model
) throughout your application to avoid confusions.