▲ | claytongulick 10 days ago | |
I try to structure functions and validations like this in a early-return list at the top of a function.
The author mentions this technique as well.I find it particularly useful in controller API functions because it makes the code a lot more auditable (any time I see the same set of conditions repeating a lot, I consider whether they are a good candidate for middleware). I try to explain this to newer developers and they just don't get it, or give me eyerolls. Maybe sending them this article will help. |