本次翻译的是five.agency.android的博客文章。
原文链接:Android Architecture: Part 1 – Every New Beginning is Hard
本次翻译不照搬原始文章中的每一个单词,原文请跳转链接!
艰难的开始。
It’s easy for a young developer without guidance to make a monster instead of an app.
通常,新社区很小,并且在开发人员之间进行知识转移的潜力有限,也就是说,由于尚无可用的体系结构指南,每个人都在从错误中学习。
这个时候简单掌握一点就能编写出一个东西,但这不是程序,而是怪兽。
like this:
遵循的标准
- Satisfy a multitude of stakeholders.
- Encourage separation of concerns.
- Run away from the real world (Android, DB, Internet…).
- Enable your components to be testable.
I. Satisfy a multitude of stakeholders.
Stakeholder is any person interested in the development of your app. Besides developers, there are UI designers, UX designers, PMs, DB admins, QA, etc.
通俗理解说,不管是UX、UI、QA、PM、etc,总之,当对项目有属于他们自己的诉求时,这个诉求就是利益相关,这时候,你或者开发人员可以轻松的进行测试、修改、更新等等不管什么操作,关键在于这些操作不能影响到另外的诉求,除非它们本来就是矛盾的。
like this:
II. Encourage separation of concerns.
满足利益诉求这一点是对于团队组织和项目阶段的一个映射,它是关注点分离的一个例子,但是比较特殊。
而通常较为普遍的,还是对于组件、模块等等方面,这些关注点需要注重单一责任原则。
总之,改变一个关注点的唯一理由:就是只能自己改变自己,并且不能影响别人。
III. Run away from the real world (Android, DB, Internet…).
感觉应该是 Hide the real world 更好理解一点,Run away from… emm, i don’t realy get it.
“ Your architecture should scream the purpose of the app. ” —— Uncle Bob.
Business logic should be clearly separated and independent of the framework.
We want to emphasize business logic and leave framework details under the hood, but this point should be even stronger:
- we would like to not only hide framework details but all the details related.
总之,Hide all details. All the Android stuff like sensors, notification mechanisms, screen details, database access, Internet access, etc.
IV. Enable your components to be testable.
- 尽可能对应用程序进行单元测试
- Hide the real world 有利于做到上面这一点。
- 如果业务逻辑与应用程序的其余部分明显分开,则测试业务逻辑会更容易。