Behavior of a controller action on reception of a null dto

99 views Asked by At

When a controller detects that a DTO passed to it is null should it instantiate an instance of the DTO (cf the Null Object Pattern), or should it simply throw an exception there and then?

Thanks

1

There are 1 answers

0
bloparod On BEST ANSWER

If null means that you can instantiate a Null Object and act in a default way, it's ok. If null makes any sense to the controller, handle this case. If null makes no sense to the controller, throw an exception.