4 ms·
It's also easier to refactor code without magic constants, as you have compile time bugs mispelling kNaverUrl instead of runtime bugs because "ww.naver.com" in
by serge2k 10y ago
It's also easier to refactor code without magic constants, as you have compile time bugs mispelling kNaverUrl instead of runtime bugs because "ww.naver.com" in one of 10 places.
- yongjik 10y agoYou have a point, but on the other hand, it is much easier to write (kNaverUrl + "index.html") than to write "www.naver.comindex.html". So it just opens door for a different kind of bugs.
- zepolen 10y agoThen it becomes a function: kNaverUrl('index.html') Multiple functions: kNaverWwwUrl('index.html') kNaverApiUrl('resource') Then it get's refactored: urlGenerator('www.naver.com')('index.html') urlGenerator('api.naver.com')('resource') Refactored even more: urlFor('naver_www', 'index.html') urlFor('naver_api', 'resource') Even more! urlGeneratorFactoryFactory(.......