What is a magic number?

John Zukowski

Magic numbers are literal numeric constants, typically stuck in the middle of code with no obvious reason for existance. Instead of using magic numbers, they should be declared as constants (private static final) with a name so you or another developer who looks at the code "later" will understand the reason behind the usage of that number, based on its new name.

0 Comments  (click to add your comment)
Comment and Contribute

 

 

 

 

 


(Maximum characters: 1200). You have 1200 characters left.

 

 

About | Sitemap | Contact