New Posts New Posts RSS Feed: Verification and MVVM
  FAQ FAQ  Forum Search   Calendar   Register Register  Login Login

Verification and MVVM

 Post Reply Post Reply
Author
midnit View Drop Down
Senior Member
Senior Member
Avatar

Joined: 22-Jun-2009
Location: Charlotte
Posts: 112
Post Options Post Options   Quote midnit Quote  Post ReplyReply Direct Link To This Post Topic: Verification and MVVM
    Posted: 10-Mar-2011 at 5:50am
Where does your verification fit into MVVM? Well, yes I know it sits on the M...but if your not binding to the properties of M how else does it fit in? Currently I am doing my own validation checking and raising via INotifyDataErrorInfo in the VM which is exposing simple properties which are backed by data obtained from the M.
 
I have not seen much value in using the verification but perhaps I am missing something. I was under the impression I would have to attach to the entity events to bubble them(verification errors) up through my VM - is this correct? Please enlighten me.
Back to Top
midnit View Drop Down
Senior Member
Senior Member
Avatar

Joined: 22-Jun-2009
Location: Charlotte
Posts: 112
Post Options Post Options   Quote midnit Quote  Post ReplyReply Direct Link To This Post Posted: 17-Mar-2011 at 4:17am
tap...
 
tap...
 
tap...
Back to Top
midnit View Drop Down
Senior Member
Senior Member
Avatar

Joined: 22-Jun-2009
Location: Charlotte
Posts: 112
Post Options Post Options   Quote midnit Quote  Post ReplyReply Direct Link To This Post Posted: 17-Mar-2011 at 4:44am

I will add to this since no one has responded.

I see the validation at the model level to be very base level validation. It cannot handle all the validation that the UI would need and I don't believe it should (or could) know enough to perform validation based on business or security logic. Any validation that occurs on the model should only be validation that can be applied across any use of that model which either means you don't reuse the model much (or any) or you have few validation points in your model.
 
Then when I add the fact that I don't like binding the V directing to the M even through an exposed property on the VM - so any validation raised on the M now has to be routed on up. This adds a little complexity but nothing to worry about. Then if the VM has a few of its own validations to perform you may need to manage the display of the various sources of the validation sent to the V.
 
I realize not everyone needs the complex validation that my apps do and for drag-n-drop simplicity it seems like (and is) a quick and easy solution but maybe I am over-thinking this or missing a piece of the puzzle.
 
The above is my opinion which is based on the apps I have personally developed.


Edited by midnit - 21-Mar-2011 at 4:01am
Back to Top
kimj View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 09-May-2007
Posts: 1278
Post Options Post Options   Quote kimj Quote  Post ReplyReply Direct Link To This Post Posted: 18-Mar-2011 at 5:55pm
Hi Robert.  Sorry that no one responded to your first post, I think it got lost among some other problems last week.
 
Your questions are actually good ones to send directly to Ward, since he loves to talk theory.  :-)
 
If you're not binding directly to any entity properties then you're right that you're not benefiting from validation on the model itself.  At least not for displaying validation errors within the UI.  Validation on entities is still performed on the server by default, however, and actually for security purposes you probably do always want this validation to be performed and to have it be fairly thorough.  You can't rely upon UI validation alone in a secure application.
 
You can also use the VerifierEngine and DevForce verifiers on any type of object, not just an Entity.  So you can use it directly in your ViewModels if it would help manage the validation process. 
 
We've got several samples which use MVVM in various flavors and also make use of DevForce validation.  If interested, you can find  them here - http://drc.ideablade.com/xwiki/bin/view/Documentation/DevForce-MVVM-Patterns
Back to Top
midnit View Drop Down
Senior Member
Senior Member
Avatar

Joined: 22-Jun-2009
Location: Charlotte
Posts: 112
Post Options Post Options   Quote midnit Quote  Post ReplyReply Direct Link To This Post Posted: 21-Mar-2011 at 4:43am
Thanks for the response kimj. I actually did send Ward a question but never got a response - which led me to a post here. I have seen no reason to change what we are doing and what we have works well so I'm in no rush.
 
When you said "You can't rely upon UI validation alone in a secure application" I can't agree more but I wasn't sure if you were implying that the VM is also UI validation. The VM (at least in this case) is on the client and therefore subject to attack and for that reason alone I question making the model more knowledgable but then that still means having validation to maintain in two domains which is also distasteful. Fortunately in our case our current applications are all internal.
Back to Top
kimj View Drop Down
IdeaBlade
IdeaBlade
Avatar

Joined: 09-May-2007
Posts: 1278
Post Options Post Options   Quote kimj Quote  Post ReplyReply Direct Link To This Post Posted: 21-Mar-2011 at 8:38am
By "UI validation" I'd meant that the client application itself is insecure and that you'll also need validation on the server.  In DevForce, validation on entities in the model is performed on the server by default during the save.  Since you're writing internal applications, security is less of a concern and you do have more leeway in structuring validation to meet your needs.  It sounds like the validation you require is more in the "business logic" realm than simple property-level validation too.
 
Ward has been swamped but things should be settling down this week, so if you'd still like to engage him about this give him another ping.
Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down