Code Convention
2016-01-25 17:00
453 查看
Classes
1. When you extend existing well-known class, attach the parent class name as suffix.
e.g.) When making a fragment for community feature: CommunityFrgment.java
2. If you are making abstract class, attach Base as suffix,
e.g.) Abstract base class of fragment which will be used in Galaxy Care: FragmentBase.java
3. Class name should be like XxxYyyy
Variables
1. When you declare instance variables of well-known classes, attach the class name as suffix.
e.g.) Declaring TextView variable for decstription: descriptionTextView
Decalring ImageView for icon: iconImageView
2. When you declaring member variables, it may be protected, private.
the member variable should be started with underscore.
e.g.) Declaring member variable for icon image: private ImageView
_iconImageView;
3. Static final member variable should be all uppercase.
e.g.) Declaring static server url: private static final String _SERVER_URL = "...";
4. Variables name should be like: xxxYyy
Codes
1. Always use braces even when only one line in the loop or if-else.
e.g.)
if(a < 0) {
a = 0;
}
2. If you use collections like Map, List, etc., I encourage you to set it final and initialize it in the member.
e.g.) private final Map<String, String> _nameJobMap = new HashMap<>();
3. If possible declare as most possible abstract interface as type.
e.g.) private Map<String, String> _nameJobMap = new
HashMap<>();
private List<String> _nameList = new ArrayList<>();
1. When you extend existing well-known class, attach the parent class name as suffix.
e.g.) When making a fragment for community feature: CommunityFrgment.java
2. If you are making abstract class, attach Base as suffix,
e.g.) Abstract base class of fragment which will be used in Galaxy Care: FragmentBase.java
3. Class name should be like XxxYyyy
Variables
1. When you declare instance variables of well-known classes, attach the class name as suffix.
e.g.) Declaring TextView variable for decstription: descriptionTextView
Decalring ImageView for icon: iconImageView
2. When you declaring member variables, it may be protected, private.
the member variable should be started with underscore.
e.g.) Declaring member variable for icon image: private ImageView
_iconImageView;
3. Static final member variable should be all uppercase.
e.g.) Declaring static server url: private static final String _SERVER_URL = "...";
4. Variables name should be like: xxxYyy
Codes
1. Always use braces even when only one line in the loop or if-else.
e.g.)
if(a < 0) {
a = 0;
}
2. If you use collections like Map, List, etc., I encourage you to set it final and initialize it in the member.
e.g.) private final Map<String, String> _nameJobMap = new HashMap<>();
3. If possible declare as most possible abstract interface as type.
e.g.) private Map<String, String> _nameJobMap = new
HashMap<>();
private List<String> _nameList = new ArrayList<>();
相关文章推荐
- RPC failed; result=22, HTTP code = 411
- gosyd/go1.6.slide at master · davecheney/gosyd · GitHub
- Windows Server 2008 Code "Longhorn" Beta 3 提供下载
- dedecms v5.1 WriteBookText() code injection vul注入漏洞
- 在C#中生成与PHP一样的MD5 Hash Code的方法
- Live Write 的代码高亮插件 Paste Code
- ERROR CODE: 1175 YOU ARE USING SAFE UPDATE MODE AN
- IIS7.5 Error Code 0x8007007e HTTP 错误 500.19的解决方法
- Microsoft Windows Server Code Name"Longhorn"Beta 3 正式发布! 下载
- Microsfot .NET Framework4.0框架 安装失败的解决方法
- Windows 下Spark 快速搭建Spark源码阅读环境
- Leanote集成Ace代码编辑器, 程序员的最爱
- 好代码是廉价的代码
- Optimizing Java Code(Pro Android Apps Performance Optimization)
- data,bdata,idata,pdata,xdata,code存储类型与存储区bit
- Writing Efficient Android Code(转)
- 常见HTTP状态(304,200等)
- 转:关于keil中data,idata,xdata,pdata,code的问题
- PowerDesigner中,修改column的name和Code同步问题
- eclipse添加注释模板