<p><a href="/daily/2023/12/04/writing-contrib-modules-as-glue-between-your-custom-code">In yesterday's email</a>, I mentioned the Private Message Queue module - a contributed Drupal module we wrote for a project as part of a contribution-first workflow.</p>
<p>In our experience, doing that and releasing Private Message Queue as its own open-source project encouraged more open-source contributions.</p>
<p>We started to ask questions like, "Which user should the messages be sent from?".</p>
<h2 id="system-users">System Users</h2>
<p>This led us to create the <a href="https://www.drupal.org/project/system_user">System User module</a>.</p>
<p>Inspired by system users in Linux, it provides a way to identify and retrieve system users that aren't tied to individuals' accounts and without relying on "magic" user IDs.</p>
<p>But what if a website doesn't have a system user?</p>
<h2 id="null-users">Null Users</h2>
<p>This led to the <a href="https://www.drupal.org/project/null_user">Null User module</a>.</p>
<p>Following the Null object pattern, if there isn't a system user, instead of returning <code>NULL</code> or <code>FALSE</code>, you return a null user that you use in the same way, though they'll have default empty values and won't perform any actions.</p>
<p>This pattern simplifies your code as you don't need to check for <code>NULL</code> or <code>FALSE</code> values.</p>
<h2 id="here%27s-the-thing">Here's the thing</h2>
<p>If I remember correctly, as part of the project, we created and released around ten new contributed modules to Drupal.org.</p>
<p>We were able to move straight onto the next phase of the project.</p>
<p>We didn't need to clean them up or refactor them beforehand. We didn't need to dedicate any additional time as they were already released.</p>
<p><a href="/daily/2023/12/04/writing-contrib-modules-as-glue-between-your-custom-code">In yesterday's email</a>, I mentioned the Private Message Queue module - a contributed Drupal module we wrote for a project as part of a contribution-first workflow.</p>
<p>In our experience, doing that and releasing Private Message Queue as its own open-source project encouraged more open-source contributions.</p>
<p>We started to ask questions like, "Which user should the messages be sent from?".</p>
<h2 id="system-users">System Users</h2>
<p>This led us to create the <a href="https://www.drupal.org/project/system_user">System User module</a>.</p>
<p>Inspired by system users in Linux, it provides a way to identify and retrieve system users that aren't tied to individuals' accounts and without relying on "magic" user IDs.</p>
<p>But what if a website doesn't have a system user?</p>
<h2 id="null-users">Null Users</h2>
<p>This led to the <a href="https://www.drupal.org/project/null_user">Null User module</a>.</p>
<p>Following the Null object pattern, if there isn't a system user, instead of returning <code>NULL</code> or <code>FALSE</code>, you return a null user that you use in the same way, though they'll have default empty values and won't perform any actions.</p>
<p>This pattern simplifies your code as you don't need to check for <code>NULL</code> or <code>FALSE</code> values.</p>
<h2 id="here%27s-the-thing">Here's the thing</h2>
<p>If I remember correctly, as part of the project, we created and released around ten new contributed modules to Drupal.org.</p>
<p>We were able to move straight onto the next phase of the project.</p>
<p>We didn't need to clean them up or refactor them beforehand. We didn't need to dedicate any additional time as they were already released.</p>