lundi 9 avril 2018

Versioning of ViewModels

I have a View and a ViewModel. ViewModel not only takes care of View related presentation but also initiates business logic(workflow in our case). My software can talk to different versions of the firmware of the device.

Use Case 1: View Layout goes through Modification It may be required to display slightly different view when connecting to a different version, in that case, I create a new view and hook it up with a new view model.

This works well.

Use Case 2: View Remains Same but Underlying Logic Changes To understand this, let's say when software connects to a Firmware version(1.0.0) it is supposed to show a view with a checkbox and a Textbox and the Textbox need to be enabled only when the checkbox is checked. Now if Software connects to a different version of firmware(1.2.0) it is supposed to show the same view but now Textbox is not supposed to be enabled/disabled based on the checkbox check.

My questions are,

  1. Do I need to create a new View Model?
  2. Should I create a flag of some sort in the database(1.2.0) and use the same view model, so the logic in the view model first check whether the flag is present or not then it can decide to enable/disable controls.

Aucun commentaire:

Enregistrer un commentaire