c# - Composition Root in MVVM DDD application -


so, answer should pretty simple: mark seemann wrote here:

a composition root (preferably) unique location in application modules composed together. ( ... ) in wpf applications it's application.onstartup method

i'm not sure onstartup method though. let's have application consisting of these projects dependencies:

domain <- app services <- wpf client (viewmodels pcl <- executable wpf client views)

mvvm pattern says business logic should proceeded in viewmodel. (edit: ahh, put in wrong words:/ meant is: when have business logic (in domain) in class game, , has method move returns true if move finished game - don't need game in view. need command - movecommand , game in viewmodel. , view should know command ). view should know command, viewmodel has performed. basically, view should know viewmodel. knowledge domain useless in view.

so question is: mvvm approach should take?

  • i want keep best practices , create every object in composition root
  • i want have business objects in view models, not in view

is viewmodel-first (or mvvmc) approach work?

mvvm pattern says business logic should proceeded in viewmodel.

this 1 wrong. never put business logic viewmodel. viewmodel presentation, presentation logic goes in here (input validation, controlling when , element gets displayed or hidden , commands exist user execute on event or wire domain objects, similar inside controller actions in mvc).

business logic part of domain , should never leave domain.

viewmodels prepare data of domain (model layer; m of mvvm) view consume it.

i want keep best practices , create every object in composition root

application.onstartup still right place it, since application layer (in n-tier terms) layer knows (viewmodels, model, domain , infrastructure) , can application specific configuration there, example adding iuserrepository sqlserveruserrepository on desktop , sqliteuserrepository on uwp app, since sql server isn't available there.


Comments

Popular posts from this blog

Delphi XE2 Indy10 udp client-server interchange using SendBuffer-ReceiveBuffer -

Qt ActiveX WMI QAxBase::dynamicCallHelper: ItemIndex(int): No such property in -

Enable autocomplete or intellisense in Atom editor for PHP -