Are preconditions necessary inside handler APIs that are supported by Frameworks? -
basically when spring io or other framework matter routes url handler method, injects path parameters user supplied values.
public responseentity<list<datamodel>> doget(@pathvariable string param1, @pathvariable string param2) { preconditions.checknotnull(param1); preconditions.checknotnull(param2); }
is practice or redundant make precondition checks on supplied params inside function shown above?
the spring framework not allow injection of null values above parameters. still, handler method can invoked other parts of code (a bad practice, legit nevertheless). method can passed null values when under junit test.
so having said this, there compelling case not have preconditions assertions @ top of handler api?
Comments
Post a Comment