when writing small functions, the case often arises when some parameters are transferred to a function that itself passes them only to small functions in order to serve its purpose.
For example (C # -ish syntax):
public void FunctionA(object param)
{
DoA(param);
DoB(param);
DoC(param);
}
private void DoA(object param)
{
DoD(param);
}
private void DoD(object param)
{
param.DoX();
}
Thus, the parameters are not used inside the called function, but "somewhere" in the depths of the small functions that perform the task.
So, when is it better to check if my Object parameter is null?
When checking function A:
Pro: -No overhead is not associated with the use of additional methods, which, in the end, will do nothing, because the object is null.
Con: -My syntactically wonderful FunctionA is polluted with ugly validation code.
When checking only when using a param object:
Pro:
- FunctionA :)
:
- , , param- null.
- , .