Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Is there two kinds of ViewModel or just one? #1

Closed
GSala opened this issue Dec 26, 2017 · 3 comments
Closed

Is there two kinds of ViewModel or just one? #1

GSala opened this issue Dec 26, 2017 · 3 comments

Comments

@GSala
Copy link

GSala commented Dec 26, 2017

I was just working on a similar architecture when I ran into this boilerplate. So far I think it's great and it completes a lot of the thoughts and inner dilemmas I was having.

One particular problem I keep running into comes down to what the responsibility of the ViewModel is. As in here, the architecture component ViewModel (presentation layer *1) is responsible for receiving Ui events and return Ui states. On the other hand, models from other layers get mapped to another kind of ViewModel (UI layer *2) which is only a representation of the data to be displayed.

  1. BrowsBuferoosViewModel.
  2. BuferooViewModel

In my project I'm using databinding and so I bind the UI layer ViewModel to list item layouts, for example. In the case of the whole screen, I bind the activity/fragment instead of the presentation layer ViewModel. But I know a colleague binds the layout directly to the presentation layer ViewModel and might have a RecyclerView adapter directly in the VM.

Would you agree with me that the two kinds of ViewModel I mention are different? Or do you consider them the same? If they are different, shouldn't we find a better naming for one of them?

@hitherejoe
Copy link
Collaborator

Just one sorry, the second on the list is the data class.

That's my bad though for naming it that, i'll get that fixed!

@GSala
Copy link
Author

GSala commented Jan 3, 2018

It's good to know you think of them them as two completely separate things. What are you going to name it then? In my opinion the "ViewModel" name for the data representation of a view makes sense.

Considering the blog post you wrote about data model mapping, it'd be reasonable to have an API Model, a Cache Model and ultimately a View Model. And so I would say that the ViewModel naming chosen for the architecture components is not really a great fit and should be renamed. I just can't find a name that clearly represents what it does.

@piotrek1543
Copy link

@GSala I think that the second class could be named as BufferooUiModel or BufferooItemModel :-)

@GSala GSala closed this as completed May 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants