<?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 Johannes Zilg on Medium]]></title>
        <description><![CDATA[Stories by Johannes Zilg on Medium]]></description>
        <link>https://medium.com/@mail_47689?source=rss-f68e17973c12------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*AYK2_bx2W4LL67pkkR13KQ.jpeg</url>
            <title>Stories by Johannes Zilg on Medium</title>
            <link>https://medium.com/@mail_47689?source=rss-f68e17973c12------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 22 Nov 2026 13:41:43 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@mail_47689/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[Good changes, bad changes]]></title>
            <link>https://blog.dasburo.com/good-changes-bad-changes-6eab46becd8c?source=rss-f68e17973c12------2</link>
            <guid isPermaLink="false">https://medium.com/p/6eab46becd8c</guid>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Johannes Zilg]]></dc:creator>
            <pubDate>Wed, 07 Aug 2024 08:56:55 GMT</pubDate>
            <atom:updated>2024-08-07T09:11:38.807Z</atom:updated>
            <content:encoded><![CDATA[<p>Code changes all the time, and of course, it does. The main purpose of software is that it is flexible.</p><p>But considering that we change software so often, I believe that we think too little about this topic.</p><p>Because not every change is the same. So, let us break this down.</p><p>In fact, there are <strong>five</strong> different ways you can change your code. Some are good, and some are bad.</p><p>We can tell whether a change is good or bad by whether it leads to a breaking change or not.</p><h4>good changes</h4><ul><li>require less</li><li>provide more</li><li>improve it</li></ul><h4>bad changes</h4><ul><li>require more</li><li>provide less</li></ul><p>For the following examples, we will look at the signature of a function written in TypeScript. But this is true for every kind of interface, whether it is a REST API or a CLI tool.</p><p>Our function simply takes two parameters of type string and returns an object with the properties <em>x</em> and <em>y</em>, which are also strings.</p><pre>type MyFn = (a: string, b: string) =&gt; ({<br>  x: string,<br>  y: string,<br>})</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WnndESqPDwUOSFBHp7MYnw.png" /></figure><h3>Provide more</h3><p>Probably the simplest way to change your function in a good way is to provide more in its result.</p><p>In our example, the function now returns a new field <em>z</em>. This is a good change because the consumers of this function are not affected by this change.</p><p>They can access the new field <em>z</em> whenever they want.</p><pre>type MyFn = (a: string, b?: string) =&gt; ({<br>  x: string,<br>  y: string,<br>  z: number, // 👍🏻<br>})</pre><h3>Require less</h3><p>Another thing you can do is require less to perform your computation. In the case of our example this could mean that we make the second param optional.</p><p>This way everything works as before and the consumer could refactor the code whenever they want.</p><p>❗Note that we only make the parameter optional.</p><p>If we removed it from the signature, every consumer of this function would get a TypeScript compile error because they would be providing an unknown parameter to the function -&gt; breaking change.</p><pre>type MyFn = (a: string, b?: string /*👍🏻*/) =&gt; ({<br>  x: string,<br>  y: string,<br>})</pre><h3>Provide less</h3><p>A bad way of changing your code is changing the output of your function.</p><p>It does not matter whether you’re removing a field, renaming it, or changing its type.</p><p>The consumers of the function will try to access something that will not behave as expected or will not be there anymore.</p><p>This is a breaking change that will lead to a compile error at best or a runtime error at worst.</p><p>Either way, you should <strong>never</strong> do that!</p><pre>type MyFn = (a: string, b: string) =&gt; ({<br>  x: string,<br>  // y: string 👎🏻<br>})</pre><pre>type MyFn = (a: string, b: string) =&gt; ({<br>  x: string,<br>  w: string, // 👎🏻<br>})</pre><pre>type MyFn = (a: string, b: string) =&gt; ({<br>  x: string,<br>  y: number, // 👎🏻<br>})</pre><h3>Require more</h3><p>Another bad way of changing your code is requiring more to perform your computation.</p><p>If we introduced another parameter to our function, all consumers would have to react to it immediately -&gt; Breaking change!</p><pre>type MyFn = (a: string, b: string, c: boolean /*👎🏻*/) =&gt; ({<br>  x: string,<br>  y: string,<br>})</pre><h3>Improve it</h3><p>The last way you can change your code is just by improving it without changing its signature.</p><p>This could mean that the code now runs free of errors or performs better. You can and should always do that.</p><h3>TypeScript Union Types vs. Optionals</h3><p>TypeScript union types offer a way to handle optional parameters without introducing breaking changes. Since an optional in TS just means a union of the type you want and <em>undefiend</em>.</p><p>This is in contrast to languages like Java, where making a parameter optional can lead to breaking changes, even if the change is generally beneficial.</p><p>For example the method on this interface has two parameters of type String.</p><pre>interface MyInterface {<br>  void myMethod(String a, String b);<br>}</pre><p>If you make the second param Optional, all consumers of this method would need to pass an Optional instead of a string.</p><p>This is a breaking change even if it was well-intentioned.</p><pre>import java.util.Optional;<br>  interface MyInterface {<br>  void myMethod(String a, Optional&lt;String&gt; b /*👎🏻*/);<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*64GPPicd7JHvQUGMdBnQog.png" /></figure><h4>About</h4><p><a href="https://t.dasburo.io/b78f46"><em>Büro am Draht</em></a><em> </em>is a Berlin-based consultancy helping our clients to build resilient and adaptable digital platforms to support today’s business requirements and even launch tomorrow’s business models we might not yet foresee. Hence, we work closely together at every stage of the digital transformation process — from digital strategy to solution design &amp; development to operational support.</p><p>Our agile approach to developing versatile and scalable solutions ensures our clients consistently deliver engaging and personalized customer experiences. To learn more about how we help companies across industries visit:</p><p><a href="https://t.dasburo.io/b78f46">dasburo.com</a><br><a href="https://t.dasburo.io/6ce68e">LinkedIn</a></p><p>Want to hear from our experts on a regular basis? <br>Sign up for our newsletter (published in <em>German</em>) <a href="https://dasburo.com/newsletter?place=blog"><em>here</em></a>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6eab46becd8c" width="1" height="1" alt=""><hr><p><a href="https://blog.dasburo.com/good-changes-bad-changes-6eab46becd8c">Good changes, bad changes</a> was originally published in <a href="https://blog.dasburo.com/">Büro am Draht</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>