News for hackers. Stuff that matters.
Re:Ask HN: Anyone know any funny programming jokes? by yongjik on Thursday January 21, 2021 @04:34PM (#25864598)
100% agree - it's a quite common trap for inexperienced developers to write down every cases and conditions separately, when they shouldn't. As a similar example, instead of writing "req.source = host + port", people would write:

    if (host == "load-balancer-1.internal.dns") {
        req.source = HOSTS::LOAD_BALANCER_1;
        req.source += PORT_MAPPING[HOSTS::LOAD_BALANCER_1];
    }
    else if (host == "load-balancer-2.internal.dns") {
        // repeat
    }
After a few quarters of services, layers, and people being added and removed, it becomes a 500-line monstrosity and sits in every critical path. And because now it's a 500-line class (half of which is defunct, but good luck figuring out which half), nobody has time to read through it and figure out that it should have been a single assignment statement.

There are no comments on this comment yet.