mercredi 16 octobre 2019

MVVM - Model-ModelView and Services-Model layers

I wonder how to split layers of MVVM project properly. For sure i will have to include Service/Business Layer because of a lot of stuff doing there and UI will be relatively simple.

  1. Can Services be included into diffrent ViewModels or one service should be only included in one ViewModel ? f.e. If i have functionality of text parser which should operate in some UserControls across application - In this matter, is this parser called Service and i can use it in diffrent ViewModels ?

  2. Simmilar question to Models - can one ViewModel include different Models as its fields? Or Model Class should include all fields for according ViewModel ? I think i can use some Models in one ViewModel, please point me on right direction.

  3. Should I use Services and Models in ViewModel or only Models in ViewModel?

  4. Is data flow from example below correct ? F.e. User clicks/changes something in View, a Command or Binding is called in ViewModel which runs service and returned Value updated fields of ViewModel based on Model ?

  5. Should Events be treated as model in matter of placing them in project structure ? I mean, to place all events classes in /Models/Events or just /Events folder ? Also it comes to naming: should i use SomethingHappenedEventModel or SomethingHappenedModel or SomethingHappenedEvent ?

If i'm not understandable, please hit me with some questions. I can provide code examples :)

Aucun commentaire:

Enregistrer un commentaire