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: 281

Filed under:

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 (, 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

Related posts about Performance

Related posts about orm