4 ms·
Say No to Null Checks
- jawngee 16y agoSo instead of validating input into a function, I should write a test, a factory and a bunch of other shit? No thanks.
- abyx 16y agoWell, my point was that validating in the function does no good: it'll raise an error you'll see in the logs and debug later to try and understand what caused it. Why not write the test that makes sure your code will never call the function with bad input and be done with it? And, you should write a test. Period. A factory isn't needed and the bunch of shit is only if you're using version < 3.0. Did you really miss this in the post? That's good input, thanks, and thanks for reading!
- jawngee 16y ago3.0 of what? I wasn't clear if your blog is about a particular framework/language (I'm guessing rails?) Not validating input to a function, in general cases, is a bad idea, imho - tests or no tests - but that might be a matter of style or preference?
- abyx 16y agoNah, it's not particular, 3.0 was a bad joke :) Well, I know better than to get into discussions about style !