Is it a good practice to throw an exception on Validate() methods or better to return bool value?

后端 未结 8 1926
攒了一身酷
攒了一身酷 2020-12-28 14:24

Is it recommended or not to throw exceptions from Validation methods like:

ValidateDates();
ValidateCargoDetails();

Apart from this : Is t

8条回答
  •  青春惊慌失措
    2020-12-28 14:50

    I would say it all depends on what/how you are doing the validation. But at the end of the day a developer can always choose to ignore a returned result (this is the problem with them), they can't ignore an exception without writing explicit code to do so.

提交回复
热议问题