https://auth0.com/blog/best-practices-in-android-development/
语言:
如果可以,使用kotlin
Null safety.
Smart inference.
Interoperability with Java.
It can be compiled to JVM bytecode or JavaScript.
Design Patterns:
Dependency Injection
- Constructor injection - where the dependencies are passed through the constructor.
- Field injection - where dependencies are sent to the class fields directly, etc.
Separation of Concerns (SoC):使用architecture pattern,MVP或者MVVM
MVP:
- The View: this is the part that displays content to the user such as a progress bar, dialogs, etc.
- The Model: this is responsible for providing data to the app whether from the DB or a web-service. This should be your single source of truth (data).
- The Presenter: this part handles the business logic, like calling the Model to get data, and then updates the view.
User Experience
Excellent UI
A lovely feel and experience of an app starts with a good design. Be sure to get one that matches the Google material design principles. Some of these principles include:
- Providing an Up navigation button.
- Consistency in color combinations.
- Use of proper icons to portray functionality, etc.
Handling Configuration Changes
使用viewModel
https://developer.android.com/topic/libraries/architecture/viewmodel.html#java
Respect the UI thread
耗时操作一定要放在后台线程执行
Compatibility 兼容适配
Create alternative resources
创建可选择的资源文件,如不同设备的layout以及drawable
或者使用矢量drawable
Security & Privacy
Communicate Securely with a Server
加密传输
Permissions
使用动态权限
Data Storage
使用内部存储保存敏感数据
Performance
Manage Objects Properly
懒加载
Square has an open source library called LeakCanary that helps us to track memory leaks in our app
跟踪内存泄漏
使用profile
使用contraintlayout
网友评论