r/shittyprogramming • u/calsosta • Nov 30 '18
Friday Code Confessions
If you have been living with technical debt and want absolution here is your opportunity.
Confess your sins and receive your penance.
155
Upvotes
View all comments
Show parent comment
15
u/[deleted] Nov 30 '18
Guards are used to detect whether an operation can finish before you try to carry it out.
Here's a pseudo code guard (it's python or at least close):
I use guards and an exit early strategy like this a lot, because it can make very complicated logic very easy to read and understand.
Sounds like you found a nice pattern on your own. Good job!