TMS Aurelius and MVVM design

TMS Aurelius and MVVM design

I've written a two-part post about how to use TMS Aurelius ORM in MVVM.

Have a look if you are interested. As always, comments, ideas and suggestions are greatly welcome.

Thanks.
http://www.kouraklis.com/2017/01/tms-aurelius-and-mvvm-design-an-example/

Comments

  1. I commented on this because it seems in the Delphi world there seems to be a fundamental misunderstanding what MVVM is all about - maybe it is because of the way Delphi works (heck, I would not want to do MVVM with WinForms either) - I don't know. And to be honest, one of the reasons why I did not spend any further time on this subject in the past is because it is frustrating to implement in Delphi - I rather use some MVP variation.

    If you need the view in order to let different viewmodels communicate to each other then you are doing it wrong. Let's take TFormMain.ButtonAddClick as example. Since the view knows the viewmodel since we are using a non binding version (otherwise this would be done via commands bindings) it would simply call fViewModel.AddNewCustomer and maybe some fViewModel.RefreshView or similar. In your code this view not only knows its viewmodel but also the model and the view and viewmodel for the add operation. All that is creating couplings in your code that MVVM is trying to avoid. It is irrelevant for the main view what happens when doing the AddCustomer operation because that is implementation detail of the viewmodel. If that decides to perform a login, security checks or asks the user for some captcha (all those could be other viewmodels and views when they require user interaction) - it does not know it just triggers an action and in this case waits for it and then updates the UI (again, the typical MVVM application in frameworks that support databinding dont even need that because they have notification mechanisms under the hood that automate that).

    If you are using Aurelius, mORMot, Marshmallow or some ini file as datasource for your customers is completely irrelevant for MVVM. If anything of your backend is dictating anything on the UI layer - something is wrong.

    ReplyDelete
  2. Stefan Glienke I agree about the comment for fViewModel.AddNewCustomer and how the communication should be done between the VM and the View. As I said, the focus of the post is not to write a sophisticated example for the pattern but how Aurelius can possibly fit in the structure.

    "If you are using Aurelius, mORMot, Marshmallow or some ini file as datasource for your customers is completely irrelevant for MVVM.">>That's true and it can appear in a model or can be further abstracted.

    ReplyDelete
  3. John Kouraklis. "If you do MVVM without databinding (which is one of the main aspects of MVVM in many implementations)..." > That is true but keep in mind that many people don't feel comfortable with the LiveBindings in Delphi and avoiding databindings requires more background work..."

    You have the option to use TAureliusDataset for the binding.

    ReplyDelete

Post a Comment