开发者

Is it possible to have too many validations?

Does the number of validation ClassMethods have anything to do with the performance of an appl开发者_开发技巧ication? Could a boatload of validations cause a strain?


I would be astonished if validations made any significant impact on performance in any non-trivial application.

And as validations are integral for both user experience and data integrity, they would be one of the last things on my list to be concerned about.


An abundance of validations probably isn't as much of a performance issue as it is a design issue. If you are building an application and you find that you have more than say 10 validations in your classes, this is probably an indication that the class is doing too much.

I'm considering something like validates_presence_of :name, :description, :etc as a single validation.


One typical issue is the way we do the validation. We should check for valid data instead of checking for invalid conditions.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