Tuesday, 15 January 2013

c# - Deferred Validation -



c# - Deferred Validation -

the whole values (1) quantify domain model have been checked ensure recognizable values, may have been farther edited suitability domain model , have been echoed (4) user. of these checks immediate on entry. there is, however, class of checking should deferred until lastly possible moment.

in the checks pattern language of info integrity ward cunningham addresses deferred validations (6) whole objects. still not clear me :(

i understand deferred validation detailed validation complex object. so, should utilize validation in test method or within domain property while next ddd? can implemented ui?

and when should avoid this? cons of deferred validation? can please explain example? in advance

there various opinions on , validation pretty big subject, never want allow domain object in invalid state. therefore, validation occurs @ object construction , exceptions thrown immediately.

e.g. person object cannot exist without name in domains.

however, it's not possible validate object invariants @ construction time. case when object must allowed exist in incomplete/transient state.

e.g.

you building application allows users post ad. fields required before posting ad, there lot of details fill , want give user alternative save unfinished work , go on later.

in exemple above, not possible validate ad entity @ construction time since must allow incomplete ads saved.

in case, advertisement posting's validation occur when it's posted.

keep in mind there many other ways solve above issue in domain. exemple, 1 not want allow ad entity in invalid state , introduce persistent adbuilder object serves purpose of representing stateful's advertisement creation process.

also, decide saving incomplete work not domain concern , incomplete info should stored on client (e.g. localstorage in web browser) until ready posted.

c# validation design-patterns domain-driven-design domain-model

No comments:

Post a Comment