Android Development Standards

3

Does anyone know where I meet the standards for Android development? From:

  • Views Name
  • Class Name
  • Activities
  • Resources
asked by anonymous 24.12.2014 / 10:38

1 answer

2

There is no Google article telling you how to rename your Resources files.

As in the @Wakim comment, there is a Java code recommendation article only.

You can follow the good patterns tips contained in this blog: link

Answering your question, I've been an Android developer for 4 years now and a while back, I follow the following pattern:

  • View : If it is as a class, who knows who inherits first, then the name of the person who does it. For example, you made an EdiText that when clicked opens a DatePickerDialog, so a name for your custom EditText could be EditTextDatePicker .

    For class names, this is very relative ...

If your class is an Activity, always end its name with Activity, as Google does.

For example: CadastroActivity , CadreActivity Listing ...

Generally, I put the class name starting with what it does then the name of who it inherits, if inheriting from Android classes (except for the case of Widgets / Views).

For example, if your class is responsible for encapsulating a listing procedure inherit from AsyncTask, you can name it as ListCastersAsyncTask.

If your class is a utility class, you can suffix the word Util .

For Resources, you should consider using them via code, that is, prefixes that help you when using code to simplify the suggestion given by the IDE when typing.

That is, for icons, you should always start with the prefix ic _

Then you put another word for the type of this icon.

For example, if this icon is a menu icon that appears in ActionBar or another menu, the next word will be action .

Then you would: ic_action _ .

Then, you put what it does: ic_action_drive

If your icon is an own screen icon for example (for example only)

You can call ic_cadastro_activity_people.

For Drawble files, for example, you can prefix the name of the highest level TAG, because it allows you to know what that file does.

For example, if a drawable file starts with the prefix shape _ , you know it's for background, color, and set spacing on a View for example.

If your file starts with selector or layer_list you know it will serve as a ringing tone in some view and so on.

Here comes the rule I said up there, on how to noema to make it easier to use via code.

That's why for all of the icons you are fetching via code for this screen, you simply enter the prefix: ic_cadastro_activity_ and several suggestions will be displayed only for this prefix.

This issue of display-only icons rarely occurs, and the above explanation was just for you to understand the ease of choosing prefixes well.

I believe that this pattern is what you are creating because the community has not defined this well and we have followed examples from Google. But always think of the best form of organization for you.

This form should help you as your project grows, such as the organization of classes in packages, the very naming of your files, everything that can facilitate the use.

Think hard about this issue of working together with the suggestion functionality of IDEs, as nomenclature helps.

    
26.12.2014 / 04:17