Elliot Suzdalnitski
1 min readJul 21, 2019

--

By using setters you can catch errors. I think this is the only reason to use a setter.

Throwing and catching errors is not a very good way to control execution flow. It makes the method undefined for invalid values and may cause the program to crash in production. We should only resort to throwing errors when an unrecoverable error has happened. Invalid user input is not one of them.

--

--

No responses yet