android10 / android10/Android-CleanArchitecture

Models for list view item and detail view

未關閉
#169 6 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視
discussion question
主要語言
Java
星號
15.5k
分支
3.3k
PR 合併指標
30 天內沒有已合併 PR

描述

I'm fetching some data from 3rd party library to access their API.

For example, i created two use cases(FetchUserList and FetchUserDetail) to fetch user list and user detail.
The user list will be displayed in recycler view but only the user name part. And in user detail view, user name and company name will be displayed.

The model received from the server(API model, as in the library) as follow:

```
class User {
String name;
Int companyId;
...
}

class Company {
Int id;
String companyName;
...
}
```

What model should i create in my domain layer?

Should i create two models, one for the fetch user list use case and another one for fetch detail use case?

Seems the result model will be dictated by the view, in recycler view i don't need company name(exclude unnecessary data), but in the detail view i need to display more data.

I'm thinking something like below, but in the user list view case i do not need the `Company` data

```
class UserModel {
String name;
Company company;
}
```

What would you suggest?

Thank you.

貢獻指南

這個儲存庫沒有索引到貢獻指南

評估

這個 Issue 還沒有評估資料。

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。