Each time you write the public method, the first thing is parameter verification. In the pastCodeAppears:
If (oneoftheargument = NULL) {Throw new argumentnullexception ("oneoftheargument", stringtable. errorclassnameargnull );}
However, the parameter table of the method sometimes takes a long time, and there are many combinations of logical judgments. At this time, the number of such statements is sometimes 6 to 7. Such code is overwhelming and less readable (from the perspective of pure data, the complexity of the circle will also be relatively high ). So now all of them are replaced with this method:
If oneoftheargument is null, the system throws callback. Error. argument. isnull (oneoftheargument); // overload. Error. argument. isnull (oneoftheargument, stringtable. errorclassnameargnull) with custom message prompts );
You can also:
// Check whether the value is null or only contains white space characters. If it is null, // throw argumentnullexception. If it only contains white space characters or/string. empty, argumentexception is thrown. error. argument. isnullorwhitespacestring (value, parametername, message); // if the value is smaller than minvalue, argumentoutofrangeexception is thrown. error. argument. lessthan (value, minvalue, message); // if the value is out of a specified range, argumentoutofrangeexception is thrown. error. argument. outofrange (value, minincl, maxincl, message); // there are many other...
In this way, the code looks much more neat.