komizo
komizo

Reputation: 1061

According to MVVM: are Services part of Model component or ViewModel?

I would like to know if Services used in MVVM are part of a Model or ViewModel component. I met with opinion that they are part of a Model since they are used as a way of extracting Model data. Then they are used via Dependency Injetion in ViewModels.

Unfortunatelly I also met with opinion that they should be in same namespace as ViewModel. Do you know good resources or any argument that could defend one one above opinion.

Upvotes: 1

Views: 301

Answers (1)

MoonKnight
MoonKnight

Reputation: 23833

This is a matter of opinion and as such the question is likely to be closed. Having said that, your answer IMO is neither. Services should typically be contain in a *.Services namespace and separate from both. You may have a "Service" that lists the available Views and a separate service to list the available ViewModels. In addition, you may have a Service that does something completely different, not involving either Views or ViewModels. My advice is not to get hung up on this...

Upvotes: 4

Related Questions