Say I have a web service with a method MyWebServiceMethod(string passedValue)
.
The web service calls a method MyServiceMethod(string passedValue)
where the value from the web service is passed along.
The service calls a repository method MyRepositoryMethod(string passedValue)
where again, the value from the service is passed along.
I hope that is clear enough. I can post code if need be.
My question is around null argument checking.
Should I check passedValue
and throw an exception in:
- The Web Service
- The Service
- The Repository
Obviously, if passedValue
is null in the web service, the following methods will never get invoked but should I check in case the solution changes in the future?
Edit
I should have said that I don't expect null to ever be a valid value.
Also, My worry in these situations is that someone may change the web service or create another client with no argument checking that will call the service with invalid arguments. So I tend to think the checking should be in both places. Then I think of YAGNI and wonder if we should cross that bridge when we come to it.
What is considered best practice in these situations?