- This topic is empty.
February 21, 2014 at 11:15 am #163656
How do you name your classes? Like this:
or like this:
I prefer camelCase.February 21, 2014 at 12:43 pm #163671SenffParticipant
.class-oneFebruary 21, 2014 at 12:46 pm #163673mcjohnstParticipant
Follow the conventions of the language
$my_var = ”;
var myVar = ”;February 21, 2014 at 1:26 pm #163681
I’m fully aware that this is superficial… but I’ve always DETESTED the copious amounts of underscores in PHP. It literally hurts my eyes to stare at a bunch of PHP.
The hyphens are ok but sometimes they visually start to blend in with properties. I understand that this is what syntax highlighting and indentation is for but I like to see a really clear difference. Especially when I look at my code on Github or in a terminal where there is no syntax highlighting. It’s really nice to have the visual breakup.February 21, 2014 at 1:39 pm #163684AlenParticipant
I’m trying to find a great article about how we read. will find it eventually…
Anyways, it basically said that we read or skip at the top of the letters… I’m probably butchering the explanation. If you were to take a line of text and cut it in half horizontally you would still be able to read it…
So this_would_be_most_legible… But I do agree that you should follow conventions mentioned by @mcjohnstFebruary 21, 2014 at 2:06 pm #163691
It couldn’t be this:
This one actually sides with Camel Case to some degree:
Considering all four hypotheses together, it becomes evident that the camel case style leads to better all around performance once a subject is trained on this style. Training is required to quickly recognize such an identifier.
Anyway, I was just curious on what people use.February 21, 2014 at 2:06 pm #163692
I think it’s ironic that my handle has an underscore and I hate them… just another reason to change it. :)February 21, 2014 at 2:08 pm #163693
Next we should talk about 2 vs. 4 spaces.February 21, 2014 at 2:48 pm #163701
I use both, to an extent, plus some others.
- I use camelCase in most situations. I find it easiest to read and write.
- I use under_scores in cases where there is a logical separation between groups of words: for example,
getLocale_byRegionclearly do the same thing, and the difference between the two methods is also obvious. Likewise, I might have an
HTTPResponse_HTMLclass, and an
I know your question is about CSS classes, but I tend to use the same logic for my naming conventions everywhere. The one I haven’t shaken (yet) is using basically all caps for SQL. I hate that, but it’s a very strong habit.
Some other conventions I follow:
- As in many frameworks (across languages), _leadingUnderscores denote non-public properties or methods.
- I use TitleCase for the names of concrete classes.
- I use ALL_CAPS for global constants (though I buck the status quo and use TitleCase for class constants).
Next we should talk about 2 vs. 4 spaces.
there is nothing to talk about.February 21, 2014 at 3:03 pm #163704
there is nothing to talk about.
I prefer 4… just saying.February 21, 2014 at 3:49 pm #163711
I prefer 4… just saying.
I like how you never even acknowledged that there might be a choice between “tabs” and “spaces.” : )February 21, 2014 at 4:34 pm #163712
I was going to acknowledge it but I didn’t want it to get contentious. This is holy war territory!
Truth be told… I use tabs so I can type less. I know some people say you’re not supposed to because if you send the file or use a different text editor, spacing can get messed up, blah blah blah.
I set Sublime Text 2 tab width to 4 spaces and never think about it again.February 21, 2014 at 5:11 pm #163713
Absolutely right – I use the tab key, but there are no tab characters in my script.February 21, 2014 at 6:12 pm #163714AlenParticipant
I use Tab as well, only 2 spaces tho… I set my padding top/bottom so it all reads very nicely…February 21, 2014 at 9:36 pm #163716
I use the tab key, but there are no tab characters in my script.
Same here. Sublime Text 2 interprets the tabs to make them spaces.
I’m still thinking about learning Vim. I’ve got it installed.
- The forum ‘Other’ is closed to new topics and replies.