CodeSOD: Three Links |
Brian's hired a contractor to tackle a challenging technical problem: they wanted to display three links in three table cells. Now, you or I might just write that as HTML. But if we did that, we'd lose the opportunity to do this in JavaScript. Plus think of all that repetition- you'll be outputting a
tag pair three times. That's just wasteful.
No, what we need is some elegant JavaScript solution that solves this problem without any unnecessary repetition.
Here we employ the For-Case antipattern to write a loop where we do something different on each iteration. That's a classic WTF, but here it's elevated through how unnecessary all of this really is. Plus we get the bonuses of style overrides, and the number of escaped quotes- but inconsistently and needlessly so. Take a look at the i == 0
branch- the double quote doesn't need to be escaped, and one time it isn't.
Suffice to say, this contractor's code wasn't used, and neither was that contractor after this.
Комментировать | « Пред. запись — К дневнику — След. запись » | Страницы: [1] [Новые] |