Don’t push ifs up, put them as close to the source of data as possible

from blog Andy G's Blog, | ↗ original
If there’s an if condition inside a function, consider if it could be moved to the caller instead Finally, I want to briefly return to the notion of testing: Well, the answer to that is the same as the answer to exceptions; strengthen the type returned by the function, and let callers ignore scenarios they […]