Home
Use Enum Constants instead of Magic numbers?
  v1.0 Posted at 27/04/2018 3:11 AM by Tiago Araujo

Using "Magic numbers" in your code makes it confusing and really hard to maintain.​​​

MagicNumberBad.jpg
Figure: Bad example - "Magic Number" works, but is a bad idea
MagicNumberGood.jpg
Figure: Good example - No Magic Number, looks good and is easy to manage​

Related rules

    Do you feel this rule needs an update?

    If you want to be notified when this rule is updated, please enter your email address:

    Comments:

    Note: Social Media login for Yotpo is not working in IE or Safari, please use Chrome. We are waiting for Yotpo to fix it.