Re:Show HN: I decided to document and share my high-level CS...
by iaskwhy on Monday March 12, 2012 @11:23AM
(#3693828)
Why "We use hyphen delimited, lowercase selectors: .thisIsBad{}, .this_is_also_bad{} but .this-is-correct{}"? I understand if the point is about the styles itself having hyphens, like padding-bottom, but it breaks the complete expression selection with ctrl+arrows (or even with the double mouse click) which I find much more annoying than using underscores instead of hyphens. I'm biased though, I prefer underscores to camelCase anytime (I do obey whatever is the rule on any project).
[ Parent
| on HN ]
Re:Show HN: I decided to document and share my high-level CS...
by edd on Monday March 12, 2012 @11:46AM
(#3693948)
The reason I would advocate using hyphens is you should do what the language (standard libraries) do. For example:
css:
margin-left, border-bottom (hyphenate)
javascript:
getElementById, documentNode (lower camel case)
ruby:
each_index, has_key? (underscore)
Re:Show HN: I decided to document and share my high-level CS...
by iaskwhy on Monday March 12, 2012 @01:27PM
(#3694454)
This would be an interesting discussion. I prefer to use the same coding style for the whole project without caring how the original authors of each language did it. I do however understand that the language API follows the original convention so one would eventually break it by following by reasoning. Ex in js: make_element_slide(getElementById('box')).
Re:Show HN: I decided to document and share my high-level CS...
by csswizardry on Monday March 12, 2012 @11:25AM
(#3693844)
No reason other than that is what I started off with and I’d rather keep things consistent. Had I started off with underscores then I’d be asking the team to stick with that.
I guess that section is more about ‘keep everything the same’ rather than ‘we must specifically use hyphens’ :)
Cheers, H
Re:Show HN: I decided to document and share my high-level CS...
by bung on Monday March 12, 2012 @11:44AM
(#3693931)
I recently brought this up with my own team after updating a 4-language piece on a project. It was originally pieced together at different times and was inconsistent. However, I was testing the waters with them trying to sell them on underscores.
We've all been using dashes in CSS for so long, but nowadays I personally feel like I'm writing so much JS that I'm longing for underscores.
Downsides: 1. You have to press shift a lot more when writing css 2. ???
Upsides: 1. You can use the "same_name" in CSS and JS 2. You can double-click easily
Feel free to expand on this, we haven't made the change, it's just something that crossed my mind recently :)
Re:Show HN: I decided to document and share my high-level CS...
by MatthewPhillips on Monday March 12, 2012 @12:19PM
(#3694118)
Underscores in JavaScript are non-standard too.