Android开发之单词缩写笔记

好命名胜于任何注释
51CTO/至简李云

编程过程中使用单词缩写可以提高效率,本文则记录 Android 开发中一些常用的缩写。

标识符命名也是讲究基本规则的:

  • 拒绝按照拼音命名,比如 String caidanming; // 菜单名
  • 拒绝比上者更甚的做法——使用拼音缩写,比如 String cdm; // 菜单名
  • 除了约定俗成的缩写,尽量不要自造,这样会增加别人阅读代码的成本
单词 缩写 示例
array arr String[] titleArr
asynchronization async
attribute attr AttributeSet attr
background bg int bgColor
buffer buf byte[] buf = new byte[1024]
button bt / btn Button btUpdate
char ch
configure conf / config
context ctx Context ctx
control ctrl
current cur long curTime
database db String dbName
default def int def
delete del delUser()
description desc <string name="about_desc"></string>
directory dir File dirFile
document doc
error err int errCode
horizontal horz int horzLen
icon ic ic_download.png
image img int imgId
implement impl class UserDaoImpl implements IUserDao {}
index i / idx int idx
information info getInfo()
initial init init()
length len for (int i = 0, len = list.size(); i < len; ++i) {}
library lib ./app/libs/
maximum max final int MAX_LEN = 100
memory mem getMemSize()
message msg String msg
millisecond millis long timeMillis
minimum min final int MIN_LEN = 1
number num int num
object obj Object obj
package pkg getPkgName()
parameter param
password pwd psd String pwd
picture pic int picNum
position pos int pos
process proc Process proc
property prop
rectangle rect rect()
request req
resource res int resId
response res
second sec long timeSec
select sel
source src
string str String dateStr
summary sum int sum
synchronization sync
system sys
temporary tmp / temp String tmpStr
text txt
user usr getUsrName()
utility util class DateUtil {}
version v / ver getVerCode()

笔者会在开发过程中不断回头添加。如果发现错误或有所补充,欢迎留言。

最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容

  • Android 自定义View的各种姿势1 Activity的显示之ViewRootImpl详解 Activity...
    passiontim阅读 173,477评论 25 708
  • 1、引言 数据库设计过程中表、字段等的命名规范也算是设计规范的一部分,不过设计规范更多的是为了确保数据库设计的合理...
    SnowflakeCloud阅读 41,108评论 0 48
  • 请看完结版:Android开发规范(完结版)
    Blankj阅读 8,629评论 25 115
  • 教练工具第三讲作业 李双双VS颜叮(死党) 1、教练:这是怎么了,愁眉苦眼的。 张平:我的主管陈明上班老是迟到,屡...
    颜叮阅读 215评论 0 0
  • 心渔著。 文笔平实,无甚出彩之处。因为听说是慢热文,也不怎么急,慢慢看着。 故事架空在一个以乐师为尊,音能杀人的时...
    路茗阅读 3,267评论 0 0