Validating Objects Through Metadata
Subject:   Not seeing the point
Date:   2005-09-26 11:05:40
From:   richardcollette
From a coding/typing perspective, I do not gain anything by annotating @ValidateEmail vs. using a method call Validation.validateEmail(email).

From a configuration standpoint, this isn't providing anything that is configurable (at least not from the examples). Suppose I want to validate that an account deposit is not larger than N dollars. Where would a user (not developer)configure that validation how would that configuration carry through to the annotation?

If the intent is not to provide user configuration, why would my validations not be included as part of the business object? Annotations in this case are no less intrusive since they have to be entered and compiled with the code. Is there really a case where you would want to strip out validations from the business logic? Think about a vending machine that no longer validates the coins it receives. Shouldn't validation be intrinsic to the object?

I could be wrong but I don't think annotations were intended to replace business logic. They're great for EJB3 entities and Plumbing Web Services where functionality outside of the nature of the business object is being added, but I'm not buying this use case just yet.