Standards for Android Development

Asked

Viewed 832 times

3

Does anyone know where I can find the standards for Android development? Since:

  • Name of Views
  • Class name
  • Activities
  • Resources
  • see if this helps you.. Android nomenclature

  • I think these two pages will help you: https://source.android.com/source/code-style.html and http://petrnohejl.github.io/Android-Cheatsheet-For-Graphic-Designers/#naming-Conventions. Although they are standards for AOSP (first) should serve as V0

1 answer

2

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

As in @Wakim’s comment, there is a Java code recommendations article only.

You can follow the good tips of Patterns contained in this blog: http://www.androiddesignpatterns.com/archives/

Answering your question, I am Android developer for 4 years and from a while now I follow the following pattern:

  • View: If it’s like class, clone who you inherit first, then name what you do. For example, you made an Editext that when clicked, opens a Datepickerdialog, then a name for your custom Edittext could be Edittextdatepicker.

    For class names, this is very relative...

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

For example: Cadastroactivity, Listagemcadastrosactivity ...

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

For example, if your class responsible for the encapsulation of a listing procedure inherits from Asynctask, you can name it Listrcadastrosasynctask.

If your class is a utility class, it can be suffixed with the word Useful.

For Resources, you should think about using them via code, that is, prefixes that assist 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 referring to 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 it would be: ic_action_.

Then you put what he does: ic_action_register

If your icon is icons specific to a screen for example (just as an example)

You can call ic_cadastro_activity_pessoa.

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

For example, if a drawable file starts with the prefix Shape_, you know that it is for background, coloring and setting spacing in a View for example.

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

Here comes the rule I said upstairs about the way noema to facilitate use via code.

That’s why for all icons that you search via code for this screen, just type the prefix: ic_cadastro_activity_ and several suggestions will be displayed only for this prefix.

This issue of unique icons for screens rarely occurs and the explanation above was only to understand the ease in choosing well the prefixes.

I believe that this desired pattern is you who creates, because the community has not yet defined it well and we follow examples from Google. But always think of the best form of organization for you.

This way should help you as your project grows, as the organization of the classes in the packages, the nomenclature of your files, everything that can facilitate the use.

Think hard about this issue of working together with the Ides' suggestion feature, as nomenclature helps with this.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.