<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Fraol Lemecha on Medium]]></title>
        <description><![CDATA[Stories by Fraol Lemecha on Medium]]></description>
        <link>https://medium.com/@frectonz?source=rss-df16c42a56ad------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*1ZYJvv-TL7CZ-8YxJlLL5A.jpeg</url>
            <title>Stories by Fraol Lemecha on Medium</title>
            <link>https://medium.com/@frectonz?source=rss-df16c42a56ad------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 13:36:25 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@frectonz/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[D3 is just BDUF with a new name]]></title>
            <link>https://medium.com/@frectonz/d3-is-just-bduf-with-a-new-name-de8e85e374a4?source=rss-df16c42a56ad------2</link>
            <guid isPermaLink="false">https://medium.com/p/de8e85e374a4</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[technology]]></category>
            <category><![CDATA[software-engineering]]></category>
            <dc:creator><![CDATA[Fraol Lemecha]]></dc:creator>
            <pubDate>Wed, 02 Nov 2022 14:09:24 GMT</pubDate>
            <atom:updated>2022-11-02T14:14:33.936Z</atom:updated>
            <content:encoded><![CDATA[<p>In an article called <a href="https://baydis.medium.com/documentation-driven-development-the-only-way-to-code-e1633830cac8">Documentation Driven Development</a> <a href="https://baydis.t.me/">Theo</a> tries to convince us that D3 is the only way to code. In the article, he challenges us to change his mind. I will try to do just that in this article.</p><p>Most, even basic software systems are too complex to be understood perfectly from the beginning. Because, as you begin working on the project, you encounter many issues you wouldn’t have thought of at the beginning. I believe the only kind of documentation that should be created before starting a project is a simple list of features and expectations. And any other decisions should be left to the developers. But if you are talking about documentation down to describing a function call, then that would be awful for everybody involved in the project. At that point, the so-called documentation would just serve to limit the developer’s creativity.</p><p>Even if you create the documentation and then you start writing the code, the documentation will eventually be wrong unless you continue updating the documentation in parallel with the code. This is just redundent and wasteful because you would be maintaining two sources of truth for the system. Afterall the only way to know what a function does is to read the function not to read its comment. As a result, if the problem with code is that it is difficult to read, why not write clean code and make it easier to understand? This would make the whole process much less wasteful because you won’t be making the people you hired to write code write prose. At the end of the day, the actual product is the code or the system that the code enables, not the documentation. Consequently, I think you should pay as little attention to the documentation as possible and dedicate all your time and energy to the code and the actual product.</p><p>Although I am not familiar with D3, it seems awfully close to the <a href="https://en.wikipedia.org/wiki/Big_Design_Up_Front">Big Design Up Front</a> (BDUF) days of programming. And BDUF is arguably the most hated idea in programming history. History has shown that many BDUF projects have failed, and most of them are never even implemented, as nobody could match the specifications (documentation). At the beginning of the computing world BDUF made sense because at that time code and computers were expensive. People had to be interpreters running their code on pen and paper to confirm its correctness before sending it off to be turned in to punch cards. At that time code was considered permanent. You would invest a lot of time and effort making sure it is correct. Because punch cards are very hard to change. Today code is cheap to write and malleable. You can even start implementing something using a no-code tool and then write the code for it when the time arises.</p><p>If you are looking to make your whole development process faster and more reliable I suggest you explore <a href="https://youtu.be/Jv2uxzhPFl4">TDD</a>. And if you are interested in how to write clean code, check out <a href="https://en.wikipedia.org/wiki/Robert_C._Martin">Robert C. Martin’s</a> wonderful books.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=de8e85e374a4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Eliminating Null]]></title>
            <link>https://medium.com/@frectonz/eliminating-null-78ffe31a9b66?source=rss-df16c42a56ad------2</link>
            <guid isPermaLink="false">https://medium.com/p/78ffe31a9b66</guid>
            <category><![CDATA[rust]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[typescript]]></category>
            <dc:creator><![CDATA[Fraol Lemecha]]></dc:creator>
            <pubDate>Tue, 09 Nov 2021 10:14:00 GMT</pubDate>
            <atom:updated>2022-05-29T19:35:31.441Z</atom:updated>
            <content:encoded><![CDATA[<h4>Using options to eliminate null checks from your code base.</h4><p>The existence of null has been the oldest and the most notorious source of runtime errors. Null has plagued our code with a never ending chain of null checks. It is time we eliminate null by using techniques that have been shown in languages like <strong>Rust</strong> and <strong>Haskell</strong>.</p><p>Here are some programming languages that don’t have null.</p><ul><li>Rust</li><li>Haskell</li><li>OCaml</li><li>Standard ML</li><li>Swift</li></ul><p>In the <strong>JavaScript/TypeScript</strong> world things are particularly worse because we have two separate types of null, <strong>null</strong> and <strong>undefined</strong></p><pre>null == undefined; <em>// true<br></em>null === undefined; <em>// false</em></pre><pre>typeof null; <em>// =&gt; &quot;object&quot;<br></em>typeof undefined; <em>// =&gt; &quot;undefined&quot;</em></pre><p>This article goes deep into this topic. <a href="https://www.lucidchart.com/techblog/2015/08/31/the-worst-mistake-of-computer-science/">Click Here</a></p><p>In this article I will show you how to eliminate null from your code by using a simple implementation of the <strong>option type</strong> from rust in typescript.</p><p>I have been learning rust for a couple of months now and I wanted to introduce one of the great features of rust to TypeScript and JavaScript. So I created the <strong>optionem</strong> library.</p><h3>A simple introduction to Option</h3><p>The option type is used in places were some operation will return either a value or no value. Null is often used to represent the no value case independent of the type of the value to be returned. We have seen that this leads to unexpected problems if the programmer calling that operation forgets to handle the no value case.</p><p>For example let’s look at a Map.</p><pre>interface Map&lt;K, V&gt; {<br>    <em>// .</em>.<br>    <strong>get</strong>(key: K): <strong>V | undefined</strong>;<br>    <em>// ..<br></em>}</pre><p>The Map interface has a method called get. The functionality of get is returning a <strong>value</strong> stored inside the map using the key associated with the value otherwise if there is no value stored in the map with the given key it returns <strong>undefined</strong>.</p><p>Now lets see what happens when we call get in our code.</p><pre>const map = new Map(); // Empty map<br>const value = map.get(&quot;key&quot;); // no value with key &quot;key&quot;<br>console.log(<strong>value.length</strong>); <strong><em>// ERROR</em></strong></pre><p>This returns an error because we forgot to check for undefined. This is a dumb example because if you use typescript you wouldn’t make this error. But it shows how forgetting null checks causes runtime errors.</p><pre>const map = new Map();</pre><pre>map.set(&quot;key1&quot;, &quot;&quot;);<br>map.set(&quot;key2&quot;, &quot;value&quot;);</pre><pre>if (map.get(&quot;key1&quot;)) {<br>    <em>// </em><strong><em>doesn&#39;t execute</em></strong><em><br>    </em>console.log(&quot;value exists at key1&quot;);<br>}</pre><pre>if (map.get(&quot;key2&quot;)) {<br>    <em>// </em><strong><em>executes</em></strong><em><br>    </em>console.log(&quot;value exists at key2&quot;);<br>}</pre><pre>if (map.get(&quot;key3&quot;)) {<br>   <em>// </em><strong><em>doesn&#39;t execute</em></strong><em><br>   </em>console.log(&quot;SHOULD NOT RUN: no value at key3&quot;);<br>}</pre><p>This code produces the following output</p><pre>value exists at key2</pre><p>If we look at the third if-condition we can see that we didn’t have a value with the key key3 so the get method returned an undefined and due to undefined being a falsey value in javascript the if-condition didn’t get executed.</p><p>Now lets look at the first if-condition. the value at the key key1 is an empty string and empty string is a falsey value, so even though the get method returned a value the value returned was also falsey thus the if condition didn’t get executed.</p><pre>if (<strong>&quot;&quot;</strong>) {<br>    console.log(&quot;<strong>WILL NOT RUN</strong>&quot;);<br>} else {<br>    console.log(&quot;<strong>empty string is falsey</strong>&quot;);<br>}</pre><p>To fix the bug in the first if-condition we need to explicitly check for an undefined.</p><pre>const <strong>map</strong> = new Map();</pre><pre>map.set(&quot;<strong>key1</strong>&quot;, &quot;&quot;);<br>map.set(&quot;<strong>key2</strong>&quot;, &quot;value&quot;);</pre><pre>if (map.<strong>get(&quot;key1&quot;)</strong> !== <strong>undefined</strong>) {<br>    console.log(&quot;value exists at key1&quot;);<br>}</pre><pre><em>// ...</em></pre><p>As we can see in the above example we had to jump through a lot of hoops to get the functionality we wanted. Now let see how much the Option type would be useful in our example. We will use the option type from the optionem library.</p><p><a href="https://github.com/frectonz/optionem">Optionem GitHub Repo</a></p><p>An implementation of Map that returns an option.</p><pre>import { <strong>Option</strong> } from &quot;<strong>optionem</strong>&quot;;</pre><pre>interface <strong>IOptionMap</strong>&lt;<strong>K</strong>, <strong>V</strong>&gt; {<br>    <em>// ...<br>    </em><strong>get</strong>(key: K): <strong>Option&lt;V&gt;</strong>;<br>    <em>// ...<br></em>}</pre><p>First Let’s see what option is.</p><h4>What is the Option type?</h4><p>The option type represents an optional value. An option is either a Some that contains a value or a None that does not. The option type is used in places where in normal circumstances you get returned a <em>nul</em>l or <em>undefined</em> if the operation failed.</p><figure><img alt="A diagram that shows option and result types" src="https://cdn-images-1.medium.com/max/1024/1*NGlDv0DDlnEAdxMcZVKSEA.png" /></figure><p>Think of them this way. The option type has two variants the <strong>none</strong> and <strong>some</strong> variants.</p><pre>interface <strong>Option</strong>&lt;T&gt; {<br>   <em>// ...<br></em>}</pre><pre>class <strong>Some</strong>&lt;T&gt; implements <strong>Option&lt;T&gt;</strong> {<br>    <em>// ...<br></em>}</pre><pre>class <strong>None</strong>&lt;T&gt; implements <strong>Option&lt;T&gt;</strong> {<br>    <em>// ...<br></em>}</pre><p>An example of using the option type.</p><pre>import { Option } from &quot;optionem&quot;;</pre><pre>const some: <strong>Option&lt;number&gt;</strong> = <strong>new Some(10)</strong>;</pre><pre>const none: <strong>Option&lt;number&gt;</strong> = <strong>new None()</strong>;</pre><p>Now let’s return to our map example.</p><pre>class <strong>OptionMap</strong>&lt;K, V&gt; implements <strong>IOptionMap</strong>&lt;K, V&gt; {<br>    <em>// ...<br></em>}</pre><pre>const map = new <strong>OptionMap</strong>&lt;<strong>string</strong>, <strong>number</strong>&gt;();</pre><pre>map.set(&quot;key1&quot;, 10);</pre><pre>map.<strong>get</strong>(&quot;key1&quot;).match({<br>    <strong>Some(val)</strong> {<br>        console.log(&quot;key1&quot;, val);<br>    },<br>    <strong>None()</strong> {<br>        console.log(&quot;key1: None&quot;);<br>    },<br>});</pre><pre>map.<strong>get</strong>(&quot;key2&quot;).match({<br>    <strong>Some(val)</strong> {<br>        console.log(&quot;key2&quot;, val);<br>    },<br>    <strong>None()</strong> {<br>        console.log(&quot;key2: None&quot;);<br>    },<br>});</pre><p>The above code produces the following output.</p><pre>key1 10<br>key2: None</pre><p>The <strong>match method</strong>(.match) on options takes in an object with two functions namely <strong>None</strong> and <strong>Some</strong>. The functions are called in different ways depending on which variant of the option the match method was called on:</p><ul><li>If you call it on a Some it calls the Some function with the value contained inside the some.</li><li>If you call it on a None it calls the None function.</li></ul><p>By using the the match method of the option we can handle both variants of the returned Option declaratively. We can see that using has made our code more readable.</p><h3>Optionem</h3><p>There is also another type that I have observed to be very useful in rust. It is the <strong>**Result**</strong> type.</p><p>Nonetheless it is a really cool simple library use it in your projects, start it on GitHub and Thank you for reading this article.</p><p><a href="https://www.github.com/fraol0912/optionem">https://www.github.com/frectonz/optionem</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=78ffe31a9b66" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>