<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Cédric Françoys</title>
    <description>The latest articles on DEV Community by Cédric Françoys (@cedricfrancoys).</description>
    <link>https://dev.to/cedricfrancoys</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1029143%2Fd0c6515a-e50b-41ea-84e3-8038a97d32d6.jpg</url>
      <title>DEV Community: Cédric Françoys</title>
      <link>https://dev.to/cedricfrancoys</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/cedricfrancoys"/>
    <language>en</language>
    <item>
      <title>Style Guide Proposal: Parentheses and Braces in PHP</title>
      <dc:creator>Cédric Françoys</dc:creator>
      <pubDate>Sat, 14 Jun 2025 17:10:40 +0000</pubDate>
      <link>https://dev.to/cedricfrancoys/style-guide-proposal-parentheses-and-braces-in-php-1pnn</link>
      <guid>https://dev.to/cedricfrancoys/style-guide-proposal-parentheses-and-braces-in-php-1pnn</guid>
      <description>&lt;h2&gt;
  
  
  Objective
&lt;/h2&gt;

&lt;p&gt;This document presents a thorough reflection on how to establish a readable, rigorous, and coherent coding syntax for the use of &lt;strong&gt;parentheses&lt;/strong&gt; and &lt;strong&gt;braces&lt;/strong&gt; in PHP. Rather than perpetuating historical conventions inherited from languages like C or Java, it is based on a clear principle: &lt;strong&gt;code should reflect the logic of the language, not formatting habits&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;The goal of this proposal is to define a style that is:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Unified&lt;/strong&gt;: one rule applies uniformly across all relevant constructs—functions, control structures, or inner expressions;&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Systematic&lt;/strong&gt;: each rule follows directly from syntactic structure, not from lexical category (keyword, identifier, etc.);&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Consistent&lt;/strong&gt;: treatment is aligned across similar cases, with no arbitrary exceptions;&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Easy to remember&lt;/strong&gt;: by eliminating contextual variations and aesthetic distinctions with no functional value.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;We aim to define a stylistic syntax that requires no extra effort in visual classification but aligns closely with the intrinsic mechanisms of PHP.&lt;/p&gt;

&lt;h2&gt;
  
  
  Syntax should follow structure, not appearance
&lt;/h2&gt;

&lt;p&gt;PHP has an explicit grammar where the syntactic category of each construct (function, control structure, expression) is clearly distinguishable by any developer familiar with the language. Therefore, it is unnecessary to introduce stylistic variations based solely on the lexical appearance of preceding elements.&lt;/p&gt;

&lt;p&gt;For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$x&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="mf"&gt;...&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="nf"&gt;foo&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$x&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In the first case, &lt;code&gt;if&lt;/code&gt; is a control structure; in the second, &lt;code&gt;foo&lt;/code&gt; is a function. Both use parentheses to wrap an expression. Yet, common conventions (e.g., PSR-12) require a &lt;strong&gt;space after &lt;code&gt;if&lt;/code&gt;&lt;/strong&gt; but &lt;strong&gt;forbid a space after &lt;code&gt;foo&lt;/code&gt;&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Why apply two different rules to the same syntactic form? This discrepancy adds no real readability. A developer can already distinguish between &lt;code&gt;if&lt;/code&gt; and &lt;code&gt;foo&lt;/code&gt;. Style should not compensate for distinctions that are inherently clear in the language.&lt;/p&gt;

&lt;p&gt;Similarly, braces &lt;code&gt;{}&lt;/code&gt; are lexical scope delimiters. Their placement should follow a consistent principle regardless of context—whether opening a function, a loop, or any other block.&lt;/p&gt;

&lt;p&gt;The central thesis is: &lt;strong&gt;a shared syntactic structure should imply a shared visual representation&lt;/strong&gt;, independent of the preceding token's semantic role (keyword or identifier).&lt;/p&gt;

&lt;h2&gt;
  
  
  Inherited conventions introduce confusion
&lt;/h2&gt;

&lt;p&gt;Prevalent style guides such as PSR-2 and PSR-12 inherit patterns from C-like languages. They enforce distinctions in formatting between constructs that are structurally similar. For example:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A function declaration must place its opening brace on the &lt;strong&gt;next line&lt;/strong&gt;:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;  &lt;span class="k"&gt;function&lt;/span&gt; &lt;span class="n"&gt;foo&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="mf"&gt;...&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;A control structure like &lt;code&gt;if&lt;/code&gt; must place the brace on the &lt;strong&gt;same line&lt;/strong&gt;:
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$x&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="mf"&gt;...&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;A space is required after &lt;code&gt;if&lt;/code&gt;, but forbidden after &lt;code&gt;foo()&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These distinctions are justified by aesthetic or historical preferences rather than grammatical necessity. They introduce a &lt;strong&gt;needless cognitive load&lt;/strong&gt;, requiring developers to memorize exceptions instead of applying a predictable rule.&lt;/p&gt;

&lt;p&gt;They also complicate the implementation of formatting tools, which must apply conditional logic rather than universal patterns. In collaborative settings, these irregularities can lead to stylistic debates or merge conflicts that are purely formal.&lt;/p&gt;

&lt;p&gt;In the end, these conventions hinder clarity and maintainability for the sake of outdated visual expectations.&lt;/p&gt;

&lt;h2&gt;
  
  
  Synthesis: Toward a uniform, logical, and rule-based syntax
&lt;/h2&gt;

&lt;p&gt;A better alternative is to derive style directly from the language's actual structure. This means:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;No space before opening parentheses&lt;/strong&gt;, regardless of preceding token: &lt;code&gt;if($x)&lt;/code&gt;, &lt;code&gt;while($y)&lt;/code&gt;, &lt;code&gt;foo($z)&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Opening braces always on the same line&lt;/strong&gt; as the controlling statement: &lt;code&gt;function bar() {&lt;/code&gt;, &lt;code&gt;if($x) {&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Closing braces alone on their own line&lt;/strong&gt;, aligned with the block start.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This results in:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Simplified comprehension&lt;/li&gt;
&lt;li&gt;Seamless compatibility with automated formatting tools (e.g., PHP-CS-Fixer, linters)&lt;/li&gt;
&lt;li&gt;A visually clean and vertically structured codebase&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The benefits are twofold:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;For individual developers&lt;/strong&gt;: fewer edge cases to remember, greater focus on logic&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;For teams&lt;/strong&gt;: less friction in code reviews, clear conventions easy to share and enforce&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Special case: &lt;code&gt;if/elseif/else&lt;/code&gt; and &lt;code&gt;try/catch/finally&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;A specific question arises regarding &lt;code&gt;if/elseif/else&lt;/code&gt; and &lt;code&gt;try/catch/finally&lt;/code&gt;, where it is common to begin the next block directly after a closing brace:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$x&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="mf"&gt;...&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;elseif&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$y&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="mf"&gt;...&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="mf"&gt;...&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="k"&gt;try&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="mf"&gt;...&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;catch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Exception&lt;/span&gt; &lt;span class="nv"&gt;$e&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="mf"&gt;...&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;finally&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="mf"&gt;...&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;While syntactically valid and widely accepted, these are the &lt;strong&gt;only cases&lt;/strong&gt; where a new structure follows immediately after a closing brace on the same line.&lt;/p&gt;

