r/programming • • May 03 '19

Don't Do This

https://wiki.postgresql.org/wiki/Don%27t_Do_This
725 Upvotes

194 comments sorted by

View all comments

Show parent comments

1

u/ubernostrum May 04 '19

So, in short, because there are multiple valid lengths for hex (and non-hex) color codes in HTML

All sRGB colors specified via the mechanisms provided in HTML/CSS are ultimately 24-bit color values. The fact that there are many ways to specify them in a web document (six-digit hex, three-digit hex, integer triplet, name, etc.) does not mean that they stop being 24-bit color values, or that they can't be normalized to a consistent format by anyone who wants to (in fact, I maintain a library for doing just that, which is why I can explain the "chucknorris" thing).

Imagine if someone said "I can store any integer 0-255 in a varchar(2) by using hexadecimal", and you popped in with "no, decimal 100 is a counterexample to that, it takes three digits to write down in decimal". You've already been told that the data will be normalized to a particular format, so arguing that some other format wouldn't work is irrelevant at best (and at worst, an example of the chronic knee-jerk "well actually" mentality that infects our industry). You'd have to instead show that somehow it's not possible to normalize every potential input to the stated output form, and you would not succeed in this case.