Welcome Guest, Not a member yet? Register   Sign In
Why cant everyone adapt to the coding guidelines?
#1

[eluser]Johan André[/eluser]
Hey!

Just a quick reflection:

I'm looking through the forum on a daily (well, sometimes several times a day) basis.
This forum houses some great user-contributed resources like librarys, plugins and addons.
Alot of the content is very good and usable but the coding standards used varies alot.

This does not (always) compromise the functions ofcourse but to me it's rather troublesome to go through a couple of hundred lines of code and change "invalid" class-names, method-names and variables before using it in my own projects.

Codeigniter has great coding guidelines in the userguide and I think everyone should use them for creating distributed content for the framework.

For instance, I see this alot:

Code:
$this->my_library->getStuff();

When it should look like (according to the coding guidelines):

Code:
$this->my_library->get_stuff();

Ofcourse, everyone has their own preferences regarding coding guidelines and I don't wanna be picky about it... (which I just realized I am) Smile
#2

[eluser]TheFuzzy0ne[/eluser]
I totally agree with what you're saying. A lot of people do adhere closely to those recommendations, but some folks are more happy sticking with what they feel comfortable with. To be honest, I feel that as long as a particular library sticks to using one method for declaring method names, and don't mix them, I don't have a problem with that.

Also, I think it's fairly safe to say that not everyone is actually aware of the Style Guide. I would like to suggest you run a poll to see how many people know of the Style Guide, and how many people don't. If you can think of a way to raise awareness of the Style Guide, please let me know, and I will be happy to help.

One more thing, however, is that the Style Guide is exactly that. It's a "guide". It's not a set of rules that must be followed. CodeIgniter is all about letting people code in a way that's comfortable for them, it's not about making them code the way a few people (or even the majority for that matter), say they should.

All the best!
#3

[eluser]jdfwarrior[/eluser]
I agree with both of you, and especially with Fuzzy. It's not that others are doing it wrong. They are doing it in the way that is natural to them.
#4

[eluser]xwero[/eluser]
I agree with TheFuzzy0ne about method consistency in a library/helper/plugin/other. The EL developers chosen the underscore style but there are a lot of developers that use the camelcase style.

I'm blind for the function name styles, i guess php functions made me numb for style Smile
#5

[eluser]jdfwarrior[/eluser]
Just a note: I was looking back over the Style Guide and noticed, things listed in the Alternative PHP Syntax page, are actually listed as "bad" in the style guide. For example, using <?=$variable?> to echo something. That is used as an example in the Alternative PHP Syntax page, and then the same syntax is shown as Incorrect in the style guide under Short Open Tags. I'm guilty of this one.

I pretty much follow the style guide for everything else, not because it taught me, just because that's how I've always coded. If I had started differently.. I don't think the style guide would have changed me Smile
#6

[eluser]TheFuzzy0ne[/eluser]
I agree. PHP functions are the worst culprits for inconsistent function names...
#7

[eluser]GSV Sleeper Service[/eluser]
personally I can't stand CamelCase, underscores_all_the_way_for_me!
#8

[eluser]jedd[/eluser]
[quote author="xwero" date="1236283732"]
I'm blind for the function name styles, i guess php functions made me numb for style Smile[/quote]

A beautiful observation!

I dislike camelcase, particularly with the exception for the first character. Exceptions are bothersome things. I find underscores far more readable, particularly on a small display. I dislike CI's indenting style, and stick with mine throughout my own code. CI's style guide eschews short tags, and I can entirely agree - I think it fits under the general heading of 'stick with one way of doing each thing in your code'. The only rationale I've heard for it (much like templating) is that it makes it easier for 'creative types' to deal with the pseudo-HTML they might have to look at, and there's no creative types around here. Wink

I've always felt true looks better than TRUE but that might come down to having a colourful IDE. (In vi, f.e., I could see the benefit of uppercasing true, false and null.) I like their rationale for using OR rather than || but often forget to do this (old habits etc). I do tend to force multiple conditionals over multiple lines, which improves readability anyway. I only discovered === about 18 months ago, and try to use it where appropriate, but I got into a habit of casting things I wasn't sure about (probably a bad habit) a while back, so === isn't so useful. And I really dislike using plurals for database table names (they tacitly encourage this behaviour). I've always used tabs for indenting so that one was easy, as was saving with unix linebreaks (I made the right decision in 1995 after all! Smile.

I'm unsure about always using ' to quote strings, mostly due to several years of using ", and because with a ' I find there are more occasions where I need escape things (strings more often contain ' than a "). Plus I never use a $var within a quote (' or ") - it seems to me that . is cheap and far more readable - so no advantages for me there.
#9

[eluser]Eric Barnes[/eluser]
I also think Pear and Zend recommend using camel case in their guides.
Quote:Class variables (a.k.a properties) and methods should be named using the "studly caps" style (also referred to as "bumpy case" or "camel caps"). Some examples (these would be "public" members):

So that may be part of the reason some people do it one way. But I tend to agree it is whatever you are used to. Just try and keep them standard in your own code.




Theme © iAndrew 2016 - Forum software by © MyBB