Should i validate parameters in constructor?

前端 未结 4 1719
谎友^
谎友^ 2021-02-07 08:09

I am creating a web application following the MVC pattern.

In effective Java the author mentions to validate the parameters in the constructor of the class when creatin

4条回答
  •  你的背包
    2021-02-07 08:34

    It sounds like you are validating fields which have already been previously validated. In that case, it is just a waste of time (both writing it and in run-time). If your form (client-side javascript) have not validated the fields then it would make sense. Otherwise you can skip it.

提交回复
热议问题