Skip to content

radyalabs/Android-Java-Coding-Style

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 

Repository files navigation

Android-Java-Coding-Style

Radya Labs Android Java Coding Style

Introduction

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.

Scope

This coding guideline only apply to Android project and Java project in general.

Terminology and Definition

  • 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

Naming Convention

###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

  1. Always use PascalCase and camelCase for name of entity
  2. Never declare variables using only case letter difference. Give meaningful name
  3. Avoid use numeric suffix in name or identifier
  4. Always use meaningful and specific name
  5. Variables and properties should describe an entity, not type or measurement
  6. Avoid Hungarian Notation!. For example : strName or iCount
  7. Avoid using abbreviation
  8. Abbreviation only for common term and widely accepted
  9. Never use Java keyword for identifier
  10. Avoid use name that will be potentially conflict with Java SDK Class or Android Class
  11. Avoid redundant prefix or suffix that does not explain more about an identifier.

E.g :

public enum ColorsEnum { }
public class CVehicle { }
public struct RectangleStruct { }
  1. Avoid use parent class name in a attribute
Customer.name not Customer.customerName
  1. Try to add "can","is","has" prefix to boolean variable
  2. 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(){ 
	}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published