Best practices in Android development

Do's and Don'ts for Android development, by Futurice developers

  1. Use Gradle and its recommended project structure
  2. Put passwords and sensitive data in gradle.properties
  3. Don't write your own HTTP client, use Volley or OkHttp libraries
  4. Use the Jackson library to parse JSON data
  5. Avoid Guava and use only a few libraries due to the 65k method limit
  6. Use Fragments to represent a UI screen
  7. Use Activities just to manage Fragments
  8. Layout XMLs are code, organize them well
  9. Use styles to avoid duplicate attributes in layout XMLs
  10. Use multiple style files to avoid a single huge one
  11. Keep your colors.xml short and DRY, just define the palette
  12. Also keep dimens.xml DRY, define generic constants
  13. Do not make a deep hierarchy of ViewGroups
  14. Avoid client-side processing for WebViews, and beware of leaks
  15. Use Robolectric for unit tests, Robotium for connected (UI) tests
  16. Use Genymotion as your emulator
  17. Always use ProGuard or DexGuard

 

非常简短的17条经验,却又很实在的经验总结。

在开发时,我常常在想,如果大家能够遵守着规范,编码会越来越简单,维护成本及稳定性都会得到很好的把控。

事实上,能够坚守DRY(Don't Repeat 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)