As everyone says, it is up to you. There is no such fixed / standard guide for this. But to make it simple, you need to put all your validation logic in one place so that it remains readable and easily changing.
, , . , db. , FKEntity. , , FKEntity.validate() ( Validatable), ... , FKEntity . - , / FKEntity (, FKEntity "x", "x" , , ), .
Inteface Validatable { void validate() throws InvalidEntityException; }
Class FKEntity implements Validatable {
public void validate() throws InvalidEntityException {
}
}
Class FKDigestService {
public digestEntities() {
try {
for(FKEntity e : entityList)
e.validate();
} catch (EntityValidationException e) {
}
}
: