1.6 KiB
1.6 KiB
title | pubDate | permalink | tags | |||||
---|---|---|---|---|---|---|---|---|
Custom coding standards and conventions | 2023-12-11 | daily/2023/12/11/custom-coding-standards-and-conventions |
|
Open-source projects like Drupal and Symfony have their own published coding standards and conventions.
For example, from Symfony's coding standards:
- Prefix all abstract classes with
Abstract
except PHPUnit*TestCase
. - Suffix interfaces with
Interface
; - Suffix traits with
Trait
;
And from Drupal's:
- Use an indent of 2 spaces, with no tabs.
- Lines should have no trailing whitespace at the end.
- Variables should be named using lowercase, and words should be separated either with uppercase characters (example:
$lowerCamelCase
) or with an underscore (example:$snake_case
). Be consistent; do not mix camelCase and snake_case variable naming inside a file.
But what about within custom applications?
Do you have your own agreed coding standards and conventions to keep the code consistent?
Do you explicitly follow the published coding standards, customise them, or follow something else?
Here's the thing
Do you know where to put new custom modules, how to name them and what conventions to follow when writing code?
Do you know where to add a new stylesheet to your theme?
If not, or it's implied, it's worth writing it down and being explicit - either within your project's or company's documentation or publicly.