<?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 Hamed Monji on Medium]]></title>
        <description><![CDATA[Stories by Hamed Monji on Medium]]></description>
        <link>https://medium.com/@absentmindedness?source=rss-da00946843b7------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*zPQliz8fe2Gcef9QAU2amQ@2x.jpeg</url>
            <title>Stories by Hamed Monji on Medium</title>
            <link>https://medium.com/@absentmindedness?source=rss-da00946843b7------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 01 Dec 2026 16:46:16 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@absentmindedness/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[Architecture — Boundaries and Leaks]]></title>
            <link>https://absentmindedness.medium.com/architecture-boundaries-and-leaks-ebaef8c02e2d?source=rss-da00946843b7------2</link>
            <guid isPermaLink="false">https://medium.com/p/ebaef8c02e2d</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[clean-code]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[software-architecture]]></category>
            <dc:creator><![CDATA[Hamed Monji]]></dc:creator>
            <pubDate>Tue, 09 Mar 2021 13:52:18 GMT</pubDate>
            <atom:updated>2021-03-09T14:26:15.743Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*ZXwxoHZUuX__gdyG" /><figcaption>Photo by <a href="https://unsplash.com/@pawel_czerwinski?utm_source=medium&amp;utm_medium=referral">Paweł Czerwiński</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><h3>Architecture — Boundaries and Leaks</h3><h3>Architecture — Boundaries and Leaks</h3><p>In this article, we’ll take a general look at <strong>software architecture</strong> and what it is and a more detailed look at architectural boundaries and leaks. But surprisingly we have to start with boundaries!.</p><h3>What are Boundaries</h3><blockquote><em>Boundaries separate software elements from one another, and restrict those on one side from knowing about those on the other. Robert Cecil Martin. Clean architecture</em></blockquote><p>Boundaries separate software elements, but why separate them!?. The answer is simple, to minimize change, meaning a change in one side of the boundary should not cause a change on another side. this is the core of every software architecture pattern, in fact, you might be able to describe what architecture means using the following</p><blockquote><strong><em>Software Architecture is defining rules that describe where boundaries live and how they communicate with each other.</em></strong></blockquote><p>Having boundaries doesn’t mean nothing from one side can never go to the other side, but rather it places a structure for clear communication rules. Once boundaries are clear you can decide on what should cross those boundaries and how it should be done. But before we look at that let see what should be inside the boundary itself first.</p><h3>Single Responsibility of Boundaries</h3><p>Each boundary should only have one responsibility, between the previous boundary and the next one, there should only be one reason for change.</p><p>With that in mind let’s look at what and how should we cross a boundary.</p><h3>Crossing Boundaries</h3><blockquote><em>when crossing a boundary the reason for change should not cross along to the next boundary.</em></blockquote><p>When a boundary receives some data from somewhere outside of its borders it should still only know the one reason that it was designed to know, and nothing more. If when passing a boundary line the next boundary receives information that makes it know about the previous boundary&#39;s responsibility then there has been an <strong>Architecture Leak</strong>.</p><h3>Leaks</h3><p>We usually think of leaks in form of memory leaks and sometimes as implementation and leaks. Architecture leaks are kind of like implementations leaks except for the implementation that is leaked is at the architecture level.</p><p>Leaks happen when one boundary&#39;s responsibility crosses over to another. Let’s take a look at a few ways leaks can happen.</p><h3>Names</h3><p>Variable names, function names, and everything that crosses a boundary can cause a leak. For instance, imagine you have three boundaries. The first one is responsible for UI-related stuff so any views live here, the second one is the UI logic, you can think of it as a presenter and the last one is the business logic.</p><p>Now image in the first boundary a click happens this click should save the information user has entered. A typical approach is to have the click call a function in the presenter so let’s The UI passes the username and password to the presenter by calling saveButtonClicked. In the second layer, the presenter stores these two values inside an object and gives them to the third boundary by calling a function again called saveButtonClicked.</p><p>The leak in the example above is the saveButtonClicked in the third layer. This layer has no awareness about the UI which is the first boundary but yet somehow it has the words ‘button’ and ‘clicked’ in its name as if it knows that there exists a save button somewhere in the application.</p><p>You might ask isn’t the first saveButtonClicked a leak too? that really depends on how you’ve chosen your boundaries but in each architecture, one layer has to know about the other. there is always a dependency, however in this case the second saveButtonClicked name is <strong>OK</strong> because it is within the responsibility of the second layer namely the presenter to know about UI, at least this part of it and also in this example the presenter is acting as a cross-boundary layer where it acts as a firewall between the two boundaries connecting them together without them knowing about each other.</p><p>I used function names as an example but it could have easily been any other kind of name, like variable names of the object that is passed to another boundary.</p><h3>Comments</h3><p>Much like In the same way that names caused a leak between architectural boundaries comments can do that to</p><pre>/**<br> * There was an error. You should show the message in red color.<br> */<br>public static final int ERROR = 3;</pre><p>The code above is from a class far from the UI boundary. This boundary also has no dependency on the UI boundary but for some reason, this comment knows how this error should be displayed in the UI boundary!. This is a clear example of how a comment can cross a boundary and cause a leak.</p><h3>Un Aligned boundaries</h3><p>Imagine class A depends on B and B depends on C. Now imagine A has some need C can solve but we can’t wrap it in B because it would violate the single responsibility for B. The simple choice here is to let A depend on C directly. this would cause the dependency graph to be in such a way that C now resides in both after B and before B. This is unaligned Boundaries. when something like this happens it’s better to wrap C in some other class So that A can depend on it such that C stays in the third layer instead of being on two different layers.</p><h3>Protecting Against Leaks</h3><p>When it comes to protecting against these kinds of leaks there are different ways that we can protect our code and mostly they depend on how your code is set up but there is one simple rule that can be used to ensure boundaries are crossed properly.</p><h3>Think Inside the Box</h3><p>The most important thing to do when writing code inside a boundary is to imagine you don’t know about any other boundaries. in both of the previous examples the names and comments were written with the full knowledge of the programmer rather than the full knowledge of that particular boundary. Remember boundaries are there to protect from change, the only way to do that is to not know about the reason for the change.</p><h3>Nothing Has Changed</h3><p>I hope you realized that most things we do, from SOLID to architecture principles, it’s all <strong>Limit Change</strong>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ebaef8c02e2d" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>