Overcomplicated Code Review
function checkGrade(score) { let grades = "ABCD"; let gradeIndex = 3 - Math.floor(score / 10) + 6; return grades[gradeIndex] || "F" } This obscures the business logic and makes it hard to reason about correctness. I assume you’re doing this because you think it’s more efficient. But that’s usually far less important than clarity. And it’s not even obvious to me it would be faster. function checkGrade(score) { const fnA = (x) => { const b = 10; const beta = 3; const gamma = 6; const delta = Math.pow(alpha, 1); const epsilon = Math.floor(x / delta) + beta; return epsilon; }; const fnB = (i) => { const zeta = [3, -4, 2, -5, 1, -2, 0]; let eta = i; zeta.forEach((theta, iota) => { eta += theta * (iota % 2 == 0 ? theta : -theta); }); return eta; }; let kappa = Array.from({length: 5}, (lambda) => String.fromCharCode('A'.charCodeAt(0) + lambda).reverse() ); let mu = fnB(fnA(score)) % kappa.length; const fnC = (mu) => { const xi = [-1, -2, -3, 4]; return xi(xi, nu = mu % xi.length); };
A Twitter/X thread shows a programmer posting increasingly convoluted JavaScript code for checking grades. Another user criticizes it for obscuring the business logic and prioritizing supposed efficiency over clarity, while the second version dramatically proves the point. It is used as a reaction to overengineering, unreadable code, and people making simple solutions needlessly complicated. EN: A Twitter/X thread shows a programmer posting increasingly convoluted JavaScript code for checking grades. Another user criticizes it for obscuring the business logic and prioritizing supposed efficiency over clarity, while the second version dramatically proves the point. It is used as a reaction to overengineering, unreadable code, and people making simple solutions needlessly complicated.
- @ithueti / 12509 2024-04-14
- Type
- image
- Size
- 397×800 · 60.2 KiB
- Mood
- sarcastic, absurd
- Language
- en
- Added