View model only for GUI?
I've been looking at the ViewModel concept while w开发者_StackOverflow社区orking on a GUI component. I like the idea that a ViewModel is kind of a subset of the complete Model, and that I can have different views into the Model. (And that the ViewModels are independent of the actual GUI View!)
Then I started thinking about if I could use the concept also for non-GUI modules. For example, integration components also may need a subset of the Model, and may have "bindings" and "events" in an abstract sense.
So, are there any thoughts about the abstract sense of ViewModels, not being limited to GUI? Or have I misunderstood the ViewModel concept? :-)
Thanks for any feedback!
ViewModel certainly could be applied to non-GUI work, though it might end up with a different name in that setting. Have a look at PAC for an extension of MVC in non-GUI settings.
ViewModels are usually called Data Transfer Objects when working with web services for instance.
. For example, integration components also may need a subset of the Model, and may have "bindings" and "events" in an abstract sense.
Sounds more like you want to use interfaces.
精彩评论