php-coding-standard-generator icon indicating copy to clipboard operation
php-coding-standard-generator copied to clipboard

Avoid "best practice"

Open joeyhub opened this issue 6 years ago • 0 comments

There's a lot of misuse or vague use of the term "best practice" and this tends to be a vague yet charged statement.

For example:

It is considered best practice to use the camelCase notation to name attributes.

This isn't so much of a best practice as it is a convention or a standard practice. In line with common sense, most people would say it's a good practice to follow convention or standards by default and that's generally a fair statement.

I'd consider actually splitting into their own category convention related checks.

It's more clearly stated further down...

The convention is to name these methods 'isX()' or 'hasX()'.

I think there's a bit of confusion here as well as you have layers of conventions. Generally speaking specifically what we're really doing here is using the Java style OOP conventions which is commonly adopted in PHP which also uses Java inspired OOP.

Using camelCase isn't by any standard a best practice. While it's an OOP standard convention and it's generally good to not deviate for no purpose, it's also deficient for scripting (metacoding) where machine readable names are particularly useful (coding by convention, etc). The camelCase format is intended much more for human readability and clashes with libraries using a different approach to programming.

It says for a whole bunch of fields repetitively "some people consider it a best practice" which really shows that's gone down too far, the practices discussion needs to be no the parent node, not repeated on every leaf node. Putting it on the parent node means it can also afford to be a little longer and more meaningful.

joeyhub avatar Mar 26 '19 11:03 joeyhub