Best practices in Android(安卓)development
16lz
2021-12-04
Do's and Don'ts for Android development, by Futurice developers
- Use Gradle and its recommended project structure
- Put passwords and sensitive data in gradle.properties
- Don't write your own HTTP client, use Volley or OkHttp libraries
- Use the Jackson library to parse JSON data
- Avoid Guava and use only a few libraries due to the65k method limit
- Use Fragments to represent a UI screen
- Use Activities just to manage Fragments
- Layout XMLs are code, organize them well
- Use styles to avoid duplicate attributes in layout XMLs
- Use multiple style files to avoid a single huge one
- Keep your colors.xml short and DRY, just define the palette
- Also keep dimens.xml DRY, define generic constants
- Do not make a deep hierarchy of ViewGroups
- Avoid client-side processing for WebViews, and beware of leaks
- Use Robolectric for unit tests, Robotium for connected (UI) tests
- Use Genymotion as your emulator
- Always use ProGuard or DexGuard
非常简短的17条经验,却又很实在的经验总结。
在开发时,我常常在想,如果大家能够遵守着规范,编码会越来越简单,维护成本及稳定性都会得到很好的把控。
事实上,能够坚守DRY(Don'tRepeat Yourself)的工程师也越来越少。你是否听过“先做出来,后面再重构。。。”,结果你看到的不是重构,而是继续在RY(Repeat Yourself)。
常常会因为一次RY,而不断在RY,数次RY之后,在面临着需求变更时,加班改BUG的开始。。。
一个优秀的项目,仅仅这17条还远远不够。以此共勉,快乐编码。
最后,感谢原作者的分享。
更多请关注原文:https://github.com/benniaobuguai/android-best-practices#use-gradle-and-its-recommended-project-structure
本文转至:http://blog.wo2b.com/?p=250
更多相关文章
- Android外派(安卓外派) — 长年提供安卓开发工程师外派业务(可签合
- 安卓外派(Android外派)提供安卓程序员外派业务(北京动点,可签合同)
- Android(安卓)模拟HTTP协议的编码问题 Android默认编码UTF-8
- 互联网徐金良:Android为什么能够超越iOS?
- 互联网徐金良:Android为什么能够超越iOS?
- Android中MediaMuxer跟MediaCodec用例
- Android(安卓)游戏开发的一些基础和经验
- Android(安卓)游戏开发的一些基础和个人经验
- Android为什么能够超越iOS?