Setter Validation can affect performance?
Posted
by
TiagoBrenck
on Programmers
See other posts from Programmers
or by TiagoBrenck
Published on 2013-10-23T10:51:22Z
Indexed on
2013/10/23
16:08 UTC
Read the original article
Hit count: 402
Whitin a scenario where you use an ORM to map your entities to the DB, and you have setter validations (nullable, date lower than today validation, etc) every time the ORM get a result, it will pass into the setter to instance the object.
If I have a grid that usually returns 500 records, I assume that for each record it passes on all validations. If my entity has 5 setter validations, than I have passed in 2.500 validations.
- Does those 2.500 validations will affect the performance?
- If was 15.000 validation, it will be different?
In my opinion, and according to this answer (http://stackoverflow.com/questions/4893558/calling-setters-from-a-constructor/4893604#4893604), setter validation is usefull than constructors validation.
- Is there a way to avoid unecessary validation, since I am safe that the values I send to DB when saving the entity wont change until I edit it on my system?
© Programmers or respective owner