Hacker News
points by Orphis 3 days ago | 0 comments
And the day you add a way to batch import request through another code path, you may forget the validation.

Having it in the lower layer is correct, a proper optimizing compiler should be able to detect there's a single code path to the function and that the checks have already been done, skipping the second check.

[–] alright2565 3 days ago
Alternatively, the code could be written in the style of parse, don't validate[1]. However I've never had a coding LLM preemptively suggest that.

[1]: https://lexi-lambda.github.io/blog/2019/11/05/parse-don-t-va...

[–] eithed 3 days ago
Well - this would be an example of defensive programming and by that logic catering for this "what if" is the way to go. LLMs were correct all along!
Hacker News