What are “magic numbers” in computer programming?
问题 When people talk about the use of "magic numbers" in computer programming, what do they mean? 回答1: Magic numbers are any number in your code that isn't immediately obvious to someone with very little knowledge. For example, the following piece of code: sz = sz + 729; has a magic number in it and would be far better written as: sz = sz + CAPACITY_INCREMENT; Some extreme views state that you should never have any numbers in your code except -1, 0 and 1 but I prefer a somewhat less dogmatic view