I'm not sure what is my question but I will try to explain.
Considering that every type in a domain model will become a rule or validation (or whatever) Strategy, what is the problem of persisting these validators on Database?
For example:
There is the followning model
public Class Contrat
{
...
public ContratType Type {get;set;}
public bool Validate(){
return Type.Validate(this);
}
}
public abstract class ContractType
{
public int Id{ get; set; }
public string Description{ get; set; }
public abstract bool Validate(Contract contract);
}
public Class PreSale : ContractType
{
public override bool Validate(Contract contract)
{
//here goes specific validation for PreSale
}
}
public Class HighRiskSale : ContractType
{
public override bool Validate(Contract contract)
{
//here goes specific validation for HighRiskSale
}
}
public Class AprovedSale : ContractType
{
public override bool Validate(Contract contract)
{
//here goes specific validation for AprovedSale
}
}
I will use a Table Per Hierarchy approach to manage the concrete validators
Is it a damnable approach?
What are the problems of doing it?
Thanks in advance
Aucun commentaire:
Enregistrer un commentaire