2 ms·
That's exactly what I thought about it, too. The example function is close to spaghetti and needs at least one helper function with a well-chosen name. The pre
by vog 16y ago
That's exactly what I thought about it, too. The example function is close to spaghetti and needs at least one helper function with a well-chosen name.
The previous example (if-then-else with a complicated boolean logic) has a similar problem: Nobody should write such a mess in the first place. Instead, give speaking names to terms like "a" and "!a & (b|c)". And with "speaking names" I don't mean stupid stuff like "isAandBorC", but something like "waterSuppyOutOfLimits". That way, humans no longer need to think in boolean algebra but in terms of the problem's domain.
He is focusing on the structural aspect of programming, making spaghetti code more manageable by easier dynamic investigation of (partial) special cases.
However, statements like "names are just comments" show that he's completely missing the linguistic aspect of programming. With well-chosen names you don't have to look at the low-level details to understand what's happening. That's what makes abstractions powerful.