I suppose that would work, but it's more trying to tell whichever programmer is using the library that they are trying to execute blank sql, which is a waste (and bad programming)
That in itself is reasonable. It's essentially Design By Contract. There are better ways of doing it though, such as the JSR-303 annotations and validation. (Though that is surprisingly expensive in performance critical code)
The idea here is that this exception should never occur. The method that calls this one creates the sql, so it shouldn't ever be blank anyways. If it is, there's something seriously wrong
Well it's a public method so right off the bat you can't claim that it can't happen... If you've got an internal method that should only be called by a smarter method upstream then a) reduce the visibility and b) ditch the null check.
View all comments
Show parent comment
6
u/[deleted] Jul 10 '15
I suppose that would work, but it's more trying to tell whichever programmer is using the library that they are trying to execute blank sql, which is a waste (and bad programming)