From a41c7a2e6501d9049dbc26a2fc6ac6eb38b05063 Mon Sep 17 00:00:00 2001 From: Oliver Davies Date: Tue, 12 Dec 2023 00:30:13 +0000 Subject: [PATCH] Add daily email for 2023-12-11 Custom coding standards and conventions --- src/content/daily-email/2023-12-11.md | 44 +++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 src/content/daily-email/2023-12-11.md diff --git a/src/content/daily-email/2023-12-11.md b/src/content/daily-email/2023-12-11.md new file mode 100644 index 00000000..bca03e94 --- /dev/null +++ b/src/content/daily-email/2023-12-11.md @@ -0,0 +1,44 @@ +--- +title: > + Custom coding standards and conventions +pubDate: 2023-12-11 +permalink: > + archive/2023/12/11/custom-coding-standards-and-conventions +tags: + - software-development + - php + - drupal + - symfony + - clean-code +--- + +Open-source projects like Drupal and Symfony have their own published coding standards and conventions. + +For example, from [Symfony's coding standards][symfony]: + +* Prefix all abstract classes with `Abstract` except PHPUnit `*TestCase`. +* Suffix interfaces with `Interface`; +* Suffix traits with `Trait`; + +And from [Drupal's][drupal]: + +* 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. + +[drupal]: https://www.drupal.org/docs/develop/standards/php/php-coding-standards +[symfony]: https://symfony.com/doc/current/contributing/code/standards.html