3 ms·
I break about half of those rules and it works very, very well. Please don't label things that can be discussed as 'best practices'. One day some newbie will wo
by tomjen3 15y ago
I break about half of those rules and it works very, very well. Please don't label things that can be discussed as 'best practices'. One day some newbie will wonder across it, take it as gospel, and then will screw up projects by applying them when they don't make sense.
Also there is nothing wrong with magic numbers so long as you don't use them where a % would be more appropriate (e.g this text is 12px, because it looks nice). If CSS is used with out a pre-processor you have to use them, as there is no concept of variables.
- csswizardry 15y ago> Please don't label things that can be discussed as 'best practices'. This is valid point, however In the README there is the line ‘This document is a personal one, and for use at my place of work […] this is a document for me and Sky. You do not have to follow the advice given, nor do I provide any guarantee.’ In the context of our team I can afford to make more sweeping statements because I have the ability to discuss and expand on the caveats. Perhaps this document becomes less useful in places without that context. > e.g this text is 12px, because it looks nice This is not an example of a magic number, this is a design decision that was made regardless of code. Perhaps I need to me more clear on what a magic number is, but by that I mean anything that has no reason for being. Cheers for the feedback, I might look at rewording some bits for clarity :) H
- johncoltrane 15y agoSo you are neatly packaging your knowledge, publishing it and marketing it (at least here and on reddit, not the smallest websites, possibly elsewhere) but somehow it's still a "personal document" and your "best practices" shouldn't be followed? > "In the context of our team I can afford to make more sweeping statements" As soon as you publish your document and market it the context of your statements changes. A lot. Think about all the *-killers that pop up every single day: the Internet loves to bash them when they fail.
- csswizardry 15y agoI see your point. This started off as a personal/close-knit reference for me and my teams’ best practices. Then I thought I might as well share it, even if only one other person finds it useful then that’s better than keeping it to myself. I packaged it with caveats and disclaimers and you can take the advice or leave it. A document was created for a small audience, sharing it was secondary, and an afterthought. It is not up to me to decide who follows them and who doesn’t; I merely made them public and people have the ability to pick, choose or even ignore at will.
- TiredOfTat 15y agoYou have some interesting opinions. It would be better if you viewed your code less emotionally, and focused on getting the job done. Maybe then you'd be more productive?
- huckfinnaafb 15y ago>I break about half of those rules and it works very, very well. Can you go into more detail about which rules you disagree with or find unnecessary?
- tomg 15y agoNot who you're replying to, but on my list: CamelCase vs using-dashes is strictly a developer preference. I happen to agree with the author of the doc about using dashes, but I'm not going to call my preference a "best practice". A "best practice" might be more akin to "if you're working on an already in progress project, don't start doing CamelCase if they're using-dashes, or vice-versa", IMO. Another controversial one is whether or not to have each style on it's own line, or in the same line. The author prefers a new line for each style because it makes for easier diff-ing in version control. The argument could be made, however, that this style introduces too much whitespace and vastly reduces the number of styles you can view at one time, not to mention increasing the linecount of your stylesheet by at least a factor of 3. Neither is, IMO, a "best practice", it's just a developer preference (IME most devs do agree with this doc, however). There's some other stuff that really just boils down to how the author prefers to read his CSS, and not really about how to structure it in a proven optimal way. I believe it's hard to argue that those are "best practices", something Wikipedia describes as "consistently shown results superior to those achieved with other means". I would like to see the argument that lining up your -webkit prefixed styles achieves this, for example. Anyway, IMO, a lot of the recommendations in the doc are good advice, just mixed in with some personal preferences. Like the author wrote though, it is his personal best practices, so in that context I suppose these are Best Practices, only the scope is limited to just the author.
- tomjen3 15y agoMagic numbers (you have to because CSS doesn't allow you to make variables), specify a height and width in pixels (works well if it doesn't contain text that may be changed and is the only way to do certain things) no index. I suspect it is because I write HTML5 apps, rather than websites (distinguishing feature: HTML5 apps have no 'you don't have javascript' fallbacks and they can't reasonably have any.).