DEV Community

Discussion on: If/Else and Specificity: Understanding "FizzBuzz"

Collapse
 
ravavyr profile image
Ravavyr

This solution is great to optimize the code.
However in the real world, next week some non-tech person is gonna come in and go "When it's divisible by 3 i also want you to display "pop" and "pizzaz" if it's divisible by 4"

At that point the final optimization becomes a hindrance, so the second version of the code is better to work with.

This happens in real world situations ALL the time.
A lot of framework devs don't take this into consideration and over-optimize the code unnecessarily leading to headaches for their future selves, or worse, for the poor sucker who has to take over their code in a year to apply new changes.

I suppose the lesson is: Optimize, only as far as you need to to gain the performance expected. Anything more, might come back to haunt you.

Collapse
 
cat profile image
Cat

Great advice. Definitely need to keep scalability in mind. I added the correction to the article. Thanks so much for sharing!