eShopOnWeb makes regular use of Guard Clauses… this is when we test our variables early for problems and throw an error or return instead of having complicated if blocks with multiple levels of nesting.
eShopOnWeb makes use of Steve Smiths own guard clause library, personally I’d probably just write them myself, they are usually simple ifs and I’d rather not take a dependency on someone else’s kit without having a validated need, but I do love the pattern. IMHO the code on the right hand side in the above example is much easier to read.
One thought on “eShopOnWeb Architecture (5/16) – makes regular use of Guard Clauses”