Have you failed a job interview?
Send us your job interview questions and get correct answers.

BP34: Do not use Magic values

Never use magic values - strings, numbers, dates...

If you need constant, define it and name it properly. Than reuse it everywhere in the code.

  • This will help you to save time if you need to change the constant later
  • You will decrease the chance to change the value on one place and forget to change it on another place
  • You can easily find all locations where the value is used

Comments

No Comments Yet.
Be the first to tell us what you think.

Download Better Coder application to your phone and get unlimited access to the collection of enterprise best practices.

Get it on Google Play