Me: Really? Is that really a business requirement? Any other requirements you need done?
I landed a graduate assistantship in 1992 as "the computer guy's assistant" at my school's physical plant. My first assignment was to generate a fixed format file with one phone number per line. The file was to range from 1-900-0000 to 1-900-999-9999 and was needed by the campus telephone system to block all premium rate calls. They asked me to do it because they got back a 30 day completion estimate from the central IT department after filling out an internal RFP form.I'm sure somewhere, someone has been paid to write a program that prints 1 to 100.
Edit: and had 6 figure salaries.
1. Implement a sane (albeit less powerful) view hierarchy system, foregoing basically all of the CSS selector stuff, and applying styles individually. The framework will be big and unwieldy, and you'll take a performance hit, but you'll be able to maintain the client code.
2. Bite the bullet and implement it the ad hoc way, comment the crap out of it, and hope that whoever comes and changes something later will remember to read those comments.
Imperatively generating and dealing with a DOM structure using simple selector queries is relatively easy to do, as is modeling what is happening in your head. Dealing with more complex CSS rules as they apply to a static (or dynamic but very simple) DOM structure is a little trickier, but not completely unwieldy. When you run into problems is when you try to do both simultaneously. Suddenly you have to not only mentally model a mutable DOM structure, but you have to model how those CSS rules will be applied in a generalized and abstract form. It's not hard to paint yourself into a corner where you'd actually start having to prove theorems about your code in order to be reasonably assured that the CSS will apply correctly.
Of course, hardly anybody actually lets it get that far. Instead, they start applying styles imperatively using JavaScript. And that sucks.
I don't know what the solution to this is, or if there even can be one that is a progression from where we currently are. But I don't think fancier CSS selectors are the answer.
Like you, i can't think of a good solution - a lot of UI frameworks either just has really heavy restrictions, or it doesn't actually provide enough abstraction to actually help with the problem. Sigh...
Me: Really? Is that really a business requirement? Any other requirements you need done?
Boss: Yes, it's your number 1 priority. No, just 1 to 100
Me: <a few minutes later> Done. Give it a review and I'll push it live.
Boss: <a few minutes later> No! I said 1 to 100 and everything divisible by 3 should be replaced by "FIZZ". Why didn't you do that?
Me: I'm pretty sure you didn't ask for that, but I'll do it right now. Any other requirements than FIZZ?
Boss: Thanks for taking care of this. There aren't any other requirements.
Me: <a few minutes later> Done. Give it a review and I'll push it live.
Boss: <a few minutes later> Seriously! Why didn't you put the BUZZ in there?
Me: What BUZZ are you talking about? You only asked for FIZZ.
Me: Wait a second, are you having me program FIZZBUZZ for you? What the heck!
Boss: Yes! Somebody on the internet asked how a non-programmer like myself would solve FIZZBUZZ!
Me: Sigh...