Android 最佳实践

2019-12-11  本文已影响0人  張小明

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

Separation of Concerns (SoC):使用architecture pattern,MVP或者MVVM

MVP:

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:

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

上一篇 下一篇

猜你喜欢

热点阅读