About models and viewing interfaces

I am developing a WPF Prism application and everything is working fine. My view models have interfaces that are introduced by MEF.

However, I do not really understand the advantages of interfaces for view models. In the end, the view is tied to its presentation model, so I think there will never be other implementations.

Actually, I also have interfaces for my views. Seems like this too much?

So my question is: can I just remove all the view and view interfaces, and also directly enter the views and view the models? Is there any reason to support interfaces for viewing and viewing models?

thanks L

+7
source share
3 answers

Interacting with your VieWModels gives you the opportunity to mock them in the test, interacting with your views looks really somehow superfluous. You will not exchange your views, and user interface testing can be done on bullying your ViewModel, so you will not need to interact with them, I think.

+4
source

This is overkill. I understand that you can make fun of your ViewModels, but I think it is more important to be practical. Also, why did you even have to make fun of your ViewModels? Any logic that should be mocked should be placed in the IMHO service class.

+7
source

The biggest reason I can think of interfaces for ViewModels is that you can write mocks that implement these interfaces for use during unit testing. Since one ViewModel can talk with another, it allows you to disable the second ViewModels behavior during the first test.

The MVVM pattern simplifies unit test classes because it separates data and control from the user interface layer (for which it is more difficult to write unit tests). Personally, I did not write interfaces for my views.

+2
source

All Articles