PHP

Peer pressure of FIG

Fig standards and its assimilation into the PHP community is helping to make truly standardized coding and any PHP developer will tell you that it is long overdue, especially when even in one core PHP class you are using a mix of camel case with underscored methods.

But there is a worrying trend occurring. People are starting to go against how they like to code and what they find easy to read and use and instead of being consistent within their coding are now being effectively bullied into coding a completely different way. Maybe it is to not look like the odd one out on composer or the fact that their standard is not catered for because people who prefer to use camel case are the ones calling the shots, at the end of the day it doesn’t matter, what does matter is that instead of creating some standardized coding it is making people code a way they don’t like.

I am all up for ensuring that code standardization exists within a module but when you get two modules from two different authors you have to expect that whereas one author may like camel case the other finds it hard and cumbersome to work with.

Yes camel case works great for a huge number of times, yes camel case is shorter but then not all PHP functions are true English, some are anagrams of their longer selves. This means deciding where capitals are and should be can get harder when coding that function into usage in a file outside of the one it is declared in.

This is not a call to arms for the fight against camel case but more that people should embrace their own idea of what readable is but at the same time imply a standardization across their coding that echos throughout every file. This way once a user has learned how you program they can safely say the rest of your extension/library/whatever is coded the same way.

The same could be said for the spacing and new lines on methods, I personally dislike adding the opening bracket of a method on a new line, it makes things longer and harder to read due to length. In fact I would say doing this also disconnects the functions content from the function signature making it harder to associate that routine to the function in question.

And I understand that single spaces help in standardization but do we really need to add spaces around the condition of the statement like so:

if (0 === 0) {

?

All of these micro standardizations is actually making our code more complex and harder to read and maintain. Imagine an IDE that didn’t do that if statement spacing for you (Eclipse PDT for one). You now have to do that spacing yourself every fucking time. Imagine having to press enter twice the amount of times to define methods.

Many people say that micro-optimization is the killer of any good application, I would say that micro-standardization is the killer of any fun and exciting programming experience and creates nothing more than micro-stress.

Yes I understand that standardized spacing helps diffing on GitHub etc but seriously your really going to have to a problem with:

if(0 === 0){

compared to:

if (0 === 0) {

when diffing? No of course not. I am an avid user of GitHub and host numerous projects there but I wouldn’t care about such tiny spacing like that. It is the indentation spacing you care about, not tiny little things like that.

I hope the PHP community can put some of PSRs short comings behind them and allow people to just have fun while keeping standardization within their application and providing a basic guideline instead of the 10 commandments which seem to be bullying developers into writing code different to what is right for them.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s