41 points · by cwebbdesign · 14y ago · 15 comments
In other words, if you want to build something maintainable, start thinking about all the ways you can help people not write custom CSS at all.
Also, LESS and SASS at their core do little to help with this problem, and can even hurt you with unintentional specificity (due to nesting) that hurts reusability. Mixins help you think "reusability" but they can really easily be misused in ways similar to how people are misusing CSS right now. This is by no means an attack on LESS/SASS, which I love. It is just a reaction to working on a large project that is making the switch and seeing the fallout.
This article focused on the first part and even compares different approaches, but misses the point that OOCSS is advocating a process overhaul, not just a change to the way that you write CSS.
When I say help people not write custom CSS, I am referring to reuse. Writing the code the right way is of course a pre-requisite, but from experience, not nearly enough.
I personally love using SASS and in fact (as mentioned by philipwalton) find it highly compatible with OOCSS. However, as with any tool, I advocate for thoughtful and critical implementation. I tend to suggest that anytime the final CSS file contains a large amount of repetitive styles or deeply nested selectors it's time to consider refactoring.
More important than any one methodology is consistency and documentation, no one wants to pick up a project with 'genius' abbreviated class names without some example markup!
I don't get the DRY CSS approach of wanting to avoid changing HTML. CSS changes are much more expensive, as they can affect the design on unrelated pages (especially if you don't write modular CSS), which means more testing.
And are there any real world use cases or benefits of "semantic class names"? If not, and if you think they hurt maintainability, why would anyone advocate them?
> And are there any real world use cases or benefits of
> "semantic class names"?
Yes. Class names tell what the stuff is, CSS rules tell how to style it.
Once you see blue 14px text on the left which has class "red-12px-right" you are enlightened.'red-12px-right' is a stupid class name (and a strawman). A better example would be 'heading-primary', instead of a "semantic" approach like '.news h2 { }' (which could have the same styles as '.blogs h1' and '.members h3'...)