Thursday, 1 March 2012

Android Naming Conventions

                         



The android naming convention is same as java naming convertion.

This Naming conventions are very important thing to follow while develop best android applications.

Four things we need to concentrate while naming in android

1) Wheather it is a noun or verb.
2) Proper use of Characters.
3) No empty spaces are allowed.
4) Avoid using dollar($) symbol.

Package    * Package name should be noun
                   * Package name should be lowercase letters
                   * Package name must be seperated with periods(.dot)

Example:   com.android.shopping
                 com.bank.account

Class        * Class name should be noun
                 * Class name should Initcap.
       
Example:   AccountHolder, AccountType


Interface    * interface name should be noun.
                   * interface name should Initcap.

Example:    DataHelper, AccountName

Method     * method name should be verb.
                  * starts with lowercase continue with InitCap

Example:    processAccount(), getUserDetail(), diaplayUserDetails()

Variable       *Variable name should be Meaningful and verb.
                     * starts with lowercase continue with InitCap
                     * for local variables like for , while can use lowercase(i,j,k).
                     * Allow dollar($),underscore(_)symbols.underscore is always recommended.

Example:    buttonSubmit, edit_Text_UserName,  _strTotal

Constant           * Constants always in uppercase
                         *  Underscore(_) is permittable

Example:    HEAD_COUNT, MAXIMUM_SIZE


Control Structure


Even for single line statement we need to surround by block {}.This is for best practice.

Example:

Poor usage
        if(true)
        Statement;

Good usage
        if(true)
        {
        Statement;
        }

Comments 

  Put comments before doing anything in program. It make us better understanding when see it again.


1 comment: