How NOT to Code - Challenge 16
Been busy doing a IP address switch over at work, which naturally caused me to find more things to rant about ;)
If you are directly calling an IP address in any manner in your coding, PLEASE STOP ;)
No I'm serious. Yes, IP changes are rare but not unforeseeable. By basing any programming logic on an IP address, you have made your code extremely fragile. to any type of change What's worse is when I see it baked into Flash/Flex apps. Typically the client doesn't have the source code and they end up SOL. In most cases, it's completely superfluous - just make a relative call and the code becomes very flexible to domain name or ip changes.
If you must use an IP or domain name in your coding, put it in a config file outside of the compiled swf. This is specially true for the Flash/Flex world.
You might even go an extra step and be more critical about calling the CGI variables directly. Sami Hoda has an interesting post about using a CGI facade - http://www.bytestopshere.com/post.cfm/cgi-facade-why-you-should-use-one. This is a very important concept of you ever intend to grow the site's infrastructure with clustering or reverse proxies.
Brad Wood wrote on 03/04/106:10 PM
I prefer to use DNS entries instead of IP addresses. We recently moved our servers to a new data center. We converted everything to DNS ahead of time, with low TTL's. Then on the day of the move, we simply updated DNS and all mapped drives, data sources, mail servers, etc all continued working.