This project has moved and is read-only. For the latest updates, please go here.


DM-V-VM Question



The DotNetPad project is of particular interest to me, I think its the best example of AvalonEdit and Roslyn available in the public domain. It's fast and it works. Understanding how it's put together, on the other hand, is another matter entirely. While I have not worked with the DM-V-VM pattern before I was very eager to learn about it when I started into this. But that's fading.

I am confused about.. well a number of things but in particular, and maybe you can help me to understand, in your diagram the DataModel is a binding target from the View, View Model and Controller (and can talk back to the controller through events), but nowhere is there any mention of the DataModel being able to communicate directly with a View Model. Yet, in the DocumentDataModel you have a Lazy<T> instance of the CodeEditorView Model that is referenced by the FileService in the Shell View Model. There's a lot of cross referencing going on here and I will admit that I'm finding the implementation of this model in dnp to be quite complex and a little difficult to follow. It's a small demo app, is such complexity necessary to demonstrate the model and framework? I doubt there would be many developers who would easily grasp what's going on in there coming from an MVVM background. I'm at a point now where I just want to flatten the whole thing into an MVVM pattern just so I can understand what's going on. Please don't take this as criticism, if the model is implemented as per your design then I stand corrected. It's just not obvious to me at this point.

Am I mistaken about the DataModel referencing the CodeEditor View Model?

Thanks for any advice you can offer.

Kind Regards



jbe2277 wrote Sep 6, 2015 at 8:04 PM

Thank you for the feedback.

You are right about the wrong design in the DotNetPad application. The DocumentDataModel is not allowed to refer the CodeEditorViewModel. This way I have created a circular dependency between ViewModels and DataModels.

I will fix this design issue.

wrote Dec 3, 2015 at 8:58 PM