3 ms·
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 examp
by yongjik 6y ago
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.