The following practices are used for identifier names throughout the library, and also the various Android app projects from this organization. Note that, in many cases, in which only one object of a given type appears in a block of code, the prefix just is the variable identifier. Otherwise, the prefix appears as part of some innerCamelCase identifier that includes a semantic name for the variable.
These identifiers are related to variables containing simple values — primitives, or the wrappers for those primitives.
Prefix | Meaning | Actual Types | Examples |
---|---|---|---|
b |
A Boolean entity — either true or
false . Could refer either to a primitive boolean
or a Boolean wrapper object.
|
|
|
c | Any single character. |
|
|
mask |
Any int or long that is being used as a
bitmask, rather than as a numeric value. This prefix is a
reminder that the integer primitive should not be used as a number.
|
|
|
n |
An unsigned integer — that is, a number which is expected to be
≥ zero. The letter choice refers to the mathematical notation ℕ
for the set of natural numbers. Since Java does not include
built-in enforcement of signed vs. unsigned integers, this prefix is used
to remind a human developer that the value is expected to be always
greater than or equal to zero. Further, it is common to use negative
values in these variables in order to track error conditions or other
special circumstances, such as setting -1 to mean "not yet
initialized".
|
|
|
r | A floating-point decimal number of any precision. The letter choice refers to the mathematical notation ℝ for the set of real numbers. |
|
|
res |
The integer constant referring to an Android resource ID.
While the underlying data type is always int , it is generally
useful to denote any integer entity that is known to carry a resource
identifier.
|
|
|
s | A simple string. |
|
|
ts |
A long integer value which holds a Unix timestamp.
This value will typically be obtained from a Date or
Calendar instance, or from some Android OS function which
give time values as a long integer of milliseconds.
|
|
|
y |
A byte. This letter choice was forced because b
already stands for "Boolean". Usually used only as part of an array of
bytes while processing raw binary data, e.g. ayBlob .
|
|
|
z |
A signed integer — that is, a whole number which might be less than,
equal to, or greater than zero. The letter choice refers to the
mathematical notation ℤ for the set of all integers. Since Java does
not include built-in enforcement of signed vs. unsigned integers, this
prefix is used to remind a human developer that this value is
expected to range across the entire integer set, in contrast to the
n prefix above.
|
|
|
The prefix o
is used for any nondescript Java object, but using
this for every non-primitive identifier would be pointless. Thus, several
Java classes, Android classes, and other "types" or objects get their own
specific notational prefixes.
Prefix | Meaning | Actual Types | Examples |
---|---|---|---|
act | Any activity instance. |
|
|
bind |
A Binder to a Service . Typically,
this prefix just is the identifier, since a function will generally
not refer to more than one Binder at a time.
|
|
|
btn | A Button appearing in the UI. |
|
|
cfg |
Any instance of the Android OS
Configuration class, or an
instance of any other class that represents some sort of "configuration"
in abstract.
|
|
|
cls |
A Class instance. Classes are frequently
passed around as hints to generic/template parameters, or used by any
feature that depends on Java reflection.
|
|
|
conn |
Any object that represents an open connection to something,
like a database or a Service .
|
|
|
crs |
A Cursor on a database result set.
|
|
|
ctor |
A constructor discovered via Java
reflection.
|
|
|
ctx | A Context . |
|
|
db |
An instance of a database, such as a
SQLiteDatabase .
|
|
|
dbh |
A database "helper" class, which provides
access to a database, such as any descendant of
SQLiteOpenHelper . This is the class which typically serves as
the API between the database connection and the rest of the app.
|
|
|
dia | Any instance of a dialog in the UI. |
|
|
fld |
A Field discovered via Java reflection.
|
|
|
filter | An IntentFilter (for a receiver). |
|
|
frag | A Fragment . |
|
|
hndl | A Handler implementation. |
|
|
infl | Any Android UI "inflater". |
|
|
info | Any of several Android standard classes that represents or contains a discrete structure of information provided by an Android OS service or sensor. |
|
|
json | A JSON object, usually produced by Gson. |
|
|
l | An instance of a listener. These are generally referenced within the localized context of a method, and thus often have no semantic name following the prefix. The type of "listener" is dependent on the object that provides it. |
|
|
lay | A Layout for the app's user interface. |
|
|
lens |
(library-specific) Any instance of a class which implements
Refractor and/or extends Lens as
part of the SQLiteHouse feature.
|
|
|
loc | Any object representing a location or locale. |
|
|
map | Any Map , such as a HashMap |
|
|
mgr | Any of the various Android classes that is a "manager" of some system component. If the context of the manager is obvious from the method, or there is exactly one manager in scope, then the identifier might not have a semantic name, but typically the name will also indicate which manager has been obtained. |
|
|
menu | A Menu in an app UI. |
|
|
mi | A MenuItem in an app UI. |
|
|
mth |
A Method discovered by Java reflection.
|
|
|
pcl | A Parcel . |
|
|
prefs | A reference to the application's preferences, or any object which can be used as an API to access those preferences. |
|
|
proc |
Any class to which the app's logic for processing data is
confined. Typically, such a "processor" class would be bound to a
Service and a BroadcastReceiver , both of which
would feed incoming signals (such as Intent s) into the
processor via its public methods.
|
|
|
qctx |
(library-specific) (deprecated) A
QueryContext instance,
describing the context of a SQLite query in progress, as part of the
SQLiteHouse feature.
|
|
|
rcv | A BroadcastReceiver . |
|
|
rng |
Any instance of Random . The prefix choice here reflects the
most common use of the class, which is as a random number
generator. Typically, this will be declared as a static
constant to be used by the class that needs it, and will thus appear as
RNG instead.
|
|
|
sb |
Any StringBuffer or
StringBuilder instance used to
accumulate a string value.
|
|
|
sched | Any class that is used to schedule tasks to be executed at certain times or intervals. |
|
|
sig |
An Intent — that is, a signal received by
the current context.
|
|
|
spin | A Spinner control in the app UI. |
|
|
srv | A Service instance. |
|
|
task | Any class representing a task to be run on a separate thread. |
|
|
timer | A Timer . |
|
|
uri | Any object representing or containing a URI. |
|
|
vals | A ContentValues instance. |
|
|
w |
Any View . Additional crumbs might be appended
to the prefix to indicate a view type, such as tw for
TextView .
|
|
|
x | Any Exception . |
|
|
These are related to a class member's role within its class, and are prepended before any other prefixes related to type or usage.
Prefix | Meaning | Examples |
---|---|---|
m_ |
The entity is a member of a class instance. The prefix could
be read by a human as "my" and alleviates the need to use the
this keyword to disambiguate the member from a local
variable with a similar name.
|
|
s_ | The entity is a static member of the class. Note that static constants do not generally carry this prefix; they are named with ALL_CAPS_WITH_UNDERSCORE_SPACES instead. |
|
Similar to a meta-prefix, these prefixes denote collections of entities, and are prepended before any of the other notational characters in the identifier name.
Prefix | Meaning | Actual Types | Examples |
---|---|---|---|
a | Any array, list, or other similar linear collection. |
|
|
v |
A Vector . Vectors are special, and worth
distinguishing from other collections, for their thread-safety, and the
specific functions provided by that class.
|
|
|