Reducing Complexity with Guard Clauses in PHP and JavaScript
Link – – engineering.helpscout.com
In this old, but still relevant, blog post Craig Davis explains what guard clauses are and how they can be used to clean up your code.
We’ll first explore several versions of a sample method from a hypothetical billing system. For these purposes, we’ll assume this is code in an existing system and we’ll look at refactoring it to reduce complexity and make it easier for a programmer to understand. The first example will be trivial enough to easily understand, but we’ll build on it in the final examples.
Read more [engineering.helpscout.com]
What are your thoughts on "Reducing Complexity with Guard Clauses in PHP and JavaScript"?