Skip to content
LeeCampbell edited this page Nov 26, 2012 · 11 revisions

Talking to my sage adviser (Dr.J) XAML is here to stay (in finance).

  • Most banks are just moving to Win7 now, they wont want to move again for 3 years.
  • This means Windows for 3 more years (i.e. no OSX/Google/Win8)
  • If they do move to OSX/Google then they will largely need a rewrite. Most UI is in .NET from what I see
  • If they stay with windows they keep all the AD/LDAP, security and UI infrastrucutre
  • With this in mind, I think it is high time for a critical review of MVVM and how it was supposed to be done, how it can be done, and how it should not be done.

M V VM

From scratch : M is Model, V is for View, VM is for ViewModel.

  • Consider the advice from Prism Guidance http://msdn.microsoft.com/en-us/library/gg405484(v=pandp.40)
  • If the "Model" does not contain any use case behaviour, I would argue it is not a model at all. "Use" before "re-use".
  • This leaves the ViewModel with responsibilities for Concurrency, Validation, Notification and Logic. hmmm.

View

  • Simply the "coat of paint" over the ViewModel.
  • Presentation concerns
  • A view is a control. This does not mean all controls are views. Try to make controls as generic as possible, whereas views are specific.
  • Hottip: If you need/want code-behind, then it probably should be a control.

ViewModel

  • Concurrency and ViewMapping. It knows WPF things like dispatcher and ICommand
  • Concurrency concerns
  • Allows for independently testing Concurrency concerns from domain concerns
  • A VM wraps the model.
  • Many VMs may be injected with the same Model. Use scoped containers to facilitate segregation
  • A VM may be injected with multiple Models. For example Personalisation is a seperate concern that should belong in a model seperate to the Business domain.
  • We not requried to use MVVM triples. We should be solving the Business problem and the UI problem. Some cases we can leverage the same Model, sometimes we cant. We should think critically about this, we dont have to blindly build MVVM triples.

Model

  • Domain concerns
  • Includes aggregate roots and Value types (Model+Enties for Logic)
  • Math - Pricing (discounts, tax, payments etc), days to a birthday, Aggregates
  • Logging
  • Security (Authentication, Authorization and Auditing)
  • Validation (IDataErrorInfo(All) & INotifyDataErrorInfo(SL4+/4.5) are in System.ComponentModel in the System.dll)
  • INPC is not a WPF specific thing. Models can implement it. (in System.ComponentModel in the System.dll)
  • Single threaded to reduce complexity in the domain concern. (Concurrency is dealt with in VM, parallel is a Service concern). Need to be aware of looping over Collections in Model that can be modified by VM (i.e. in different thread). This leads us to recommend passing snapshots of data to the model.

DDD

  • Entities
  • Value objects
  • Services
  • Modules
  • Aggregates
  • Factory
  • Repositories
  • Domain events
  • Sub Patterns
  • Specification
  • Side-effect Free
  • Declarative
  • Sub domains
  • Bounded Context
  • Context Map
  • Shared Kernel
  • Anti Corruption Layer
  • Segregated Core
  • Abstract Core
  • Pluggable Component
  • Layers (Reposonsibility Layers in system design)
  • Integration concerns*
  • Repository for Caching, Mapping and finding the data possibly via a ServiceClient or DAL.

Application design concerns

Responsive Apps.

  • Dispatcher, STA applications
  • Rx
  • New ObserveOn operator:
  • Ideally be able to Journal?
  • Takes the time the item is recieved (ie. .Timestamp()) then logs the delay until it is processed (only in debug. Potentially with a tolerance level ie. only delays over 100ms are logged?)

Logging vs. Journaling vs. Auditing vs. Instrumentation

  • Usefull stats
  • App start (Who (userID) what when(DateTime&UTC) where(Dir and Working dir) why how(Parent process?)
  • Current state (preferences, windows, vms etc)
  • Threads, Handles, Memory (Private, Managed, UnManaged), CPU usage - Collected periodically
  • Events (system initiated) and Commands(user initiated) with payload
  • Visualizing Flows from logs e.g. http://www.logsequencer.com/

Deployment

  • Deployment WPF/Silverlight/Metro/Javascript?
  • Click-Once and partial updates
  • Signed applications (with partial updates)
  • Versioning. Ideally we want side-by-side versioning or version tolerant contracts, but at what cost?
  • Assembly version vs Service versioning (e.g. Google v3)

For a discussion point, consider all of these concerns; where do they belong?

  • Colors/Gradients/Glow effects/Mouse over etc
  • Responsiveness
  • Logging
  • Journaling
  • Simple math
  • Complex match
  • Security (AAA)
  • Validation
  • Caching (for performance)
  • Batching for IO performance
  • Instrumentation
  • Change notification
  • Personalisation/Settings management (column order/width, colors, sounds etc...)

Also consider,

  • how can I continue coding when the servers/network/DB/IntegrationPoint is down?
  • how can I run the app without all the features I dont care about (or make the app so fast it does not matter)
  • how do I deploy the app
  • how do I change a configuration, without recompiling, and have that change audited