Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Should i validate parameters in constructor?

Tags:

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 creating a new object.

However i am not creating some API that will be used by third parties. My classes just accept parameters from input fields of a form which are validated before beeing submited to the server.

So in this case should i create my classes the way the author mentions in Effective java or it is useless?


Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!