JMichelson wrote:
The validation classes generated by LLGLPro seem to validate individual entiry fields whenever a field value changes. However, this is a "chatty" approach to validation and is not efficient for distributed applications.
It's not chatty, because the validation objects are inside the entity itself. This means that the entity uses an object that's inside itself for validation. These validations are for basic per field validations only, like "OrderDate has to be > today" etc. Not complex business logic validations. In a distributed application, you remote the entity object, and with that you remote the validator object as well (since it's inside the entity object), and thus will work nicely.
I think that, in some cases, its better to validate the entire entity (object) one time just before the database is updated. Are you guys doing it this way? How? Do you think that the generated validation classes could be enhanced to include entiry-wide (not just individual field) validation?
If you want to do entity-wide validation, you can do that using the 2-class scenario. With that, you get 2 classes per entity: "CustomerEntity" and "CustomerEntityBase". In CustomerEntity, you override UpdateEntity() and InsertEntity() and do the validation there. If the validation succeeds, you call base.UpdateEntity() or base.InsertEntity(), otherwise return false, throw an exception or whatever you want. Re-generating the code using two-class scenario's 'base only' or full/safe will not overwrite the 'CustomerEntity' class only the CustomerEntityBase class. Set the two-class scenario full/safe as your prefered scenario in the preferences so it gets preselected the next time you generate code.
Validating an entity in 1 go can be the solution if you want to perform some complex BL on the entity's data. If you just want to check if an ID is > 0, use a validator class implementation (which are never overwritten). You can also use a 'manager' approach which validates a passed in entity for correctness and returns true or false.
Next year enhancements are planned which will allow you to define concepts like 'Sales Order' which refers to objects like Customer, Employee, Order and OrderDetails. With that you also can define rules on them, which are complex validators in fact. For now, you have to add them manually as said above and move simple per-field validations into the validator classes and complex multiple-field (multiple entity perhaps) validations into the entity itself or in manager objects which in fact are business processes and execute rules based on input, in this case an entity or serie of entities.
Validation of string lengths for (n/var)char fields and variable/binary fields is done automatically, you don't need to set up validation for that.