DEV Community

Discussion on: Clean Code

Collapse
 
sarcevicantonio profile image
Antonio Sarcevic

Care to elaborate on the Magic Word thing? I don't get it. Also shouldn't it be >= instead of >?

Collapse
 
tastaslim profile image
Taslim Arif

Improved thanks. Magic number is nothing but using direct number in code:

if(name.length()>12){ ----} // here using 12 directly is bad.

Instead we should use
MAX_NAME_LENGTH=12;
if(name.length()>MAX_NAME_LENGTH) { ------ }

Collapse
 
kaszubski profile image
Info Comment hidden by post author - thread only visible in this permalink
Mateusz Kaszubski

imo its typo, it should look like this -->
if(age >= MINIMUM_AGE_FOR_VOTING) "eligible for voting"

Some comments have been hidden by the post's author - find out more