<p>When you're writing open source code, such as a PHP library or a Drupal module, the larger it is, the harder it can be to reuse.</p>
<p>Each implementation will have its own requirements and specifics, so why have code that tries to do everything?</p>
<p>The smaller the code, the more reusable it is.</p>
<p>The most reusable code I've written have been in smaller modules, like the <a href="https://www.drupal.org/project/system_user">System User</a> and <a href="https://www.drupal.org/project/null_user">Null User</a> Drupal modules.</p>
<p>Both are very small and solve a specific problem.</p>
<p>The Null User module is used by the System User module to provide a default if no system user is defined.</p>
<p>It could have been part of the System User module, but extracting it into a separate module makes it more reusable.</p>
<p>It also makes System User leaner, less bloated and more focused on its use case and its own functionality.</p>
<p>This approach is based on the UNIX philosophy of a program doing one thing well, and chaining programs together when needed to solve a larger problem.</p>
<p>Then, if you need, you can extend the code in a custom module or add features <a href="/daily/2025/02/24/patch">by applying patches</a>.</p>
format:full_html
processed:|
<p>When you're writing open source code, such as a PHP library or a Drupal module, the larger it is, the harder it can be to reuse.</p>
<p>Each implementation will have its own requirements and specifics, so why have code that tries to do everything?</p>
<p>The smaller the code, the more reusable it is.</p>
<p>The most reusable code I've written have been in smaller modules, like the <a href="https://www.drupal.org/project/system_user">System User</a> and <a href="https://www.drupal.org/project/null_user">Null User</a> Drupal modules.</p>
<p>Both are very small and solve a specific problem.</p>
<p>The Null User module is used by the System User module to provide a default if no system user is defined.</p>
<p>It could have been part of the System User module, but extracting it into a separate module makes it more reusable.</p>
<p>It also makes System User leaner, less bloated and more focused on its use case and its own functionality.</p>
<p>This approach is based on the UNIX philosophy of a program doing one thing well, and chaining programs together when needed to solve a larger problem.</p>