Mvp in practice
37
MVP In Practice MVP, OOP and Unit test
Transcript of Mvp in practice
About meAndroid developer 2 years+
Name: 洪彥彬
Gitbook: https://www.gitbook.com/book/hungyanbin/android-unit-test/
Github: https://github.com/hungyanbin
Contract1. 在實作前就先要定義好 → DIP2. 定義 View 跟 Presenter 職責
3. Contract 應該要看不到 Android framework 的元件(Bundle, Context)4. 有關 Android Framework UI 元件,都在 View 實作中解決
5. 有關 Android Framework 非 UI 元件,都在 Model 實作中解決
Bad smell1. 透露實作細節
2. 違反DIP(Dependency Inversion Principle)3. 依然沒有與 Android Framework(StringRes) 分開,而且使用integer來代表字串
不太合理4. 滿滿的技術債
可能會遇到的實務困難
1. Presenter 與 Model 的職責不好決定
2. Presenter : View 是一對一?多對一?多對多?
3. 與 Android Framework 切不乾淨
4. 不會寫單元測試