Form Validation + Domain Logic or Business Rule Validation == Full Data Validation
In CRUD screens/domain, the FORM VALIDATION is prevalent. This is the only form of validation we need before saving the data to the Database.
These are Just Forms over Data Base Tables. Once the Data on the form is validated, we do not need validatoin on the server. Domain Model of such Sceens is Anemic Domain Model and it is perfect of have such Anemic Domain Model. It is not an Anti Pattern. It is just a pattern when feature is Thin and it is not FAT.
But in Complex Domain/Business intensive domains, data validation + domain logic validation both are used and there is a lot different in them. In such domain or Features we need rich domain model.
Form Validation is low level checks those are also applied at DB level.
These check are applied at Data Type level, Data Format level. LOW LEVEL FORM BASED DATA VALIDATION. They do not need to consult existing data in the DB.
Domain Logic Validation: This is validation is done at high level, and it involves the business rules.
Before saving data is needed to validated against the Domain Rules.
We get the Data from user, we also load the data from DB if needed, both types of Data is loaded in an OO API (Domain Model) and apply checks on it validate data.
Examples are: Decisions tables with Business Logic. Insurance Domain. Complex Conditional Logic of Domain. If then this else then this. Complex Domain IF-THEN-ELSE ladders.
OO API or Domain Model should also log and return the reason why particular Save attempt failed.
In case of Forms over Data/CRUD, we only need Form Validation, we do not need domain logic. Domain Model is Anemic that may turn into Rich Domain Model as application evolves.
The whole applicaiton or sub domain is CRUD oriented.
As the application grows, there are changes that
Anemich Domain Model ==> Rich Domain Model.
Therefore we will always use the Domain Model pattern
We cannot stop CRUD froms to the part of Complex Sub Domain of Appliation.
Application may be mix of CRUD forms and Complex Forms,
In CRUD screens/domain, the FORM VALIDATION is prevalent. This is the only form of validation we need before saving the data to the Database.
These are Just Forms over Data Base Tables. Once the Data on the form is validated, we do not need validatoin on the server. Domain Model of such Sceens is Anemic Domain Model and it is perfect of have such Anemic Domain Model. It is not an Anti Pattern. It is just a pattern when feature is Thin and it is not FAT.
But in Complex Domain/Business intensive domains, data validation + domain logic validation both are used and there is a lot different in them. In such domain or Features we need rich domain model.
Form Validation is low level checks those are also applied at DB level.
These check are applied at Data Type level, Data Format level. LOW LEVEL FORM BASED DATA VALIDATION. They do not need to consult existing data in the DB.
Domain Logic Validation: This is validation is done at high level, and it involves the business rules.
Before saving data is needed to validated against the Domain Rules.
We get the Data from user, we also load the data from DB if needed, both types of Data is loaded in an OO API (Domain Model) and apply checks on it validate data.
Examples are: Decisions tables with Business Logic. Insurance Domain. Complex Conditional Logic of Domain. If then this else then this. Complex Domain IF-THEN-ELSE ladders.
OO API or Domain Model should also log and return the reason why particular Save attempt failed.
In case of Forms over Data/CRUD, we only need Form Validation, we do not need domain logic. Domain Model is Anemic that may turn into Rich Domain Model as application evolves.
The whole applicaiton or sub domain is CRUD oriented.
As the application grows, there are changes that
Anemich Domain Model ==> Rich Domain Model.
Therefore we will always use the Domain Model pattern
We cannot stop CRUD froms to the part of Complex Sub Domain of Appliation.
Application may be mix of CRUD forms and Complex Forms,
Usllally Small and Medium Level Web Appsare combinaiton of both.
In such sitations too we use the Domain Model. Some Classes are Anemic just bags of
getter and setter properties. Some Classes are Rich and contain Domain Rules.
Therefore we will always use the Domain Model pattern
No comments:
Post a Comment