80 lines
2.7 KiB
YAML
80 lines
2.7 KiB
YAML
uuid:
|
|
- value: 19a48fd0-5e10-496b-b08c-1ed47ad6b2a9
|
|
langcode:
|
|
- value: en
|
|
type:
|
|
- target_id: daily_email
|
|
target_type: node_type
|
|
target_uuid: 8bde1f2f-eef9-4f2d-ae9c-96921f8193d7
|
|
revision_timestamp:
|
|
- value: '2025-05-11T09:00:08+00:00'
|
|
revision_uid:
|
|
- target_type: user
|
|
target_uuid: b8966985-d4b2-42a7-a319-2e94ccfbb849
|
|
revision_log: { }
|
|
status:
|
|
- value: true
|
|
uid:
|
|
- target_type: user
|
|
target_uuid: b8966985-d4b2-42a7-a319-2e94ccfbb849
|
|
title:
|
|
- value: 'Types add context'
|
|
created:
|
|
- value: '2024-08-17T00:00:00+00:00'
|
|
changed:
|
|
- value: '2025-05-11T09:00:08+00:00'
|
|
promote:
|
|
- value: false
|
|
sticky:
|
|
- value: false
|
|
default_langcode:
|
|
- value: true
|
|
revision_translation_affected:
|
|
- value: true
|
|
path:
|
|
- alias: /daily/2024/08/17/types-add-context
|
|
langcode: en
|
|
body:
|
|
- value: |
|
|
<p>In yesterday's email, I wrote about why <a href="/daily/2024/08/16/what-are-err--req-and-res">readable variable names are important</a> and why I use descriptive variable names in my code.</p>
|
|
|
|
<p>Given this pseudo-code:</p>
|
|
|
|
<pre><code class="php">function hande(req, res) {
|
|
}
|
|
</code></pre>
|
|
|
|
<p>With the short variable names, whilst you can guess, it's unclear what the variable names are.</p>
|
|
|
|
<p>However, in this code, we have the same variable names, but we also have additional type information:</p>
|
|
|
|
<pre><code class="php">function handle(Request req, Response res): void {
|
|
}
|
|
</code></pre>
|
|
|
|
<p>Even with the same variable names, I know what their types are and what the function returns, I have better completions and diagnostics in my editor and better static analysis of my code, making it easier to identify and fix potential bugs.</p>
|
|
|
|
|
|
format: full_html
|
|
processed: |
|
|
<p>In yesterday's email, I wrote about why <a href="/daily/2024/08/16/what-are-err--req-and-res">readable variable names are important</a> and why I use descriptive variable names in my code.</p>
|
|
|
|
<p>Given this pseudo-code:</p>
|
|
|
|
<pre><code class="php">function hande(req, res) {
|
|
}
|
|
</code></pre>
|
|
|
|
<p>With the short variable names, whilst you can guess, it's unclear what the variable names are.</p>
|
|
|
|
<p>However, in this code, we have the same variable names, but we also have additional type information:</p>
|
|
|
|
<pre><code class="php">function handle(Request req, Response res): void {
|
|
}
|
|
</code></pre>
|
|
|
|
<p>Even with the same variable names, I know what their types are and what the function returns, I have better completions and diagnostics in my editor and better static analysis of my code, making it easier to identify and fix potential bugs.</p>
|
|
|
|
|
|
summary: null
|
|
field_daily_email_cta: { }
|