Bruce Johnson

.NET Developer, speaker and author. In my spare time, parent, chauffeur, and goalie.

Sep 2014

Going Out of Style

by in CodeSOD on

The process of optimizing the CSS used in a web site can be quite complicated. The subtle interplay between selectors, attributes, specificity, inheritance and the DOM elements can significantly impact the outcome. Style guides can be a thing of elegant beauty, to be admired by many and revered by those steeped in the dark arts of styling.

There there's the code that George found when he took on the task of migrating a 1990's-era web site. Nobody expects code from a 15 year-old web site to be up to current standards. But there are limits. George's spidey sense started tingling when he found a file named 'css.php'. A look inside didn't do anything to turn the alarm bells off.


Feeling Validated

by in CodeSOD on

Ugh...Address validation. Take some address strings, add to that a city, state, postal code, and country... make sure they are are all look syntatically 'valid' based on some business logic - it's not as easy as we'd hope to be able to handle EVERY possibility. But, no matter WHAT you come up with, I can guarantee that it's guaranteed to be much easier to digest than the block of validation code discovered by Mickey.

According to Mickey, there are a couple of special rules for this address validation that result in some of the WTF-ness. If an address is changed, and it's "close" to existing address, then the user needs to be prompted to confirm the address. And this prompt shouldn't take place unless the address itself has been changed. Wanna bet that the user specification for 'close' included the phrase 'you know what I mean'? That's probably the reason why the code doesn't actually address the idea of 'closeness'...the developers are still waiting for the definition.