Radya Labs Android Java Coding Style
This document is describe guidelines and recommendations when developing Android application. Our main goal is to define a consistent format and style for every source code produced by all Radya Labs developer.
This coding guideline only apply to Android project and Java project in general.
- PascalCase : Every first word begin with UpperCase. Ex: TextView
- CamelCase : First alhabet using lowercase and every first word begin with uppercase. Ex: myTextView
- AllUpperCase : All alphabet using uppercase. Ex: SEAT_SIZE
- AllLowerCase : All alphabet using lowercase. Ex: com.radya.controller
###Overview
- Project File : PascalCase
- Package : AllLowerCase
- ClassFile : PascalCase
- Class : PascalCase
- Struct : PascalCase
- Interface : PascalCase
- Enum : PascalCase
- Enum Attribute: AllUpperCase
- Method : CamelCase
- Attribute : CamelCase
- Constant : AllUpperCase
- Static Attribute : AllUpperCase
- Parameter : camelCase
###General Guide
- Always use PascalCase and camelCase for name of entity
- Never declare variables using only case letter difference. Give meaningful name
- Avoid use numeric suffix in name or identifier
- Always use meaningful and specific name
- Variables and properties should describe an entity, not type or measurement
- Avoid Hungarian Notation!. For example : strName or iCount
- Avoid using abbreviation
- Abbreviation only for common term and widely accepted
- Never use Java keyword for identifier
- Avoid use name that will be potentially conflict with Java SDK Class or Android Class
- Avoid redundant prefix or suffix that does not explain more about an identifier.
E.g :
public enum ColorsEnum { }
public class CVehicle { }
public struct RectangleStruct { }
- Avoid use parent class name in a attribute
Customer.name not Customer.customerName
- Try to add "can","is","has" prefix to boolean variable
- Add "Average,Count,Sum,Min,Max" in a certain variable that reflect aggregation
###Name and Syntax
Project File
package
Try use AllLowerCase and name that match project title.
Class
Try use PascalCase. Use noun or noun phrase for class. Add suffix or part of parent class for child class
public class Customer { }
private struct ApplicationSettings { }
Interface
Try use PascalCase.
public interface OnClickListener
{ }
Method
Try use CamelCase.
public String getName(){
}