&lt;p&gt;Following the principle of minimizing stylistic exceptions, this behavior should be reconsidered. Specifically:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;PHP does &lt;strong&gt;not require&lt;/strong&gt; chaining these blocks on the same line.&lt;/li&gt;
&lt;li&gt;Although &lt;code&gt;else&lt;/code&gt;, &lt;code&gt;catch&lt;/code&gt;, and &lt;code&gt;finally&lt;/code&gt; are syntactically dependent (they cannot start independently), this &lt;strong&gt;does not justify&lt;/strong&gt; a distinct visual form.&lt;/li&gt;
&lt;li&gt;Maintaining vertical alignment enhances structure visibility.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Proposed rule
&lt;/h3&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;All blocks (&lt;code&gt;if&lt;/code&gt;, &lt;code&gt;else&lt;/code&gt;, &lt;code&gt;elseif&lt;/code&gt;, &lt;code&gt;try&lt;/code&gt;, &lt;code&gt;catch&lt;/code&gt;, &lt;code&gt;finally&lt;/code&gt;) must start on a new line after the previous block’s closing brace.&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;This ensures:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;No stylistic exceptions&lt;/li&gt;
&lt;li&gt;Clear vertical structure&lt;/li&gt;
&lt;li&gt;Uniform block detection&lt;/li&gt;
&lt;/ul&gt;

&lt;h4&gt;
  
  
  Preferred example:
&lt;/h4&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="k"&gt;if&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$x&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="mf"&gt;...&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="k"&gt;elseif&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$y&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="mf"&gt;...&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="mf"&gt;...&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="k"&gt;try&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="mf"&gt;...&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="k"&gt;catch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nc"&gt;Exception&lt;/span&gt; &lt;span class="nv"&gt;$e&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="mf"&gt;...&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="k"&gt;finally&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="mf"&gt;...&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This rule aligns fully with the overall goals of this guide: to reduce special cases and avoid tying formatting to specific keywords.&lt;/p&gt;

&lt;h3&gt;
  
  
  Modern extensions: arrow functions and ternary expressions
&lt;/h3&gt;

&lt;p&gt;Some newer constructs in PHP raise stylistic questions, though they typically do not involve braces.&lt;/p&gt;

&lt;h4&gt;
  
  
  Arrow functions (&lt;code&gt;fn&lt;/code&gt;)
&lt;/h4&gt;

