Organizing your Source File

2016-06-22  本文已影响13人  jockerMe

Android应用应该使用被以一种简洁的文件结构组织,使你的代码更容易阅读。此外,合理的代码以及类命名规则是非常重要的,以确保你的代码整洁易于维护


Naming Convention

Java Code

Type Example Description
Variable incomeTaxRate All variables should be camel case
Constant DAYS_IN_WEEK All contants should be all uppercase
Method convertToEuroDollars All methods should be camel case
Parameter depositAmount All parameter names should be camel case

For Android Classes

Name Convention Inherits
Activity CreateTodoItemActivity AppCompatActivity,Activity
List Adapter TodoItemsAdapter BaseAdapter,ArrayAdapter
Database Helper TodoItemsDbHelper SQLiteOpenHelper
Network Client TodoItemsClient N/A
Fragment TodoItemDetailFragment Fragment
Service FetchTodoItemService Service,IntentService

Android Folder Structure

上一篇 下一篇

猜你喜欢

热点阅读