View-First or ViewModel-First

Topics: Getting Started
Apr 4, 2012 at 9:06 AM
Edited Apr 4, 2012 at 9:06 AM

Hi there, let me first start by saying that I do *not* want to start a war.... Merely, I want to gather some opinion on whether Caliburn.Micro is considered more orientated towards View-First or ViewModel-First development, or whether they are (like God said) created equal!?

If someone knows of a good place that discusses the Pros/Cons of both in detail, that would also be very useful! At the moment myself and the other developer are not in agreement about how best to proceed, I think we should use VM-First, he V-First. Before we make a decision either way, I'd like to make sure that I know all the facts.

Is there any difference in the amount of resources available for one over the other? Is there more documentation? Samples? etc.

Apr 13, 2012 at 2:48 PM

Nobody!?

Apr 13, 2012 at 2:58 PM

Honestly, it is more or less a matter of tastes... well, view-first was the only route some time ago for Silverlight/WP7 applications, but it is not anymore.

Personally, I prefer the view-model-first approach, since I tend to structure my applications bottom-up: start with functionalities and use Views as skins for them. Moreover, I often design my applications to be extensible through plugins and such, so I tend to have a view which is heavily driven by a view-model.

Using a view-first apporach, the view-model would be deduced once the view is already in place, nevertheless part of the extensible application would require a prior knowledge over a view-model (or equivalent object), so in the end I would end up with a view-model first approach anyway at some point...

Finally, I find quite hard to deal with dynamic skinning (or structural skinning) using a view-first approach. Just my opinion, anyway...

Apr 13, 2012 at 4:32 PM

Thanks, I appreciate the response!

Apr 16, 2012 at 6:02 PM

If have the same opinion as BladeWise. For my point of view, it feels more "natural" to use ViewModelFirst.
Unfortunately I never used ViewFirst, so I can't really compare. But comparing other code with ViewFirst (and without caliburn, by the way) I find
my code much more clear to read and understand.

With ViewModelFirst you would still have the possibility to adjust some public properties before View will be shown.
That's very convenient, as I find. With ViewFirst you probably have to catch the DataContext, then cast it to the ViewModel
and then you could change such properties. For me you have to spend time and effort without getting additional advantage.

 

Apr 17, 2012 at 2:48 PM

I can think of lots of scenarios where a View-First implementation will have difficulties; for example, imagine you develop an app that has an online and offline mode. When running online, the main screen should display a webpage of the latest company news and a twitter feed, if offline, it should display some static information that gets updated with each release of the program.

View-Model first makes this easy, the main screen could have a content control called "InfoPane" and the main screen view-model loads the appropriate view-model into the corresponding public "InfoPane" property based on a logic decision.

How could you even do this View-First? Am I missing something?