|
|
@ -1499,16 +1499,14 @@ about a programming language.</p>
|
|
|
|
<p>Rust has many unique features. These features give us great benefit by removing
|
|
|
|
<p>Rust has many unique features. These features give us great benefit by removing
|
|
|
|
whole classes of problems. Some of them are also patterns that are <em>unique</em> to Rust.</p>
|
|
|
|
whole classes of problems. Some of them are also patterns that are <em>unique</em> to Rust.</p>
|
|
|
|
<h2 id="yagni"><a class="header" href="#yagni">YAGNI</a></h2>
|
|
|
|
<h2 id="yagni"><a class="header" href="#yagni">YAGNI</a></h2>
|
|
|
|
<p>If you're not familiar with it, YAGNI is an acronym that stands for
|
|
|
|
<p>YAGNI is an acronym that stands for <code>You Aren't Going to Need It</code>.
|
|
|
|
<code>You Aren't Going to Need It</code>. It's an important software design principle to apply
|
|
|
|
It's a vital software design principle to apply as you write code.</p>
|
|
|
|
as you write code.</p>
|
|
|
|
|
|
|
|
<blockquote>
|
|
|
|
<blockquote>
|
|
|
|
<p>The best code I ever wrote was code I never wrote.</p>
|
|
|
|
<p>The best code I ever wrote was code I never wrote.</p>
|
|
|
|
</blockquote>
|
|
|
|
</blockquote>
|
|
|
|
<p>If we apply YAGNI to design patterns, we see that the features of Rust allow us to
|
|
|
|
<p>If we apply YAGNI to design patterns, we see that the features of Rust allow us to
|
|
|
|
throw out many patterns. For instance, there is no need for the <a href="https://en.wikipedia.org/wiki/Strategy_pattern">strategy pattern</a>
|
|
|
|
throw out many patterns. For instance, there is no need for the <a href="https://en.wikipedia.org/wiki/Strategy_pattern">strategy pattern</a>
|
|
|
|
in Rust because we can just use <a href="https://doc.rust-lang.org/book/traits.html">traits</a>.</p>
|
|
|
|
in Rust because we can just use <a href="https://doc.rust-lang.org/book/traits.html">traits</a>.</p>
|
|
|
|
<p>TODO: Maybe include some code to illustrate the traits.</p>
|
|
|
|
|
|
|
|
<div style="break-before: page; page-break-before: always;"></div><h1 id="behavioural-patterns"><a class="header" href="#behavioural-patterns">Behavioural Patterns</a></h1>
|
|
|
|
<div style="break-before: page; page-break-before: always;"></div><h1 id="behavioural-patterns"><a class="header" href="#behavioural-patterns">Behavioural Patterns</a></h1>
|
|
|
|
<p>From <a href="https://en.wikipedia.org/wiki/Behavioral_pattern">Wikipedia</a>:</p>
|
|
|
|
<p>From <a href="https://en.wikipedia.org/wiki/Behavioral_pattern">Wikipedia</a>:</p>
|
|
|
|
<blockquote>
|
|
|
|
<blockquote>
|
|
|
|