Naming is a personal preference. A name is ideal if the name indicates what the functionality of a certain thing is. You and any other developer using these definitions should also know what the names mean and which definition to choose. Pretty easy if you agree with the names throughout the project.
For example, dark_blue is obviously blue, and text_highlighted is the color of the selected text. The name that you should use depends on what you need: if you want to classify colors by their name, take the first, if you want to abstract from the actual color, take the second. For general layouts using text_highlighted will often make more sense, since the actual color does not matter, and the functionality is more important (text highlighting and regular text, etc.). In this example, the choice between text_highlighted and text_regular much more obvious than the choice between color_light_blue and color_dark_blue , although they may all refer to the same color. A name can help prevent mistakes.
Android uses prefixes for names in [ android.R.drawable ] (http://developer.android.com/reference/android/R.drawable.html), for example:
btn_ for button graphicsic_ for icon graphicsic_menu_ for menu iconsic_dialog_ for dialog icons
stat_ for status icons
The scheme, of course, is not perfect, but the advantage of using prefixes that begin with the most general classification is that you can use code completion to search for specific elements step by step. Thus, color_blue_dark may be better than dark_blue_color , at least if you think the color classification is more important than the dark / light classification. The same applies to first_time_prompt . If you have a lot of prompt , it makes sense to call them prompt_first_time , promt_other_time , ... if they can be classified by activity, for example, which can be used as a supercategory: mainactivity_prompt_* , secondactivity_prompt_* , so that you know what they belong to.
source share