Use Enum Constants instead of Magic numbers?

Updated by Ben Neoh [SSW] 1 year ago. See history

123
<introEmbed body={<> Using "Magic numbers" in your code makes it confusing and really hard to maintain. </>} />
Image

❌ Figure: Bad example - "Magic Number" works, but is a bad idea

Image

✅ Figure: Good example - Add Enum

Image

✅ Figure: Good example - No Magic Number, looks good and is easy to manage

Acknowledgements

Adam Cogan
Related rules

Need help?

SSW Consulting has over 30 years of experience developing awesome software solutions.

We open source.Loving SSW Rules? Star us on GitHub. Star