Your Web News in One Place

Help Webnuz

Referal links:

Sign up for GreenGeeks web hosting
June 29, 2019 10:39 pm GMT

How do you handle the disposable IF statements ?

Hi there,

Sometimes you need to write a conditional block that will only be executed once or for a brief period of time then the condition won't be satisfied again, like for ever.

An example for these IFs is

// User activationif (!user.activated) { alert('please activate your account'); return false;}

The idea of that residing code that won't be executed again has been bothering me for years. I'm kind of picky and sometimes go crazy about micro-optimization, but sometimes I just ignore it. However, I feel that there's a great design pattern that I'm not aware of that may make me feel better about it.

What do you think ? Do you share the same feeling ? and how are you dealing with it ?

Photo by Carolina Pimenta, Unsplash


Original Link: https://dev.to/mazentouati/how-do-you-handle-the-disposable-if-statements-hi6

Share this article:    Share on Facebook
View Full Article

Dev To

An online community for sharing and discovering great ideas, having debates, and making friends

More About this Source Visit Dev To