![]() ![]() ![]() So other than the ugly SetError method which takes in a string for a control name, I think this isn't bad. Each folder would be a layer in your application (or split across multiple assemblies): Here's the class diagram for all the classes in the system:Īnd here's how the classes break down in the solution. It's fairly simple but the sample has been broken down a bit further hopefully to help you understand the pattern better. This just runs through each error object in the DTO through a method to check the error:ĥ8 if ( _claim. If it does, it sets the response message (mapped to a textbox in the UI) and calls a method called indicateErrors. The Notification object is an object embedded in the Data Transfer Object, which is passed into the service when it's created so our service layer has access to the DTO to register errors as it does it's validation.įinally coming back from the service layer, the presenter checks to see if the DTO's Notification object HasErrors. Here it checks the various business rules and then uses the Notification object to keep track of errors. UNKNOWN_POLICY_NUMBER) ĥ3 fail(((( RegisterClaimDTO) Data). PolicyId))Ĥ6 Policy policy = FindPolicy((( RegisterClaimDTO) Data). MISSING_INCIDENT_DATE) Ĥ4 if ( isNullOrBlank((( RegisterClaimDTO) Data). MISSING_INCIDENT_TYPE) Ĥ3 fail((( RegisterClaimDTO) Data). ![]() MISSING_POLICY_NUMBER) Ĥ2 failIfNullOrBlank((( RegisterClaimDTO) Data). Then in my view implementation I did this:Ĥ1 failIfNullOrBlank((( RegisterClaimDTO) Data). The only way I could do it (in the implemenation of the view) was to pass in the control name as a string. I wasn't about to pollute my presenter with controls from the UI (otherwise it would be easy) so how could I get the view to wire up the right error message to the right control. When I implemented the MVP pattern I had a bit of a problem. All the controls are there for the picking. In Martins example, he uses Autonomous View which is great and the way he resolves what control is causing what error it's easy to wire up. The SetError method needs a bit of explaining. There's also a ResponseMessage property which displayed if there are errors or not. The view is mocked out (which is what we're testing) so we expect calling the 3 properties of the view (that match up to the UI). MinValue ġ8 private static readonly DateTime VALID_INCIDENT_DATE = DateTime. 13 private const string INVALID_POLICY_NUMBER = "" ġ4 private const string VALID_POLICY_NUMBER = "1" ġ5 private const string INVALID_CLAIM_TYPE = "" ġ6 private const string VALID_CLAIM_TYPE = "1" ġ7 private static readonly DateTime INVALID_INCIDENT_DATE = DateTime. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |