Re:It Takes 6 Days to Change 1 Line of Code (2015)
by jeroen on Wednesday December 07, 2016 @05:23AM
(#13121622)
> I had to do something special for www.naver.com, Korea's biggest portal. Because the string > "www.naver.com" appeared multiple times in the same function, we put that into a string
> constant at the beginning: something like
> static const string kNaverUrl = "www.naver.com";
> Because having "magic constant" sprinkled in the code is bad!
You have changed your magic string into a magic constant. It's a step towards better code, but the next step is to give the thing a proper name. In this case, something like DoSomethingSpecialUrl. Now you have a bit of self-documenting code.
You have changed your magic string into a magic constant. It's a step towards better code, but the next step is to give the thing a proper name. In this case, something like DoSomethingSpecialUrl. Now you have a bit of self-documenting code.