开发者

View model only for GUI?

开发者 https://www.devze.com 2023-03-03 02:51 出处:网络
I\'ve been looking at the ViewModel concept while w开发者_StackOverflow社区orking on a GUI component.

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消