So every number in the code that we are sending to a method as an argument is considered as a Magic Number? To me, it shouldn't.  I think if some number is let's say it is for minimum length of user name and we start using 6 in the code...then yeah we have a maintenance problem and here 6 is a magic number....but if we are calling a method that one of its arguments accept an integer for example as the ith member of a collection and then we pass 0 to that method call, in this case I don't see that 0 as a magic number. What do you think?
Is every number in the code considered a magic number?
programming practices
If the meaning of the number is very clear in the context, I don't think it's a magic number problem.Example: Let's say you're trying to get the substring of a string, from the beginning to some token and the code looks like this (imaginary language and library):s := substring(big_string, 0, findFirstOccurence(SOME_TOKEN, big_string));In this context, the meaning of the number 0 is clear enough. I suppose you could define START_OF_SUBSTRING and set it to 0, but in this case I think it would be overkill (although it would be the correct approach if you knew that the start of your substring might not be 0, but that depends on the specifics of your situation).Another example might be if you are trying to determine if a number is even or odd. Writing:isEven := x % 2;is not as strange as:TWO := 2;isEven := x % TWO;Testing negative numbers asMINUS_ONE := -1;isNegativeInt := i <= MINUS_ONE;also feels weird to me, I'd much rather seeisNegativeInt := i <= -1;