Are you one of those developers that use to write code in some sort of cypher, whose only you understands, afraid of being ripped off of your code or seeing your job terminated?
Hopefully you will read this through because I have bad news to you.
To the rest of you, please continue. You will find value for sure.
WordPress community uses the tagline “code is poetry“. I rather think of code as a good prose, written with attention, using decent punctuation and with no hidden sense. Basically, going through all the “clean code” mantras.
Standard (male noun), which serves as a model or reference.
By definition, everything that may serve as a model or reference enabling consistency might be called a standard. Therefore, a standard may be just a coding guide style; or some well proofed formulas to specific problems, known as design patterns.
Standards adoption allows a better code readability. This means, your code will be more easy to be read by others. Contrary to the initial premise, more eyes over the code will improve the detection of bugs, security and performance flaws. This will also diminish the feeling of sole ownership, allowing a better knowledge share among the entire team. No, nobody will take your place…in fact, you will improve chances to become a better developer, and that will help you keep that job longer.
Design patterns aren’t a new thing, they exists quite some time and there’s an amazing book, written by the gang of 4 – Erich Gamma, Richard Helm, Ralph Johnson, John Vlissides – “Design Patterns: Elements of Reusable Object-Oriented Software“.
However, in this post I intend to focus more on style guides.
There’s a project called “PHP Framework Interop Group” where are debated which standards will be enforced by the PHP community. Related to style guides we have the PSR-1 (Basic Coding Standard) and the PSR-2 (Coding Style Guide). There’s a proposal for a new standard, the PSR-12 (Extended Style Guide) but it’s a draft in early stages.
WordPress, although its codebase is PHP, suggests a different style guide – WordPress Coding Standards – whom collides with the PSR-2. If your intent is plugin or theme development, or say you want to collaborate for the core codebase, you better respect the WordPress style guide.
In our team we follow the WordPress Coding Standards, but we added some rules of our own. Please, be free to read, use or contribute in our github.
CSS related, there are many methodologies like BEM (Block Element Modifier), which one we use at log.
Bottom-line, it does not matter if you will adopt the style guide A or B, but if any will be adopted by your entire team. That’s the biggest challenge and where the major benefits will arise. The feeling of share ownership will increase code quality. Better code quality will decrease the number of bug reports. Better code will be easy to maintain. Better code will enable your system to be more mature and stable. A better system will make you more proud of your work and soo as your employer.
As you see, the entire team will benefit, and so will you.