Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>In my own application I need to validate dimensions as they are typed in. The sequence I used is as follows</p> <ol> <li>The user selects or types then moves away from the control.</li> <li>The control loses focus and notifies the View sending it's ID and the entry text.</li> <li>The View checks what Shape Program (a class implementing a interface) created the Form and passes it the ID and entry text</li> <li>The Shape Program returns a response.</li> <li>If the Response is OK the View updates correct Entry of the Shape Class.</li> <li>If the Response is OK the View tells the Form through a Interface that it is OK to shift the focus to the next entry.</li> <li>If the Response is not OK, the View looks at the response and using the Form Interface tells the form what to do. This usually means the focus shifts back to the offending entry with a message displayed telling the user what happened.</li> </ol> <p>The advantage of this approach that validation is centralized in one location for a given Shape Program. I don't have to go modify each control or even really worry about the different types of controls on the form. Way back when I designed the software I decided how the UI going to work for textboxes, listboxes, combo boxes, etc. Also different levels of severity is handled differently. </p> <p>The View takes care of that instructing the Form what to do through the Interface. How it actually is implemented is handled by the Form itself in it's implementation of the Interface. The View doesn't care if the Form is displaying yellow for warning and red for error. Only that it handles those two levels. Later if a better idea of displaying warning vs errors comes along I can make the change in the Form itself rather mucking around with the View logic or the validate in Shape Program.</p> <p>You are already halfway there if you are considering making a class to hold your validation logic this will get you the rest of the way in your new design.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload