Live data from Hacker News

CSS: Our best practices are killing us

slideshare.net

51–54 of 54 posts

Re: CSS: Our best practices are killing us

#51
post #10

She says we shouldn't blame the language, but how much of this is because CSS eschews Composition for (incomplete) Multiple Inheritance? And how much of the extra code is an effort to avoid bugs because layout properties are non-orthogonal? At what point do we decide that it's not that "you're doing it wrong", but that there were actually some design choices that, in retrospect, maybe weren't such a good idea? I'd sa…

It might be the language's fault, but that doesn't make the least bit of difference. CSS is here to stay for the foreseeable future, and she's saying we have learn how to use the tools we're stuck with the best we can.

That is the sad, sad truth of it. At least with CSS compilers and libraries like jQuery, it's getting easier to compensate for CSS' deficiencies. I do, though, still hold onto some hope that someday we'll be able to leave it behind.

Re: CSS: Our best practices are killing us

#52
post #11

My main rule is: Never write a class that you can't use again. I've other rules too, such as "padding is top, margin is bottom". CSS must be modular, not exception-based.

Top and bottom of the box, or top and bottom in the source? Margin and padding are both useful on all sides of the box.

Re: CSS: Our best practices are killing us

#53
post #47

Earlier quoted context omitted.

Another best practice I have is to place a comment on each closing element, referring to the opening one. So,I have: CONTENTCONTENTCONTENT When you have complex pages, with several nesting levels, this can save much, much time.

Isnt there a danger that someone else working on your code might not respect that rule (or dare I say it, but maybe you're in a rush one day) and you don't update the comment when you update the class. Now you've got comments saying in correct things, and you risk all sorts of confusion. The same rule applies to commenting methods in code really, you don't comment what the code does exactly - just what the intention…

The time spent on keeping the code readable is never wasted :) Obviously, every developer must adopt this habit.

Re: CSS: Our best practices are killing us

#54
post #30

Earlier quoted context omitted.

"much of this is because CSS eschews Composition for (incomplete) Multiple Inheritance?" Pretty much all of it. I remember being a bit surprised when they first released CSS at just how impotent it was. Over a decade later, I now realize my younger self would have gotten himself stuck in a morass of Turing completeness, but CSS goes too far the other direction. Decoupling styles (which may contain several rules) from…

CSS3+HTML apparently is Turing complete: http://lambda-the-ultimate.org/node/4222

Yeah, but not in the way I meant. The way I meant is that you have actual coding abilities in the CSS, because "more power is better". I now understand how that is not true, how it is generally better to be parsimonious with the power in your language (just enough to get the job done), and if you can avoid (convenient) Turing Completeness it's usually a good idea in a declarative UI language. But you can still do forward-declaration non-code replacements without opening the door to Turing-chaos.
Post reply on HN