Basically as the title says. Say we have an API endpoint that takes some object as a parameter and passes that object into a service method. That service method then relies on a mapper class to map the object to another type. This leaves three places to check if the object is null:
- Beginning of the API function
- Beginning of the service function
- Beginning of the mapper function
It seems overkill to perform a null check three times, but there is no guarantee that the service function will only be used by that one API function and no guarantee that the mapper function will be used only by the service function. I was curious what others considered to be best practice in this situation. Thanks!