Lou*_*rda 5 android mvvm android-architecture-components
另一个“哪个更好”的问题,我知道这些都是主观的。我更好的定义是:
所有Android蓝图均按功能打包:
https://github.com/googlesamples/android-architecture
/tasks
/addedittask
/taskdetail
Run Code Online (Sandbox Code Playgroud)
以及所有体系结构组件样本均逐层使用:
https://github.com/googlesamples/android-architecture-components
/db
/model
/ui
/persistence
Run Code Online (Sandbox Code Playgroud)
我很困惑,因为在Architecture Components网站的底部,它实际上具有指向Android MVP和MVVM蓝图示例的链接,在我看来这是矛盾的。
基于Android 架构指南和Clean Architecture,我建议采用这种方法
data/
model/
remote/
local/
Repository
domain/
usecases/
GetUserListUseCase
presentation/
screen1/
screen1Activity
screen1Fragment
screen1ViewModel
screen2/
screen2Activity
screen2Fragment
screen2ViewModel
core
common/
di/
Run Code Online (Sandbox Code Playgroud)
更多信息请参见:https ://www.toptal.com/android/android-apps-mvvm-with-clean-architecture
我认为这取决于项目规模。不同公司的团队也使用不同的方法。
我更喜欢在小型项目中使用第二种类型的包管理。
如果你想重用ModelView组件,只需将它们放在功能包中即可。也许用这种类型:
/db
feature1/
feature2/
/model
feature1/
feature2/
/ui
/persistence
feature1/
feature2/
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
495 次 |
| 最近记录: |