3 ms·
You may want to also consider refactoring this code. A function should do what it says, not have unexpected side effects. Not only can this be surprising to a
by retro64 10y ago
You may want to also consider refactoring this code. A function should do what it says, not have unexpected side effects.
Not only can this be surprising to a client, but it also makes it difficult to leverage the code for reuse elsewhere ("I only wanted the IP address, not the rest, guess I'll write one called getIpAddressOnly", etc).
Functions like this also tend to become muddled and difficult to maintain because as time marches forward, functionality may need to be added between these side effects, and again, unless it is refactored, it has to end up within the same function, making the whole problem even worse.