[aida] Post Tutorial comments - validation

Friedrich Dominicus frido at q-software-solutions.de
Thu Apr 21 08:07:27 CEST 2011


Herbert König <herbertkoenig at gmx.net> writes:

> Hi Elliot,
>
>
> EF> others.  Ideally, you'd want to have an all or nothing approach.  Is
> EF> there a way to do total form validation before the fields are
> EF> committed to the domain model?  perhaps some non-javascript way?
>
> while I accept the arguments on validation of Friedrich and see their
> usefulness, just let me state two things:
>
> - Ajax was a move away from whole form posts for good reasons. But I'm
> sure you can still make every action a Form post in Aida.
>
> - In my own application the web interface always works on a copy of
> the model object which is only committed when it's in proper state
> regarding the whole domain model. For example an appointment may
> itself be in a valid state but may block the necessary travel time to
> the next appointment in the calendar.
>
> So for me validation is not a matter of the web interface.
>
> Again, I'm not arguing against Friedrich's proposals on validation,
> maybe you even want to scan the list archives for those validation
> discussions. I just describe the way I'm doing it today.
I do not disagree. You just have to see it in the context of
presentatan and getting form/to a string representation of some object. 

And if we follow the rules of having difference defence walls we surely
should have validation on the view side (and this  is what we are
talking here) and validation on the model site..

So in the end we probably have three levels of validation
1) validaton based on the input in one "input  area"
2) validation based on all the input files of a form
3) validaton on the model side. 


You copy of the model side is somewhere between 2-3. 

My proposal especially handles this sorry not very extensible
autoConvert function. 
autoConvertToString: anObject
	"try to convert object to string depending on object type"
	"Squeak specific!"
	(anObject isKindOf: String) ifTrue: [^anObject].
	(anObject isKindOf: Integer) ifTrue: [^anObject printString].
	(anObject isKindOf: Point) ifTrue: [^anObject printDotString]. "???" "Squeak specific!"
	(anObject isKindOf: Date) ifTrue: [^anObject shorterPrintSloString].
	anObject aidaIsAssociation ifTrue: [^anObject]. "multilingual"
	^anObject printString

You can not have a different presentation here but you "must" use
shorterPrintSloString. This is not good.

In the end one must admit. Validation is not really easy and sorry it
often just feels like an afterthought. Therfor I suggests an alternative
approach which I think is  at least better than what there currently
is...

YMMV of course.

Friedrich

-- 
Q-Software Solutions GmbH; Sitz: Bruchsal; Registergericht: Mannheim 
Registriernummer: HRB232138; Geschaeftsfuehrer: Friedrich Dominicus


More information about the Aida mailing list