Jump to content

I like Allman style and tabs. Convince me to use PSR-2.


Sarke

Recommended Posts

I like my braces style and I like my tabs.  But I also realize there is benefit to using PSR-2 for more standard code when it comes to collaborating and contributing to open-source (some of which demand it).

 

What compelling arguments can you make that I should switch to PSR-2 for all my PHP coding?

Link to comment
Share on other sites

The easy and less rude (to PHP-FIG) way to answer that is that (a) they're recommendations for a standard and (b) they're aimed towards establishing a common practice for open-source projects and not necessarily for individuals.

 

Personally I don't care for all their standards either. Especially about code style. They're not official and they don't even represent the PHP community as a whole.

Link to comment
Share on other sites

The cool folks over at Sensio Labs have a tool you can use to format your existing code:  http://cs.sensiolabs.org/  

 

So even if you don't want to code in a particular style there's an option to let them format it for you.  Also gives you an easy way to mod things and see how they look in  different style.

Link to comment
Share on other sites

The coding indentation style is something like which side of the road you are driving. It doesn’t make any difference except if you are driving opposite in others in this road. Yes there are numerous studies that suggest the one side of the road over the other as I guess there could be with indentation style. That means that if you have any important reason to have your code PSR-2 “compliant” then you should abandon Allman style and use their rules.

 

Allman style is wired in my brain , even in some projects that I had to write in K&R , I eventually wrote in Allman and then had a second IDE (Eclipse) with K&R configurations to change it and make the commits and updates in SVN. I really can’t understand why people prefer other indention style but equally I can’t understand why some people think the blue color relates to sadness and therefore dislike it. I can be friend and coworker with a person that hates blue , it is a matter of taste. So yes I can work in a non Allman style environment, but my taste in coding indention probably wont change.

 

 

Many things have being wrote about Allman vs everything else, many times when I talk to a person that is strongly opposed to Allman I ask “in how many OOP languages do you write code this epoch ? ”. The answer is usually from none to one. I were a Java enthusiastic at mid 90’s , all the official books from Sun were in Allman , luckily this went well with my previous programming indentation style experience in C and C++. When PHP became really OOP (after version 5) I jumped in. I can see that Allman is in decline in amateurs code, that’s sad for me , but again it is a matter of taste.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.