&lt;p&gt;Introduced in PHP 7.4, these use parentheses for parameters and a single expression (no braces).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Guideline&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;No space between &lt;code&gt;fn&lt;/code&gt; and &lt;code&gt;(&lt;/code&gt;:&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Do&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;  &lt;span class="nv"&gt;$f&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;fn&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$x&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nv"&gt;$x&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Don't&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;  &lt;span class="nv"&gt;$f&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;fn&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$x&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nv"&gt;$x&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  Ternary expressions (&lt;code&gt;? :&lt;/code&gt;)
&lt;/h4&gt;

&lt;p&gt;These are expression-level constructs. The goal is to promote clarity:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Guidelines&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Use parentheses to wrap nested or complex sub-expressions.&lt;/li&gt;
&lt;li&gt;Insert spaces around &lt;code&gt;?&lt;/code&gt; and &lt;code&gt;:&lt;/code&gt; like any binary operator.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Examples&lt;/strong&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="nv"&gt;$result&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nv"&gt;$x&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="o"&gt;?&lt;/span&gt; &lt;span class="s1"&gt;'positive'&lt;/span&gt; &lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'negative'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="nv"&gt;$message&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$x&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="o"&gt;?&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nv"&gt;$x&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt; &lt;span class="o"&gt;?&lt;/span&gt; &lt;span class="s1"&gt;'large'&lt;/span&gt; &lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'small'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="o"&gt;:&lt;/span&gt; &lt;span class="s1"&gt;'zero'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;These are not subject to brace-related rules and are best covered by expression formatting standards.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;A style rule has value only if it &lt;strong&gt;enhances structure without interfering with it&lt;/strong&gt;. Code should reflect program logic—not act as a canvas for visual conventions.&lt;/p&gt;

&lt;p&gt;By choosing a unified syntax based on structural grammar, this guide offers a rational, consistent, and modern approach to writing PHP. It abandons historical formatting quirks in favor of sustainable, generalizable principles.&lt;/p&gt;

&lt;p&gt;This is not about personal preference, but about redefining the foundations of PHP style on clear, durable, and logically grounded rules. The following sections will present each rule, its application, edge cases, and practical implications.&lt;/p&gt;

&lt;h3&gt;
  
  
  A Note on Perspective and Adoption
&lt;/h3&gt;

&lt;p&gt;I am fully aware that proposing an alternative style guide is unlikely to change much. While this document lays out a coherent and logically structured alternative, I have little hope it will shift the current conventions in any significant way.&lt;/p&gt;

&lt;p&gt;Most developers don’t genuinely care about syntactic consistency—as long as their code runs, builds, and passes the linter. Habits are deeply entrenched. Furthermore, the prevalence of established standards like PSR means that any deviation, however justified, is perceived as unnecessary friction.&lt;/p&gt;

&lt;p&gt;And the arrival of AI doesn’t help. On the contrary, it reinforces the inertia. Most code generated by AI tools blindly follows existing PSR-style rules. The AI doesn’t reason about syntax—it imitates. The more these tools are used, the more the current conventions become self-reinforcing, regardless of whether they were ever truly optimal.&lt;/p&gt;

&lt;p&gt;This guide is not an attempt to fight that tide. Rather, it is an exercise in principled reasoning. If the future of coding is to be increasingly automated, we should at least strive to encode principles that are internally consistent, teachable, and deducible—rather than inherited from historical precedent or aesthetic legacy.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>programming</category>
      <category>php</category>
      <category>overthinking</category>
    </item>
    <item>
      <title>End-to-End Application: A Complex Challenge</title>
      <dc:creator>Cédric Françoys</dc:creator>
      <pubDate>Tue, 20 Aug 2024 12:24:03 +0000</pubDate>
      <link>https://dev.to/cedricfrancoys/end-to-end-application-a-complex-challenge-431j</link>
      <guid>https://dev.to/cedricfrancoys/end-to-end-application-a-complex-challenge-431j</guid>
      <description>&lt;p&gt;Developing an end-to-end application is an extremely complex task that requires a multitude of skills that few individuals possess alone. &lt;/p&gt;

&lt;p&gt;That's where FullStack developers come in.&lt;/p&gt;

&lt;p&gt;To overcome this challenge, it is crucial to implement advanced strategies and architectures that promote scalability, maintainability, and security.&lt;/p&gt;

&lt;p&gt;One of the most effective approaches is adopting &lt;strong&gt;microservices&lt;/strong&gt;. By dividing the application into small, independent services, each responsible for a specific functionality, management and evolution of the whole are facilitated. This modularity is further enhanced by containerization, which allows these services to be deployed and managed consistently across different environments, simplifying deployment and increasing scalability.&lt;/p&gt;

&lt;p&gt;Going even further, &lt;strong&gt;serverless&lt;/strong&gt; architecture offers a solution where developers can focus exclusively on the code without worrying about server management, while benefiting from automatic scalability. This approach is often combined with an API-First design, ensuring that integration and communication between different services and components are smooth and efficient.&lt;/p&gt;

&lt;p&gt;In terms of reactivity and real-time processing, &lt;strong&gt;Event-Driven&lt;/strong&gt; Architecture is a wise choice. By structuring the application around events, its responsiveness and ability to handle variable loads can be significantly improved. &lt;br&gt;
At the same time, Domain-Driven Design (&lt;strong&gt;DDD&lt;/strong&gt;) helps structure development around the business domain, offering a model-centric approach to solving complex problems.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;CQRS&lt;/strong&gt; (Command Query Responsibility Segregation) adds another dimension by separating read and write operations, thus optimizing performance and scalability. This philosophy is complemented by Hexagonal Architecture, which isolates the business domain from user interfaces and infrastructure, making the application easier to test and evolve.&lt;/p&gt;

&lt;p&gt;To structure the application modularly, Layered Architecture (or &lt;strong&gt;MVC&lt;/strong&gt;) remains a classic. It clearly separates presentation, business logic, and data access responsibilities. In an increasingly cloud-centric world, adopting Cloud-Native Architecture becomes indispensable for fully leveraging the services and features of cloud providers.&lt;/p&gt;

&lt;p&gt;Security and compliance cannot be overlooked. Implementing robust authentication mechanisms, such as &lt;strong&gt;OAuth&lt;/strong&gt; or &lt;strong&gt;JWT&lt;/strong&gt;, is essential to secure application access. Concurrently, defining and enforcing strict security policies ensure the protection of sensitive data and compliance with current regulations.&lt;/p&gt;

&lt;p&gt;Adhering to relevant ISO standards is also crucial to ensure the quality and security of the application. Finally, adopting Test-Driven Development (&lt;strong&gt;TDD&lt;/strong&gt;) and implementing continuous integration and deployment pipelines (&lt;strong&gt;CI/CD&lt;/strong&gt;) not only improves code quality but also accelerates the development cycle.&lt;/p&gt;

&lt;p&gt;By being aware of these strategies and best practices, it becomes possible to navigate the complexity of developing an end-to-end application, even for a stand-alone fullstack developer.&lt;/p&gt;

&lt;p&gt;If you're looking for a framework to achieve that: have a look at this open source framework : &lt;a href="https://github.com/equalframework/equal" rel="noopener noreferrer"&gt;https://github.com/equalframework/equal&lt;/a&gt;&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>developers</category>
      <category>fullstack</category>
    </item>
    <item>
      <title>Dates References: A Timely Affair</title>
      <dc:creator>Cédric Françoys</dc:creator>
      <pubDate>Wed, 12 Jun 2024 19:35:15 +0000</pubDate>
      <link>https://dev.to/cedricfrancoys/dates-references-a-timely-affair-2kmh</link>
      <guid>https://dev.to/cedricfrancoys/dates-references-a-timely-affair-2kmh</guid>
      <description>&lt;p&gt;&lt;strong&gt;One notation to rule them all&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;For some time now, I've been working on a &lt;a href="https://github.com/equalframework/equal" rel="noopener noreferrer"&gt;Web App framework&lt;/a&gt;, and this led me to think about a lot of things, amongst which data typing.&lt;/p&gt;

&lt;p&gt;eQual provides a structured way to reference dates allowing to describe and retrieve any date based on the current date, which can be used in Domains for filtering or conditioning visibility. &lt;/p&gt;

&lt;p&gt;Date References allow to reference dates relatively to various intervals and dynamically compute dates for a wide range of scenarios by combining methods and parameters.&lt;/p&gt;

&lt;p&gt;A &lt;strong&gt;Date Reference&lt;/strong&gt; descriptor is built using the following structure :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;date.&amp;lt;origin&amp;gt;(&amp;lt;offset&amp;gt;).&amp;lt;interval&amp;gt;.&amp;lt;method&amp;gt;(&amp;lt;arguments&amp;gt;)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;or, in a more explicit notation :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;date.{this|prev|next}[(&amp;lt;offset&amp;gt;)].{day|week|month|quarter|semester|year}.{first|last|get(reference:index)}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Attributes and Arguments
&lt;/h3&gt;

&lt;h4&gt;
  
  
  1. Origin
&lt;/h4&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Method&lt;/th&gt;
&lt;th&gt;Description&lt;/th&gt;
&lt;th&gt;Offset&lt;/th&gt;
&lt;th&gt;Possible Values&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;prev(n)&lt;/td&gt;
&lt;td&gt;Previous period with an offset of n intervals&lt;/td&gt;
&lt;td&gt;n &amp;gt; 0&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;prev&lt;/code&gt;, &lt;code&gt;prev(n)&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;next(n)&lt;/td&gt;
&lt;td&gt;Next period with an offset of n intervals&lt;/td&gt;
&lt;td&gt;n &amp;gt; 0&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;next&lt;/code&gt;, &lt;code&gt;next(n)&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;this()&lt;/td&gt;
&lt;td&gt;Current period (n=0 by default)&lt;/td&gt;
&lt;td&gt;n = 0&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;this&lt;/code&gt;, &lt;code&gt;this(0)&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h4&gt;
  
  
  2. Interval
&lt;/h4&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Interval&lt;/th&gt;
&lt;th&gt;Description&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;day&lt;/td&gt;
&lt;td&gt;Day&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;week&lt;/td&gt;
&lt;td&gt;Week&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;month&lt;/td&gt;
&lt;td&gt;Month&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;quarter&lt;/td&gt;
&lt;td&gt;Quarter&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;semester&lt;/td&gt;
&lt;td&gt;Semester&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;year&lt;/td&gt;
&lt;td&gt;Year&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h4&gt;
  
  
  3. Method
&lt;/h4&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Method&lt;/th&gt;
&lt;th&gt;Description&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;first()&lt;/td&gt;
&lt;td&gt;First day of the interval&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;last()&lt;/td&gt;
&lt;td&gt;Last day of the interval&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;get()&lt;/td&gt;
&lt;td&gt;Get a specific date with arguments&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h3&gt;
  
  
  Tables of Possible Values
&lt;/h3&gt;

&lt;h4&gt;
  
  
  Origin
&lt;/h4&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Method&lt;/th&gt;
&lt;th&gt;Possible Values&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;prev(&amp;lt;increment&amp;gt;)&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;prev&lt;/code&gt;, &lt;code&gt;prev(0)&lt;/code&gt;, &lt;code&gt;prev(n)&lt;/code&gt; (n ≥ 0)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;next(&amp;lt;increment&amp;gt;)&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;next&lt;/code&gt;, &lt;code&gt;next(0)&lt;/code&gt;, &lt;code&gt;next(n)&lt;/code&gt; (n ≥ 0)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;this()&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;this&lt;/code&gt;, &lt;code&gt;this(0)&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h4&gt;
  
  
  Interval
&lt;/h4&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Interval&lt;/th&gt;
&lt;th&gt;Description&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;day&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Day&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;week&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Week&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;month&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Month&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;quarter&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Quarter&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;semester&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Semester&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;year&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Year&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h4&gt;
  
  
  Method
&lt;/h4&gt;

&lt;p&gt;Methods can be applied on the chosen interval (except for &lt;code&gt;day&lt;/code&gt;, for which the method has no effect).&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Method&lt;/th&gt;
&lt;th&gt;Description&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;first()&lt;/td&gt;
&lt;td&gt;First day of the interval&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;last()&lt;/td&gt;
&lt;td&gt;Last day of the interval&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;get()&lt;/td&gt;
&lt;td&gt;Get a specific date&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h4&gt;
  
  
  Arguments for the &lt;code&gt;get()&lt;/code&gt; Method
&lt;/h4&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Argument&lt;/th&gt;
&lt;th&gt;Concerned Interval&lt;/th&gt;
&lt;th&gt;Possible Values&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;day:&lt;/td&gt;
&lt;td&gt;month, quarter, semester, year&lt;/td&gt;
&lt;td&gt;Month: &lt;code&gt;day:1&lt;/code&gt; to &lt;code&gt;day:31&lt;/code&gt;&lt;br&gt;Year: &lt;code&gt;day:1&lt;/code&gt; to &lt;code&gt;day:365&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;week:&lt;/td&gt;
&lt;td&gt;month, quarter, semester, year&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;week:1&lt;/code&gt; to &lt;code&gt;week:52&lt;/code&gt; (or &lt;code&gt;week:53&lt;/code&gt;)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;:first&lt;/td&gt;
&lt;td&gt;month, quarter, semester, year&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;monday:first&lt;/code&gt; to &lt;code&gt;sunday:first&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;:last&lt;/td&gt;
&lt;td&gt;month, quarter, semester, year&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;monday:last&lt;/code&gt; to &lt;code&gt;sunday:last&lt;/code&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;:&lt;/td&gt;
&lt;td&gt;month, quarter, semester, year&lt;/td&gt;
&lt;td&gt;
&lt;code&gt;monday:1&lt;/code&gt; to &lt;code&gt;monday:5&lt;/code&gt; (month)&lt;br&gt;&lt;code&gt;monday:1&lt;/code&gt; to &lt;code&gt;monday:14&lt;/code&gt; (quarter)&lt;br&gt;&lt;code&gt;monday:1&lt;/code&gt; to &lt;code&gt;monday:26&lt;/code&gt; (semester)&lt;br&gt;&lt;code&gt;monday:1&lt;/code&gt; to &lt;code&gt;monday:52&lt;/code&gt; (or &lt;code&gt;monday:53&lt;/code&gt;) (year)&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h3&gt;
  
  
  Usage Examples
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;today&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;date.this.day
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Seven days from now&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;date.next(7).day
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;First day of the month 5 months before the current month:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;date.prev(5).month.first()
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Last day of the quarter 2 quarters after the current quarter:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;date.next(2).quarter.last()
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;34th week of the next year:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;date.next(1).year.get(week:34)
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;First Monday of the semester 3 semesters before the current semester:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;date.prev(3).semester.get(monday:first)
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Second Wednesday of the month 4 months after the current month:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;date.next(4).month.get(wednesday:2)
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;first day of current year:&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;date.this.year.first
&lt;/code&gt;&lt;/pre&gt;


&lt;p&gt;or&lt;br&gt;
&lt;/p&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;date.this.year.get(day:1)
&lt;/code&gt;&lt;/pre&gt;

&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>programming</category>
      <category>softwareengineering</category>
      <category>softwaredevelopment</category>
      <category>codequality</category>
    </item>
    <item>
      <title>Not my type: Types Vs. Usages</title>
      <dc:creator>Cédric Françoys</dc:creator>
      <pubDate>Sun, 22 Oct 2023 15:57:30 +0000</pubDate>
      <link>https://dev.to/cedricfrancoys/not-my-type-56fo</link>
      <guid>https://dev.to/cedricfrancoys/not-my-type-56fo</guid>
      <description>&lt;p&gt;&lt;strong&gt;An irreverent yet positively innovative approach regarding data typing&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;I love programming. I discovered the computers and wrote my first programs when I was a kid and I've never stopped since then.&lt;/p&gt;

&lt;p&gt;For some time now, I've been working on a &lt;a href="https://github.com/equalframework/equal" rel="noopener noreferrer"&gt;Web App framework&lt;/a&gt;, and this led me to think about a lot of things, amongst which data typing.&lt;/p&gt;

&lt;p&gt;It took me quite a long time to realize that the conventional approach of using variable types in most programming languages leads developers to create programs that require tremendous efforts to deal with validation, adaptation, storage and rendering of the manipulated values.&lt;/p&gt;

&lt;p&gt;The reason is that traditional data typing in programs is very permissive, tends to prioritizes technical needs over human reasoning, often lacks of context validation, and is rarely explicit in terms of human representation.&lt;/p&gt;

&lt;p&gt;This article presents a solution that aims to tackle these limitations by suggesting a more complete, flexible and unambiguous way to define and to handle data. &lt;/p&gt;

&lt;h2&gt;
  
  
  TL;DR
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;If, when declaring...&lt;/th&gt;
&lt;th&gt;You intend to deal with...&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;let country:string&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;"a two letters code of a country that complies with ISO3166"&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;float amount&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;"an amount of money with a precision of 4 decimal digits"&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;string email&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;"an email address that complies with IETF RFC 5322 &amp;amp; RFC 6854"&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;string password&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;"the blowfish encrypted version of a password complying with NIST recommendations"&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;Then you're using an ambiguous typing&lt;/strong&gt; and you probably have to manually deal with validations and conversions. &lt;/p&gt;

&lt;p&gt;This article presents the advantages of using an &lt;strong&gt;explicit typing&lt;/strong&gt;, and suggests that a simple syntax inspired by the &lt;a href="https://en.wikipedia.org/wiki/Media_type" rel="noopener noreferrer"&gt;Media Type&lt;/a&gt; notation could be used as a supplement or even as a replacement to traditional data types.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;type [ ["/" subtype[.variation][":" length]] ]["{" min, max "}"]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Example: "A money amount with up to 12 integer digits and 4 decimal digits" (FASAB/GAAP compliant) :&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;amount/money:12.4 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Did you say Variable ?
&lt;/h2&gt;

&lt;p&gt;As a developer, I deal with variables and types all the time. It is so common that it has become difficult to explain what exactly is a variable. &lt;/p&gt;

&lt;p&gt;Let's try anyway.&lt;/p&gt;

&lt;p&gt;All programming languages rely on data types in order to define how each piece of data has to be stored in memory, and to guarantee that operations performed on the data are consistent.&lt;/p&gt;

&lt;p&gt;Programs use names to identify the memory locations that are assigned for storing the data. These names are called "variables".&lt;/p&gt;

&lt;p&gt;In most cases, the value stored in a variable can change during the execution of the program (which is why it is called a "variable").&lt;/p&gt;

&lt;p&gt;A variable can be used in computations, assigned to other variables, or passed as argument to functions or methods.&lt;/p&gt;

&lt;p&gt;Most programming languages use types as classification of variables based on the kind of data they represent.&lt;/p&gt;

&lt;p&gt;The most common types, used in nearly all programming languages, are : bool(ean), int(eger), float(ing-point number), and string.&lt;/p&gt;

&lt;h2&gt;
  
  
  The whole picture
&lt;/h2&gt;

&lt;p&gt;Whatever the purpose of the processing, when a program handles variables there are 4 key considerations from the developer perspective:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Data Model&lt;/strong&gt; (Validation): Ensuring that the submitted value complies with the Model defintion and the application logic.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Data Storage&lt;/strong&gt; (Allocation): Determining the amount of memory required to store the variable (i.e. how many bytes).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Data Exchange&lt;/strong&gt; (Adaptation): Manipulating the data to convert it from one format to another (example: data exchange through API).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Data Representation&lt;/strong&gt; (Formatting): Specifying how the data should be displayed for human reading. (Sometimes there are some conventions for representing a data : a phone number, an email address, a monetary amount, a percentage value, ...  This aspect might also depend on the user's language &amp;amp; locale).&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;In most cases, programming languages deal with a single concept of "type" to manage all these considerations, which often turns out to be incomplete or even impossible. And some of (and sometimes all of) these tasks are left to the discretion of the developer on a case-by-case basis.&lt;/p&gt;

&lt;h3&gt;
  
  
  Data Model (validation)
&lt;/h3&gt;

&lt;p&gt;&lt;em&gt;Data modeling consists of telling the kind of data (human concept) that is stored into a variable (computer concept), and specifying if some constraints must be applied on a variable. The questions it addresses are "how to validate it" and "what operations can be performed on it".&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;In most situations, the type of a variable is used to control the operations that can be performed on it. It is also used to check that the variable that is passed as parameter to a function has the expected type, based on the function signature.&lt;/p&gt;

&lt;p&gt;This is because the intended use of a piece of data always has some implicit restrictions. As a consequence, some operators might be forbidden for variables of a certain type. For instance, the operator &lt;code&gt;/&lt;/code&gt; is valid for numbers (means "perform a division") but doesn't make sense for strings.&lt;/p&gt;

&lt;p&gt;Also, depending on the language, a same operator might have distinct meaning depending on the type of the operands. For instance, in JS or C++, using the operator &lt;code&gt;+&lt;/code&gt; on numbers means "&lt;em&gt;perform an arithmetic addition on these values&lt;/em&gt;" while using it on strings means "&lt;em&gt;concatenate these strings&lt;/em&gt;".&lt;/p&gt;

&lt;p&gt;Observations : &lt;/p&gt;

&lt;p&gt;Most languages allow developers to define variables amongst the following models : character, number, string, binary value and array.&lt;/p&gt;

&lt;p&gt;But these types can describe a lot of things: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;a string can be used for storing a name, a country, an address, ...&lt;/li&gt;
&lt;li&gt;a number can represent a quantity, an index, or even a date&lt;/li&gt;
&lt;li&gt;a binary value might be a document, an image, an archive, ...&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The Model should not only tell "What it is" but also "What it is intended for". Doing so makes it possible to bind some constraints to a variable. And the advantage of having constraints bound to data types is that, in case a submitted value does not comply with what is expected, it is easy to automatically provide the user with an accurate feedback about the reason why its submission was rejected.  &lt;/p&gt;

&lt;h3&gt;
  
  
  Data Storage (allocation)
&lt;/h3&gt;

&lt;p&gt;&lt;em&gt;Data storage relates to the amount of memory the computer must reserve in order to store the variable. The question it addresses is "what amount of memory must be allocated".&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Types are almost always used to tell the computer how much memory (what amount of bytes) should be allocated for storing the value of a variable.&lt;/p&gt;

&lt;p&gt;In the early days of computing, when every byte was valuable, resource allocation efficiency was a crucial consideration. And the rigor in the choice of the most appropriate type in terms of memory was decisive in order to take advantage of the least available bit. But it also resulted in not very intuitive and sometimes ambiguous notations. For instance, in C and C++, the &lt;code&gt;int&lt;/code&gt; type can be stored on 2 or 4 bytes depending on the environment.&lt;/p&gt;

&lt;p&gt;Here are the elementary computer memory units: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;bit&lt;/strong&gt;: 1 binary digit&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;byte&lt;/strong&gt;: a 8-bits (the smallest addressable unit of memory in most architectures)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;string&lt;/strong&gt;: a series of bytes of an arbitrary length&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;integer&lt;/strong&gt;: a block of bytes used to represent an integer value, which length depends on the computer architecture&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The way types are defined depends mostly on machine architecture (CPU registers capacity: 16 bits, 32 bits,  64 bits, ...) and on common values expected to be manipulated for different levels of precision (min, max) according to Byte multiples (int32, unsigned int, long long int, ...)&lt;/p&gt;

&lt;p&gt;Here are a few examples of variable declaration (as it can be found in common programming languages) that are ambiguous for humans in terms of memory allocation:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Declaration statement&lt;/th&gt;
&lt;th&gt;Comments&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;const N:u8&lt;/code&gt; (Rust)&lt;/td&gt;
&lt;td&gt;an unsigned integer stored on 8 bits (i.e. a natural number between 0 and 255)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;Dim n As Byte&lt;/code&gt; (VB)&lt;/td&gt;
&lt;td&gt;(idem)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;double n&lt;/code&gt; (C++)&lt;/td&gt;
&lt;td&gt;a real number with "double" precision (unclear about min and max values)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;let n:number&lt;/code&gt; (TS)&lt;/td&gt;
&lt;td&gt;any integer or floating point number (also unclear about min and max values)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;let n:i32&lt;/code&gt; (Rust)&lt;/td&gt;
&lt;td&gt;not easy for humans to tell the limits (something like "a range between -2 billons and +2 billions")&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;
&lt;code&gt;unsigned long long n&lt;/code&gt; (C++)&lt;/td&gt;
&lt;td&gt;(who the hell knows the result of 2^64-1 ?)&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Observations : &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Telling how a variable must be stored by using an integer number of bytes might have been necessary in the past, but it is not the case anymore: typing should not be confused with memory allocation.&lt;/li&gt;
&lt;li&gt;Any application uses a hardware-software stack which has implications in terms of limits (maximum number of digits, precision of the floating number). However, this stack is likely to evolve over time, and so are these limitations. Therefore, the logic of an application should be decoupled from the stack. That way, it would be easier for the developer to ensure that the storage/memory allocation remains consistent with the App logic.&lt;/li&gt;
&lt;li&gt;Typing should not only focus on how to store the data but also on how to translate human concepts to something that a computer can (easily) handle. If capability for humans to read the resulting source code is maintained, it greatly eases the work of the developers while adapting, maintaining or improving the code.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Data Exchange (adaptation)
&lt;/h3&gt;

&lt;p&gt;&lt;em&gt;Data Exchange relates to the transfer of data and variables from one environment to another. The question it addresses is "How to convert a piece of data received from the outside into a local variable and convert it back for sending a response".&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Each environment might store variables using its own types and representations.&lt;/p&gt;

&lt;p&gt;When the application receives data from the outside, nothing guarantees that it can be converted from the input format to a native format (programming language) in a consistent way, and without exceeding the capacity of the underlying layers (available/allocated memory).&lt;/p&gt;

&lt;p&gt;The same goes for sending data : we have no clue about how to format the data so that is it correctly interpreted, apart from the notation suggested by official norms like ISO. But again, nothing guarantees that the system we're communicating with follows these standards.&lt;/p&gt;

&lt;p&gt;Observations : &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A variable should be seamlessly convertible to another format according to the target specifics (ex. JS, PHP, SQL)&lt;/li&gt;
&lt;li&gt;A type should allow distinct programs or computers to handle the data in a consistent way.&lt;/li&gt;
&lt;li&gt;An application should communicate about the parameters it expects along with the inherent limitations (expected format, maximum size, etc.)&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Data Representation (formatting)
&lt;/h3&gt;

&lt;p&gt;&lt;em&gt;Data representation relates to the encoding of a value in a way that makes it understandable by humans and valid within a given context.  The question it addresses it "How to display it within a given context?".&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;For some types of variables, outputting data is not trivial and can involve a lot a possible variations (for instance when preferences or user settings are involved). In such case, it is necessary to be explicit about how the data must be displayed.&lt;/p&gt;

&lt;p&gt;An additional difficulty is that some representations might vary depending on the "locale" settings (e.g. character for decimal separator) or international variations of notations (e.g. amount of digits of a phone number or digits grouping convention).&lt;/p&gt;

&lt;p&gt;Dates are a good example: various strategies can be found depending on the tools and environments (timestamps, formatted strings, ISO notation). And this matter is still subject to many issues is modern softwares.&lt;/p&gt;

&lt;p&gt;Observations : &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Typing should allow both computers and humans to know how to present the value of that variable.&lt;/li&gt;
&lt;li&gt;For types that may be represented in many different ways (ex. dates / datetimes), an additional piece of information is necessary for disambiguation.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Explicit typing
&lt;/h2&gt;

&lt;p&gt;Unlike computers, humans know that a real is a number and that a string is a piece of text. On the other hand, unlike humans, computers need to know beforehand how much memory must be allocated in order to store a real number or a string.&lt;/p&gt;

&lt;p&gt;The problem is that the human definitions of "text" and "number" are quite vague. Respectively: "&lt;em&gt;a coherent set of signs that transmits some kind of informative message&lt;/em&gt;"; and "&lt;em&gt;symbols that represents an amount&lt;/em&gt;" and give no clue about storage or rendering.&lt;/p&gt;

&lt;p&gt;To enable a computer to handle a value accurately, without requiring the developer to program in every detail how to store and manipulate it based on its intended use, the associated variable should have an &lt;strong&gt;explicit type&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;In other words, explicit typing describes a variable in a way that covers the 4 aspects presented above : modeling, allocation, adaptation and formatting.&lt;/p&gt;

&lt;h2&gt;
  
  
  Proposition
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;The suggestion made in this article is that explicit typing can be achieved by using a single descriptor.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Here below, is a proposal in the form of a proof of concept, that uses a notation logic close to the the Media Type syntax (&lt;a href="https://en.wikipedia.org/wiki/Media_type" rel="noopener noreferrer"&gt;MIME&lt;/a&gt;) for building such descriptors.&lt;/p&gt;

&lt;p&gt;Using the MIME notation, in conjunction with concepts for which an unambiguous definition or an international standard exists, provides an explicit typing. For instance, we can assume that a "language" is a value that holds 2 or 3 lowercase letters and whose possible values are provided by the ISO standards ISO-639-1 and ISO-639-2.&lt;/p&gt;

&lt;p&gt;The term "&lt;strong&gt;usage&lt;/strong&gt;" is used to distinguish explicit types from primitive types.&lt;/p&gt;

&lt;p&gt;Here is the full syntax of a "usage" descriptor:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;type [ ["/" subtype[.variation][":" length]] ]["{" min, max "}"]&lt;/code&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;type&lt;/code&gt; is the name of the non-primitive type;&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;subtype&lt;/code&gt; is the mandatory categorization of the non-primitive type (example: number/integer). It always has a default value so it can be omitted (ex. text defaults to text/plain); &lt;/li&gt;
&lt;li&gt;
&lt;code&gt;variation&lt;/code&gt; (optional) additional meta information to identify a specific standard or norm (example: hash/md.4);&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;length&lt;/code&gt; is either an amount of digits (or glyphs), or a length under the form  &lt;code&gt;precision.scale&lt;/code&gt;; 

&lt;ul&gt;
&lt;li&gt;for numeric values, the length tells the amount of digits (required bytes can be found with &lt;code&gt;ceil(log2(x) / 8&lt;/code&gt;);&lt;/li&gt;
&lt;li&gt;for strings, the length indicates the amount of glyphs (which might differ from the number of bytes);&lt;/li&gt;
&lt;li&gt;for usages that imply a floating point numbers, the length can be composed of several parts separated with dots (e.g. &lt;code&gt;precision[.scale]&lt;/code&gt;).&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;
&lt;code&gt;min&lt;/code&gt; and &lt;code&gt;max&lt;/code&gt; are optional parameters intended for numbers and can be used for defining custom limits. By default, there are always limits, set based on the min and max implied by the usage. If set, these values must be consistent with the length (for instance number/natural:2 cannot have a min lower than 0 nor a max higher than 99).&lt;/li&gt;

&lt;/ul&gt;

&lt;p&gt;The primitive types can coexist, but become special cases of the "usage".&lt;/p&gt;

&lt;p&gt;The proposition being that:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A usage always relates to a generic type (by example, all variations of "number/real" relate to the type "float");&lt;/li&gt;
&lt;li&gt;All generic types are associated with one default usage;&lt;/li&gt;
&lt;li&gt;The default boundaries depend on the local environment and off-limit values should be rejected by it.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Examples
&lt;/h3&gt;

&lt;p&gt;Below is presented a non-exhaustive list of descriptors using such notation.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Usage&lt;/th&gt;
&lt;th&gt;Primitive Type&lt;/th&gt;
&lt;th&gt;Description&lt;/th&gt;
&lt;th&gt;Examples&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;TEXTS&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;text/plain&lt;/td&gt;
&lt;td&gt;string&lt;/td&gt;
&lt;td&gt;A regular string composed of unicode chars (UTF-8 4-byte) &lt;br&gt;&lt;strong&gt;Alias&lt;/strong&gt;: text, text/plain.short, text/plain:255&lt;br&gt;&lt;strong&gt;Variations&lt;/strong&gt;: text/plain.small (65KB) text/plain.medium (16MB), text/plain.long (4GB)&lt;/td&gt;
&lt;td&gt;Hello world.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;text/xml&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;An XML formatted string (equivalent to MIME "application/xml")&lt;/td&gt;
&lt;td&gt;&amp;lt;Person&amp;gt;&lt;br&gt;&amp;lt;Name&amp;gt;Joe&amp;lt;/Name&amp;gt;&lt;br&gt;&amp;lt;/Person&amp;gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;text/html&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;An HTML formatted string.&lt;/td&gt;
&lt;td&gt;&amp;lt;p&amp;gt;HTML rocks!&amp;lt;/p&amp;gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;text/markdown&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;A piece of text using MarkDown notation.&lt;/td&gt;
&lt;td&gt;## Title&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;text/wiki (markup/wikitext)&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;A piece of text using Wiki markup.&lt;/td&gt;
&lt;td&gt;''italic''&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;NUMBERS&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;amount/money&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;A financial amount&lt;br&gt;&lt;strong&gt;Alias&lt;/strong&gt;: amount/money:9.2, amount/money:2&lt;br&gt;&lt;strong&gt;Variations&lt;/strong&gt;: amount/money:9.4 (FASAB/GAAP)&lt;/td&gt;
&lt;td&gt;886.90 EUR&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;amount/percent&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;A percentage &lt;br&gt;&lt;strong&gt;Alias&lt;/strong&gt;: amount/percent:2&lt;br&gt;
&lt;/td&gt;
&lt;td&gt;85.13%&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;amount/rate&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;A rate amount (with no units).&lt;br&gt;&lt;strong&gt;Alias&lt;/strong&gt;: amount/rate:4&lt;br&gt;&lt;strong&gt;Variations&lt;/strong&gt;: amount/rate:6&lt;br&gt;
&lt;/td&gt;
&lt;td&gt;1.0789&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;number/boolean&lt;/td&gt;
&lt;td&gt;bool&lt;/td&gt;
&lt;td&gt;
&lt;strong&gt;Alias&lt;/strong&gt;: number/boolean:1&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;number/natural&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;A positive integer (ISO 80000-2: [0;99])&lt;br&gt;&lt;strong&gt;Alias&lt;/strong&gt;: number/natural:9 (32bit) or number/natural:19 (64 bits)&lt;br&gt;&lt;strong&gt;Example&lt;/strong&gt; : number/natural:2 (2 digits positive integer)&lt;/td&gt;
&lt;td&gt;0, 25, 999&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;number/integer&lt;/td&gt;
&lt;td&gt;int&lt;/td&gt;
&lt;td&gt;
&lt;strong&gt;Alias&lt;/strong&gt;: number, number/integer.decimal&lt;br&gt;&lt;strong&gt;Variations&lt;/strong&gt;: number/integer.hexadecimal, number/integer.octal&lt;br&gt;&lt;strong&gt;Examples&lt;/strong&gt;: number/integer:1 (a single digit integer: [-9;+9])&lt;/td&gt;
&lt;td&gt;-32767, 1, 65535&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;number/real&lt;/td&gt;
&lt;td&gt;float&lt;/td&gt;
&lt;td&gt;
&lt;strong&gt;Alias&lt;/strong&gt;: number/real:10.2&lt;br&gt;&lt;strong&gt;Example&lt;/strong&gt;: number/real:5.2 (a float number with 2 decimal digits and max 3 digits for the integer part)&lt;/td&gt;
&lt;td&gt;123.45&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;URI&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;uri/url.http&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;A URL using HTTP or HTTPS scheme.&lt;/td&gt;
&lt;td&gt;&lt;a href="https://equal.run" rel="noopener noreferrer"&gt;https://equal.run&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;uri/url.ftp&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;A URL using FTP and FTPS scheme.&lt;/td&gt;
&lt;td&gt;&lt;a href="ftp://ftp.example.com"&gt;ftp://ftp.example.com&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;uri/urn.isbn&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;An International Standard Book Number for identifying a book&lt;br&gt;&lt;strong&gt;Alias&lt;/strong&gt;: urn/isbn:13 or urn/isbn.13&lt;br&gt;&lt;strong&gt;Variations&lt;/strong&gt;: uri/urn.isbn:10 (ISO 2108)&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;uri/urn.isan&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;International Standard Audiovisuel Number for identifying and audiovisual&lt;/td&gt;
&lt;td&gt;ISAN 0000-0000-3A8D-0000-Z-0000-0000-6&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;uri/urn.iban&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;International bank account number (ISO-13616)&lt;br&gt;&lt;strong&gt;Variations&lt;/strong&gt;: urn/iban.BE (or urn/iban.16 or urn/iban:16)&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;uri/urn.ean&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;International article numerotation EAN number (ISO-15420)&lt;br&gt;&lt;strong&gt;Alias&lt;/strong&gt;: urn/ean.13 or urn/ean:13&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;DATES&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;date/plain&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;An ISO 8601 date with date part only [&lt;a class="mentioned-user" href="https://dev.to/00"&gt;@00&lt;/a&gt;:00:00UTC])&lt;br&gt;&lt;strong&gt;Alias&lt;/strong&gt;: date&lt;/td&gt;
&lt;td&gt;1955-11-05&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;date/time&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;A full ISO 8601 date holding an UTC time.&lt;br&gt;&lt;strong&gt;Alias&lt;/strong&gt;: datetime&lt;/td&gt;
&lt;td&gt;1955-11-13T05:04:00Z&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;date/year&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;Alias: date/year:4 (integer 0-9999)&lt;br&gt;&lt;strong&gt;Variations&lt;/strong&gt;: date/year:2&lt;/td&gt;
&lt;td&gt;1999&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;date/month&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;An integer representing a month within the year (ISO-8601 : 1 to 12, 1 being January)&lt;/td&gt;
&lt;td&gt;11&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;date/weekday&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;An integer representing a day within the week (ISO-8601: 1 to 7, 1 being Monday)&lt;br&gt;&lt;strong&gt;Alias&lt;/strong&gt;: date/weekday.mon &lt;br&gt;&lt;strong&gt;Variations&lt;/strong&gt;: date/weekday.sun (0 to 6, 0 is Sunday)&lt;/td&gt;
&lt;td&gt;3&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;MISC&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;email&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;A string describing an email address as defined by IETF RFC 5322 &amp;amp; RFC 6854&lt;/td&gt;
&lt;td&gt;&lt;a href="mailto:cedric@equal.run"&gt;cedric@equal.run&lt;/a&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;language&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;A language represented with 2 lower case letters (&lt;a href="https://en.wikipedia.org/wiki/List_of_ISO_639-1_codes" rel="noopener noreferrer"&gt;ISO 639-1&lt;/a&gt;)&lt;br&gt;&lt;strong&gt;Alias&lt;/strong&gt;: language/iso-639:2&lt;br&gt;&lt;strong&gt;Variations&lt;/strong&gt; : language/iso-639:3 (&lt;a href="https://en.wikipedia.org/wiki/List_of_ISO_639-2_codes" rel="noopener noreferrer"&gt;ISO 639-2&lt;/a&gt;)&lt;/td&gt;
&lt;td&gt;en, de, zh&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;country&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;A country represented with 2 upper case letters (&lt;a href="https://en.wikipedia.org/wiki/ISO_3166-1_alpha-2" rel="noopener noreferrer"&gt;ISO 3166-1 alpha-2&lt;/a&gt;)&lt;br&gt;&lt;strong&gt;Alias&lt;/strong&gt;: country/iso-3166:2&lt;br&gt;&lt;strong&gt;Variations&lt;/strong&gt;: country/iso-3166:3 (&lt;a href="https://en.wikipedia.org/wiki/ISO_3166-1_alpha-3" rel="noopener noreferrer"&gt;ISO 3166-1 alpha-3&lt;/a&gt;)&lt;/td&gt;
&lt;td&gt;FR, GB&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;image&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;A binary value representing an image. &lt;br&gt;&lt;strong&gt;Variations&lt;/strong&gt;: image/jpeg, image/gif, image/png, image/tiff, image/webp&lt;/td&gt;
&lt;td&gt;.PNG........IHDR..............wS.....IDAT..c.................IEND.B.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;password&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;A password complying to NIST 800-63 (minimum length of 8 chars, unicode chars)&lt;br&gt;&lt;strong&gt;Alias&lt;/strong&gt;: password/nist, password/enisa&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Note: if you're interested in more examples or have any suggestions, feel free to explore the complete list of Usages on this &lt;a href="https://gist.github.com/cedricfrancoys/48014bd2a1f07905abcef00cbe90cb38" rel="noopener noreferrer"&gt;Gist&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Numbers boundaries
&lt;/h3&gt;

&lt;p&gt;When it comes to numbers, it is common for a variable not to relate to any standard or external convention, but instead to have boundaries (i.e. minimum and maximum possible values).&lt;/p&gt;

&lt;p&gt;For that, we can use a notation similar to the one used in regular expressions for {n,m} quantifiers (&lt;a href="https://docs.oracle.com/javase/tutorial/essential/regex/quant.html" rel="noopener noreferrer"&gt;https://docs.oracle.com/javase/tutorial/essential/regex/quant.html&lt;/a&gt;)&lt;/p&gt;

&lt;p&gt;Here are a few examples: &lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;general&lt;/th&gt;
&lt;th&gt;with boundaries&lt;/th&gt;
&lt;th&gt;description&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;number/integer&lt;/td&gt;
&lt;td&gt;number/integer{-10,10}&lt;/td&gt;
&lt;td&gt;an integer within the range [-10;10]&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;amount/money:6.4&lt;/td&gt;
&lt;td&gt;amount/money:6.4{0,300000}&lt;/td&gt;
&lt;td&gt;a money amount between $0.0 and $300,000&lt;br&gt;examples: 299999.9999&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;This technique can be advantageously extended to strings to define specific lengths:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;general&lt;/th&gt;
&lt;th&gt;with boundaries&lt;/th&gt;
&lt;th&gt;description&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;text/plain&lt;/td&gt;
&lt;td&gt;text/plain{2,30}&lt;/td&gt;
&lt;td&gt;a string having minimum 2 glyphs and maximum 30 glyphs&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h3&gt;
  
  
  Handling Arrays
&lt;/h3&gt;

&lt;p&gt;Array is a kind of super type. It has a  length (that can be dynamic), and holds elements of a specific type.&lt;/p&gt;

&lt;p&gt;Various notations for arrays can be found among popular programming languages. The most usual notations are :&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;Array&amp;lt;Type&amp;gt;&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;Type[]&lt;/code&gt; or &lt;code&gt;Type()&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;[Type; size]&lt;/code&gt;or  &lt;code&gt;Type[size]&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In order to respect the assumptions made earlier, and make it easily usable in controllers (validation only), we should be able to determine the maximum length of the array, along with the kind of elements it holds.&lt;/p&gt;

&lt;p&gt;For arrays as well, &lt;strong&gt;Usage&lt;/strong&gt; can helpfully complete the information about the handled data:&lt;/p&gt;

&lt;p&gt;we know the variable holds a series of items and we know how to store, validate, display and convert those items.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Array holding 3 integers having max 2 digits &lt;/span&gt;
&lt;span class="c1"&gt;// (#memo - type is a special case of a broader usage)&lt;/span&gt;
&lt;span class="p"&gt;[&lt;/span&gt;
  &lt;span class="s1"&gt;'type'&lt;/span&gt;   &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s1"&gt;'array'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="s1"&gt;'usage'&lt;/span&gt;  &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s1"&gt;'number[3]/integer:2'&lt;/span&gt;
&lt;span class="p"&gt;];&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="c1"&gt;// Array&lt;/span&gt;
&lt;span class="p"&gt;[&lt;/span&gt;
  &lt;span class="s1"&gt;'type'&lt;/span&gt;  &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s1"&gt;'array'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="s1"&gt;'usage'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s1"&gt;'email[10]'&lt;/span&gt;
&lt;span class="p"&gt;];&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;There is a special case of non-typed arrays that may be used in order to accept arbitrary values or maps.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;&lt;span class="c1"&gt;// special case non-typed array &lt;/span&gt;
&lt;span class="c1"&gt;// (#memo - applies only to input params not meant to be stored)&lt;/span&gt;
&lt;span class="p"&gt;[&lt;/span&gt;
  &lt;span class="s1"&gt;'type'&lt;/span&gt;  &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s1"&gt;'array'&lt;/span&gt;
  &lt;span class="s1"&gt;'usage'&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="s1"&gt;'array'&lt;/span&gt;
&lt;span class="p"&gt;];&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Additional benefits
&lt;/h3&gt;

&lt;p&gt;This approach can be used for identifying (or guessing) the kind of data that a field stores, which can be useful in various situations :&lt;/p&gt;

&lt;h4&gt;
  
  
  Sensitive data
&lt;/h4&gt;

&lt;p&gt;When using production data within a DEV or Staging environment, this approach allows to identity sensitive or privacy-related data.&lt;/p&gt;

&lt;p&gt;Having a Usage telling the kind of value we're dealing with (ex. name, birthdate, gender, address, email, iban, password) allows developer to identify which values must be obfuscated (withdrawn or randomized) before importing data to the test environment, and/or with what sample data they can be replaced.&lt;/p&gt;

&lt;p&gt;Also, for record-based backups, it can be used to tell which columns must by encrypted.&lt;/p&gt;

&lt;h4&gt;
  
  
  Sample data (DB seeding)
&lt;/h4&gt;

&lt;p&gt;In the same way, coupling properties with Usages makes it easy to generate sample sets for seeding a database with dummy data in a consistent way.&lt;/p&gt;

&lt;h2&gt;
  
  
  Next
&lt;/h2&gt;

&lt;p&gt;If your curious about this or would like to see an example of implementation, you can have a look at the eQual framework.&lt;/p&gt;

&lt;p&gt;Here are the direct links to the involved files in  the repository :&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://github.com/equalframework/equal/blob/master/lib/equal/data/adapt/DataAdapterInterface.class.php" rel="noopener noreferrer"&gt;https://github.com/equalframework/equal/blob/master/lib/equal/data/adapt/DataAdapterInterface.class.php&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/equalframework/equal/blob/master/lib/equal/orm/usages/Usage.class.php" rel="noopener noreferrer"&gt;https://github.com/equalframework/equal/blob/master/lib/equal/orm/usages/Usage.class.php&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/equalframework/equal/tree/master/lib/equal/orm/usages" rel="noopener noreferrer"&gt;https://github.com/equalframework/equal/tree/master/lib/equal/orm/usages&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Valuable sources consulted over time
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://en.wikipedia.org/wiki/Data_type" rel="noopener noreferrer"&gt;https://en.wikipedia.org/wiki/Data_type&lt;/a&gt;&lt;br&gt;
&lt;a href="https://en.wikipedia.org/wiki/Media_type" rel="noopener noreferrer"&gt;https://en.wikipedia.org/wiki/Media_type&lt;/a&gt;&lt;br&gt;
&lt;a href="https://www3.ntu.edu.sg/home/ehchua/programming/java/datarepresentation.html" rel="noopener noreferrer"&gt;https://www3.ntu.edu.sg/home/ehchua/programming/java/datarepresentation.html&lt;/a&gt;&lt;br&gt;
&lt;a href="https://www1.icsi.berkeley.edu/%7Esather/Documentation/EclecticTutorial/node5.html" rel="noopener noreferrer"&gt;https://www1.icsi.berkeley.edu/~sather/Documentation/EclecticTutorial/node5.html&lt;/a&gt;&lt;br&gt;
&lt;a href="https://www.lehigh.edu/%7Eineng2/notes/datatypes" rel="noopener noreferrer"&gt;https://www.lehigh.edu/~ineng2/notes/datatypes&lt;/a&gt;&lt;br&gt;
&lt;a href="https://doc.rust-lang.org/nomicon/repr-rust.html" rel="noopener noreferrer"&gt;https://doc.rust-lang.org/nomicon/repr-rust.html&lt;/a&gt;&lt;br&gt;
&lt;a href="https://docs.oracle.com/javase/tutorial/essential/regex/" rel="noopener noreferrer"&gt;https://docs.oracle.com/javase/tutorial/essential/regex/&lt;/a&gt;&lt;/p&gt;

</description>
      <category>programming</category>
      <category>computerscience</category>
      <category>development</category>
      <category>softwareengineering</category>
    </item>
  </channel>
</rss>
