<?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 Sebastian Sprenger on Medium]]></title>
        <description><![CDATA[Stories by Sebastian Sprenger on Medium]]></description>
        <link>https://medium.com/@seb-sprenger?source=rss-2938ff25802e------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*Buqg02CGgABCwYai0CViRg.jpeg</url>
            <title>Stories by Sebastian Sprenger on Medium</title>
            <link>https://medium.com/@seb-sprenger?source=rss-2938ff25802e------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 16 Nov 2026 18:07:06 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@seb-sprenger/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[The words “MUST”, “MUST NOT”, “REQUIRED”, “SHALL”, “SHALL
 NOT”, “SHOULD”, “SHOULD NOT”…]]></title>
            <link>https://seb-sprenger.medium.com/the-words-must-must-not-required-shall-shall-not-should-should-not-f47d116d5c60?source=rss-2938ff25802e------2</link>
            <guid isPermaLink="false">https://medium.com/p/f47d116d5c60</guid>
            <dc:creator><![CDATA[Sebastian Sprenger]]></dc:creator>
            <pubDate>Sun, 22 May 2022 12:21:31 GMT</pubDate>
            <atom:updated>2022-05-22T12:25:47.323Z</atom:updated>
            <content:encoded><![CDATA[<h3>The words “MUST”, “MUST NOT”, “REQUIRED”, “SHALL”, “SHALL<br> NOT”, “SHOULD”, “SHOULD NOT”, “RECOMMENDED”, “MAY”, and “OPTIONAL”</h3><p>Many specification documents use various words to describe their expectations. I, as a non-native English speaker, always felt somewhat insecure especially about the intricacies of the difference between SHALL and SHOULD and MAY. When looking up the words for example on wiktionary.org it turns out that there are distinct differences.</p><ol><li>SHALL is used to indicate determination or obligation. So much more assertive and therefore closer to MUST.</li><li>SHOULD is used to give advice. Which implies certain voluntariness.</li><li>MAY is used to get or give permission.</li></ol><p>All those terms and their respective meanings are actually well and concisely described in <a href="https://datatracker.ietf.org/doc/html/rfc2119">RFC 2119</a>. With this article and the insights from the dictionary usage of the terms in specifications now feels much more intuitive, nevertheless I created a small infographic to help me remember:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/888/1*Ogx9f7c4H7D1oqclzN8lWA.png" /></figure><p>and boiled it down to a rule of thumb:</p><blockquote>Handle everything, except when you should or must not.</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f47d116d5c60" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Driven? Oriented? Spot the difference!]]></title>
            <link>https://seb-sprenger.medium.com/driven-oriented-spot-the-difference-11f133d1e323?source=rss-2938ff25802e------2</link>
            <guid isPermaLink="false">https://medium.com/p/11f133d1e323</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[event-driven-architecture]]></category>
            <category><![CDATA[test-driven-development]]></category>
            <category><![CDATA[software-architecture]]></category>
            <dc:creator><![CDATA[Sebastian Sprenger]]></dc:creator>
            <pubDate>Mon, 01 Nov 2021 11:11:08 GMT</pubDate>
            <atom:updated>2021-11-01T11:11:08.658Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*rv9kadG6E2Mgx3Os4kQNfQ.jpeg" /></figure><p>In IT we sometimes find things that are called <strong>X-oriented Y</strong> or<strong> A-driven B</strong>. Is it simply naming (#onlyTwoHardThingsInComputerScience) or is there actually a difference? Let’s take a look and try to explore patterns behind the names.</p><h3>X-oriented Y &amp; A-driven B Examples</h3><p>Spontaneously, I can think of several applicable terms in IT which I want to briefly describe in the following sections. This is not an exhaustive list though, you come across others as well.</p><h4>Object-oriented Programming</h4><p>In Object-oriented Programming (OOP) we use objects to structure data (fields, attributes) and code (methods). The Java programming language is very consistent in applying this dogma: In Java everything is a class, even the main function has to be in a class (which is different to C++ or Go). Although C++ was initially thought as “C with classes”. Bottom line, we do programming with objects.</p><h4>Aspect-oriented Programming</h4><p>In Aspect-oriented Programming (AOP) we work encapsulate concerns like logging, metrics, authentication, or remote procedure calls into aspects (e.g. thought the application of proxies). An aspect has a certain shape and clear constraints. Certain things can be done, while others cannot be done with AOP. Again, we are mostly concerned with the what: aspects.</p><h4>Service-oriented Architecture</h4><p>In a Service-oriented Architecture (SOA) we build modules represented as services. Services offer certain things like being accessible via a network interface, the interface conforming to a standard, being very generic and therefore reusable. This is an architecture that consist of services arranged in a certain way.</p><h4>Test-driven Development</h4><p>In Test-driven Development (TDD) we direct the dominant thought towards a testcase. By applying test after test in the red-green-refactor cycle, the production code nearly appears automagically. To make an argument for our oriented-driven discussion, the insight here is: <em>“By focusing on the tests, we get the actual result — the production code.”</em> Of course tests in itself are awesome and absolutely desirable to build confidence in maintaining, extending, changing software.</p><h4>Behavior-driven Development</h4><p>In Behavior-driven Development (BDD) engineers, product owners, and stakeholders come together to describe how a system ought to behave when used in more or less plain English (or any other language). This is a strategy to explore what needs to be build and as such stems from the problem space. By focusing on the behavior we <em>drive </em>the development. Like TDD, this is really more of a methodology.</p><h4>Event-driven Architecture</h4><p>In another article I made the statement that architecture is dealing with the question <em>“what goes where and talks how to whom?”</em>. In Event-driven Architecture (EDA) we look at (domain) events to determine boundaries of systems (what goes where) and interactions between systems (talks how to whom). Similarly to BDD and TDD we focus on something else, namely events, to derive the actual thing: architecture.</p><h3>Summary</h3><p><strong>In X-oriented Y, we do/build Y with X.</strong> We focus on the <em>what</em>.<br><strong>In A-driven B, we focus on A to d(e)rive B.</strong> We put our attention on the <em>how</em>.</p><h3>PS: Data-driven Decisions</h3><p>To me in IT being data-driven means to back-up decisions with data. E.g. invest in self-services which address the top 5 questions/tasks when customers call customer service — and then validate whether or not these self-services actually relieved customer service. I am somewhat torn if my observation applies to Data-driven Decisions. One the one hand we can explore data to find decisions to be made, on the other hand we often face decisions and then dig into the data. E.g. when we want to measure success we already know what we want to decide. The “oriented” label does not seem to fit as well.</p><p>Maybe we need another term like data-<em>based</em> decisions? Maybe I see patterns where are none?</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=11f133d1e323" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Dealing with complexity in software]]></title>
            <link>https://seb-sprenger.medium.com/dealing-with-complexity-in-software-956e1923db2e?source=rss-2938ff25802e------2</link>
            <guid isPermaLink="false">https://medium.com/p/956e1923db2e</guid>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[complexity]]></category>
            <category><![CDATA[technical-debt]]></category>
            <category><![CDATA[architecture]]></category>
            <dc:creator><![CDATA[Sebastian Sprenger]]></dc:creator>
            <pubDate>Sun, 13 Jun 2021 18:22:34 GMT</pubDate>
            <atom:updated>2021-06-13T18:22:34.932Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*le1MFLyCPL2ax5cGu3AQqA.jpeg" /></figure><p>When dealing with software we often complain about complexity. In such situations developing, maintaining, and operating the software get painful. Business as well as engineering are frustrated. Let’s explore.</p><h3>Definition of complexity</h3><p>It seems I have a neck for writing about vaguely defined terms. For “complexity” you can find a <a href="https://en.wikipedia.org/wiki/Complexity_(disambiguation)">disambiguation</a> page on Wikipedia, which more often than not sets you up for a multitude of interpretations. Surprisingly, when complaining about complexity in software, I don’t think we actually want to follow up with the “… in computer science” path that Wikipedia has in store for us. I prefer the rather abstract definition that is proposed on the disambiguation page itself:</p><blockquote>Complexity is the behaviour of a system whose components interact in multiple ways so possible interactions are difficult to describe.</blockquote><p>On a different note, I came to appreciate the <a href="https://en.wikipedia.org/wiki/Cynefin_framework">Cynefin Framework</a> when dealing with problems. It uses the relationship between cause and effect to distinguish between complicated and complex. For complex domains it says:</p><blockquote>Cause and effect can only be deduced in retrospect</blockquote><p>Yet another useful definition I found in the (German) book “<a href="https://www.m-vg.de/redline/shop/article/3688-komplexithoden/">Komplexithoden</a>” (doing the translation myself):</p><blockquote>Complexity is the degree of surprises we need to account for.</blockquote><p>Complementary, I think about something being “complicated” as being inaccessible to those who do not have the appropriate knowledge — but this knowledge can be attained through study.</p><h3>Computers are deterministic, you know?</h3><p>I remember one of those infamous millenial-child-helps-boomer-parent-on-a-computer-thingy calls with my father:</p><blockquote>He: “This computer is illogical!”<br>Me: “Computers are the embodiment of logic.”</blockquote><p>Which brings me to a rather philosophical question: <strong>If computers are based on logic and are deterministic, then it should be possible to determine what is going to happen. Then how can software be surprising? Is software really complex?</strong></p><p>You’d be right to point out here, that when looking at the bigger picture you have to consider other criteria like unpredictable user input, random hardware malfunction, or other unaccounted variables from the unknown unknowns realm. The <a href="https://en.wikipedia.org/wiki/Fallacies_of_distributed_computing">fallacies of distributed computing</a> come to mind.</p><p>I encourage you to take a closer look at what we are actually complaining about. We do not complain about software being complex. Instead, we observe that changes take longer than expected. That estimation feels pointless, because experience tells us that estimates are always wrong. We add something and all of sudden somewhere else something explodes. Our confidence in answering “will this work?” is in free fall.</p><h3>Embracing complexity</h3><p><strong>It does not matter if software itself is complex or not. Reasoning about software systems surely is.</strong> There are tons of branches and possible outcomes we need to consider. When failing to determine everything correctly upfront, we are surprised. Plus there might be variables we simply do not know or have not enough information about (e.g. the network). So we say, that it can only be deduced in retrospect.</p><p>You might think: The only thing we have to do is <strong>analyze</strong> all branches and possible outcomes, right? We have to realize that human beings only have a certain capacity to wrap their head around something. If that capacity limit is reached, we usually add people (four eyes see more than two, right?) and write things down… and all of a sudden are well on our way toward <a href="https://en.wikipedia.org/wiki/Analysis_paralysis">analysis paralysis</a>. Analyzing so much, that we are not progressing forward anymore. More often than not, it’s just not practical in the realm of software. Much like our current cryptography is based on really huge numbers which are not impossible to brute force, but simply impractical to brute force.</p><p>Once a software system has reached a certain level of not-being-able-to-wrap-your-head-around’ness, you should strap in for surprises and dealing with complexity.</p><p><strong>Do not give up.</strong> That would be the attitude of a victim. <strong>Instead, give in to complexity!</strong> Realize and accept that software looks complicated, but dealing with it is indeed complex. To liberate ourselves from our complaints we need to embrace complexity!</p><h3>Invest in understandability</h3><p>How do we actually embrace complexity? When we rephrase the problem, or rather our goal, to “people can wrap their head around it” — then we can get more concrete on practical solutions. What helps people to wrap their head around software?</p><h4>Architecture</h4><p>Structuring things, and doing so consistently, allows for abstract thinking (smaller chunks, hierarchies, patterns, etc) and reduces cognitive load. A major step towards being-able-to-wrap-your-head-around software.</p><p>Architecture is a huge field though. While I cannot pass up on the opportunity to link to my article <a href="https://seb-sprenger.medium.com/of-boxes-and-arrows-32a63aef7039">of boxes and arrows</a>, I actually do not want to go into detail on architecture within in this article. <strong>I want to impress on you how important architecture is in terms of dealing with complexity.</strong></p><h4>Testing</h4><p>The Cynefin Framework suggests for complex domains a probe-sense-respond approach. The low stakes environment in software is automated testing before deployment. A unit or integration test is a very basic yet powerful way for probing and sensing. Good architecture enables such tests. If code is strongly coupled such tests can become hard and more of a burden rather than a tool for experimentation. A healthy test suite can be the difference in answering what is going to happen!</p><p>Also, please keep in mind that the nature of a test can only prove the presence of an error, but <strong>it cannot prove the absence of any error</strong>.</p><h4>Observability</h4><p>Of course surprises hurt the most in production. Production is the high stakes game for probe-sense-respond.</p><p>How many requests do we see? How much load can the system handle? How fast does the auto-scaling respond? What are users actually doing? The answers to such questions are invaluable for reasoning about software and there is only one place to get it from. Being able to observe how production is doing is absolutely key to reason about software systems.</p><p>When I think of observability things like logging, metrics, dashboards, tracing, apm, alerting pop into my head. A starting point that I recommend is this <a href="https://www.youtube.com/watch?v=juP9VApKy_I">talk by Adrian Cole</a>. Additionally, collecting data into an analytics thing (DWH, datalake, datapool, datamesh, etc) and working with that data yields incredible insights and is a true game changer.</p><h4>Experimentation</h4><p>Sometimes we want to answer questions which are absolutely outside of our expertise. How will users behave? How will this perform over that? Applying A/B-tests can help justifying making decisions.</p><h4>DevOps</h4><p>It is cool to have all these pieces in place, but it is equally important to put all the pieces together. Insights from observing production should be fed back into architecture and testing of the system to create a cycle of continuous improvement. Since systems evolve, we need keep them understood.</p><h4>Focus</h4><p>Especially in crisis situations many people’s intuition calls for all hands on deck. Think about how that affects your ability to wrap your head around anything. Though counter-intuitive, consider breaks, a good night’s sleep, starting late, finishing early — if you are dealing with complexity in software.</p><h3>Technical debt</h3><p>If you want to have a car but do not have the money to buy it, you can pick up debt and purchase it right away. Of course you have to pay back some money for some time after the purchase and the total is more than if you had not picked up that debt. At the same time you get that car right away, which can be of tremendous value!</p><p>In software we use the analogy of technical debt: We can deliver features faster, by not doing [any of the above]. By skipping [any of the above], we are picking up technical debt.</p><p>This metaphor carries some risks, as we usually do not treat it seriously. In finance we can precisely measure and manage our debt. If my net income is 5000, I just need to make sure that my expenses do not exceed that limit and I should be fine — also we are usually contracted to regularly pay off our debt. Finally, we can only pick up new debt, if we are deemed credit worthy.</p><p>In software, debt has nothing to do with money. Technical debt is a fancy word for “erosion of quality”. Since it is hard to get a precise measurement of that quality, it is <strong>nearly impossible to <em>responsibly </em>work with this kind of debt</strong>.</p><p>Also, we <strong>usually do not pay back technical debt on a <em>regular </em>basis</strong>. The software system evolves regardless. Even if the inside is not touched, outside variables might change (e.g. user traffic, system filling databases). At some point that technical debt may become really troubling. To stay with the metaphor, <strong>the total amount of payback increases the longer we wait to pay back technical debt</strong>.</p><p><strong>Often times there is no system which checks for technical debt credit worthiness. Somebody needs to keep the balance in check — and it takes courage to do that.</strong></p><p>Think of technical debt as an exponentially growing downward spiral. The more technical debt you have, the more technical debt you accumulate. The more technical debt you have accumulated, that harder it is to pay back technical debt. Escape this vicious cycle by not picking up technical debt, paying back technical debt regularly, and as early as possible.</p><p><strong>Technical debt is a key driver in increasing avoidable(!) complexity of software and therefore negatively impacts the being-able-to-wrap-your-head-around’ness.</strong></p><h3>TL;DR</h3><p>Reasoning about software systems is complex. The larger the system, the more distributed everything is, the more surprises it holds, the harder it is to wrap your head around it. This in turn leads to pain in predicting outcomes of changes which slows development down and may lead to errors which further slow down development. Do not fall into analysis paralysis. Instead embrace complexity and prepare accordingly through good architecture, strong testing and observability capabilities. Technical debt is a downward spiral which makes things worse; treat it accordingly. Whatever you do, try to increase being-able-to-wrap-your-head-around’ness.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=956e1923db2e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Of Boxes and Arrows]]></title>
            <link>https://seb-sprenger.medium.com/of-boxes-and-arrows-32a63aef7039?source=rss-2938ff25802e------2</link>
            <guid isPermaLink="false">https://medium.com/p/32a63aef7039</guid>
            <category><![CDATA[software-architecture]]></category>
            <category><![CDATA[software]]></category>
            <category><![CDATA[architecture]]></category>
            <category><![CDATA[solution-architecture]]></category>
            <dc:creator><![CDATA[Sebastian Sprenger]]></dc:creator>
            <pubDate>Sun, 14 Feb 2021 14:35:40 GMT</pubDate>
            <atom:updated>2021-02-17T09:02:51.329Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8C7QURxHFlXHI8o74b01vw.jpeg" /></figure><p>Every software engineer also acts as a software architect. I want to cover why that is and take a look at the principles, dimensions, aspects to consider in this discipline.</p><h3>What is architecture anyway?</h3><p>In software we often talk about architecture. The term is actually understood rather vaguely as people use it to refer to different things in their mind. The differentiation into software architecture, solution architecture, systems architecture, cloud architecture, or enterprise architecture is not particularly helpful either — at least for explaining what architecture is.</p><p>Presenting architecture definitions is a slippery slope. Please think of this article as <em>that guy’s perspective on architecture</em>.</p><p>There is actually an — in my opinion — not so bad definition in <a href="http://www.iso-architecture.org/ieee-1471/defining-architecture.html">ISO 42010</a>. According to the standard “architecture” is comprised of the</p><blockquote>fundamental concepts or properties of a system in its environment embodied in its elements, relationships, and in the principles of its design and evolution</blockquote><p>Formalities aside, I think of it as</p><blockquote>A concept of <strong>what goes where and talks how to whom</strong>.</blockquote><p>And as a corollary to that</p><blockquote>What are the implications because of that?</blockquote><p>Since software engineers are deciding <em>what goes where and who talks how to whom </em>basically all the time, every software engineer is also an architect.</p><h3>Distributed Systems</h3><p>There are many levels on which architecture happens. In every software system we can decide <em>“what goes where and talks how to whom”.</em> Where classes reside, which packages may call classes located in other packages, which boundaries may or may not be crossed. I call architecture within one software artifact “<strong>software </strong>architecture”.</p><p>In my work I often came across larger systems consisting of several “microservices” (which is yet another ill defined term). I usually drop the “micro” and go with “service”. Deciding what goes into which service and how services talk to each other is part of what I consider “<strong>solution </strong>architecture”. That’s the field I am mostly interested in and that’s what this article will focus on.</p><p>In a software world deciding <em>“what goes where and talks how to whom”</em> yields impactful results towards <a href="https://sarahtaraporewalla.com/agile/design/decade_of_cross_functional_requirements_cfrs">cross-functional requirements</a> or non-functional requirements. Including but not limited to: <em>“How independently can teams work?”</em>, <em>“How independently can engineers within a team work?”</em>, <em>“How easily can responsibility be transferred to another team?”</em>, <em>“What about availability?”</em>, <em>“What is the blast radius if anything goes down?”</em>, <em>“How can the system be scaled?</em>”, <em>“What are the implications for performance?”</em>,<em> “How quickly can we change something?”</em>, <em>“Impact on cost and effort?”</em>, etc and so forth.</p><h3>Architectural Thinking</h3><p>The first part of <em>“what goes where and talks how to whom”</em> entails the second. Depending on <em>what goes where</em> we need to think about <em>who talks how to whom</em>. <em>What goes where</em> is driven by cohesion, while <em>who talks how to whom</em> deals with coupling.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/500/1*b_fOhnulEcFJu0Jlph_UNw.jpeg" /><figcaption>THE architectural problem</figcaption></figure><p>In my eyes, coupling and cohesion is the central anchor point — the essence, if you will — of architectural thinking. Obviously, there is no right or wrong here, there is always a tradeoff, there is always a decision, which by the way gives rise to the infamous all the time correct answer: “It depends”.</p><p>Cohesion describes how much things belong together. We usually want high cohesion. Coupling describes interdependence between things. We usually want low and/or loose coupling (between cohesive units).</p><h3>High Cohesion</h3><p>Deciding <em>what goes where</em>. Drawing some boxes. How hard can it be? Allow me to spoil the fun: It can be extremely tedious and unbelievably hard! To achieve high cohesion I do not think too much about what needs to go in there as I think about what can go elsewhere. A voice in my head reads Antoine de Saint-Exupéry’s quote about perfection to me over and over again:</p><blockquote>“Perfection is achieved, not when there is nothing more to add, but when there is nothing left to take away.”</blockquote><p>Admittedly a good driver for architectural thinking, perfection is more often than not actually not required nor desirable. The cost is simply to high. If we move things from one place to somewhere else, we are creating lots of places which all need attention one way or another. This may result in creating new git repositories, new pipelines, new deployment descriptions, new dashboards, etc — which I like to refer to as “moving parts”. Moving parts drive complexity on any system.</p><p>Cohesion can be considered on different levels of abstraction. The things to look out for are <strong>boundaries</strong>.</p><p>A library could be such a boundary. Say we have code in two libraries which (almost) always go together, then why do we want to have two rather than one? Even if some users do not use all the stuff in your library it may be worthwhile to ship it as one to reduce the hassle of maintaining and integrating them. However, if you have good reasons to create multiple libraries there may be other ways to create cohesion of those libraries. Spring Boot for example provides so called starters, which utilize Maven’s transitive dependency system to form a cohesive unit of things.</p><p>Deployment artifacts or services are another candidate for boundaries. It makes sense to put different things into different services for a variety of technical reasons such as test time, deployment time, scalability, availability, error proneness, etc. At the same time the moving parts argument holds true here as well. Creating tons of small services adds complexity. And we generally try to avoid/decrease complexity because it is so incredibly hard to catch the point where it is still manageable before it punches you in the face. Several services can also be grouped into a cohesive unit. You could apply whatever means your runtime environment (e.g. Kubernetes namespaces, Cloud Foundry spaces, AWS VPCs) has to offer or simply use tags or labels, or don’t do anything at all and remember that grouping from the top of your head. When considering which services belong to one another I find DDD amazingly helpful.</p><p>Another incredibly beneficial question is <em>“if we’d move this service to a different team, what should then go to that team as well?”</em>. This question yields yet another boundary: The team boundary. Thanks to <a href="https://en.wikipedia.org/wiki/Conway%27s_law">Conway’s Law</a> team boundaries are not to be underestimated. Putting things to different teams can be incredibly painful or a pillar of stability in your overall architecture.</p><h3>Loose Coupling</h3><p>Once we have a proposal, a decision, or constraints (e.g. off-the-shelve-products) of <em>what goes where</em>, we need to figure out <em>who talks how to whom</em>. Generating insights from thinking about coupling is crucial in validating or invalidating our thoughts on cohesion. Our learnings here may lead us back to the question <em>what goes where</em> as we may not like what we will find out looking at coupling.</p><p>In terms of boxes and arrows we will now focus on the arrows. When looking at a diagram my first question is usually whether the arrows describe dependencies or message flow (I personally prefer dependencies). Dependencies describe who initiates the communication, while message flow is a result of information being pushed or pulled. Another dimension often expressed with solid or dashed arrows are considerations towards synchronous and asynchronous processing.</p><h4>Dependencies</h4><p>As architects we need to decide who is initiating the communication and who is waiting to be contacted. The box which is initiating the communication has a dependency on the box on the receiving end. If that box is not available, it cannot complete its piece of work. Which actually does not have to be as bad as it sounds as we often can complete work later. The box on the receiving end needs to be aware that load might propagate.</p><p>We want to carefully consider which box needs to know about the other boxes. In my experience this is less dependent on technicalities and more dependent on the use cases. If you need data from another service to execute your use case, you might want to call that other service, especially when it is dynamic stuff. For less urgent and probably more static stuff you can replicate data and keep it locally, then you do not have to reach out to the other service <strong>while </strong>executing your use case — which improves performance and reduces chance for failure. If this approach sounds interesting, I recommend to checkout <a href="https://scs-architecture.org/">self-contained systems</a>.</p><h4>Pulling and Pushing Information</h4><p>Data replication as well as event propagation can be done using pull or push. While dependencies center around the question <em>“who knows about the other service?”</em> message flow is concerned with <em>“who is responsible for making sure that data is where it needs to be</em>?<em>”.</em> Another way to look at it is to consider <em>active </em>and <em>passive</em>. Is a service pulling or is it being pulled? Is a service pushing or is it being pushed to?</p><p>Pulling information often goes hand in hand with <em>polling</em>. Pulling information in short regular intervals. Service A may poll service B to see, if there is new work do to be done. If service B is not available, service A has nothing to do. Once service B comes back online, service A will poll again and if there is new work service A will get to it. Setting up polling is nice because resiliency is already baked in. Depending on your poll rate and your traffic/load in the system you may perform unnecessary calls between the services. This is not super efficient and may produce noise in your monitoring. On the other side every pull can act as a dead man switch which can be used to notice failures in your system. Pulling information may also result in a certain delay. If new information comes in right after you pulled, it takes until the next pull for that information to be transmitted. This may or may not be a problem. Polling can also be used to safeguard a system from overload. Simply poll less frequently if your system is under heavy load.</p><p>To reduce the noise and improve reaction time two systems can use <em>long polling</em>. With this mechanism the client uses a long timeout and the server holds the connection for a certain amount of time if there is no new work to be transmitted. If new work comes in, the server can immediately transmit the new work. As an alternative you can simply poll really often.</p><p>Pulling information can be annoying if you have to poll <strong>various targets</strong> and additional sources pop up all the time. Your service would need to change because another service has been added to the system — a violation of the <em>Open Closed Principle</em>. In that case it would be nice if those new sources would push the information — or let your service know how to poll them.</p><p>Pushing is pretty much the opposite of pull. It transmits only information if it has to (reducing noise) and it does so immediately. However, too many pushes may overload the target system. If the target system becomes unavailable you may have to retry at a later point in time. Failures in form of “pushes do not work anymore” may be hard to detect, as monitoring the absence of something easily leads to false positives. Pushing information can be very effective in scenarios where services do not operate on the same network. When integrating with external services it is often simpler to reach out to them, rather than providing an internet facing endpoint including security aspects which can be pulled.</p><p>Pushing information can also be annoying if you have to push to <strong>various targets</strong> and they keep growing. In this case it would be more convenient if the additional services would pull information from you. Alternatively new services may register a push endpoint with your service in a self-service fashion. Think of webhooks with any 3rd party service.</p><p>Thinking about push and pull usually goes hand in hand with dependencies (they both are expressed by direction of arrows). Please notice that <strong>push and</strong> <strong>pull</strong> may become annoying when various targets are involved. So take a good look at your 1:n and n:1 relationships to decide who should initiate communication.</p><p>Another insightful question to decide the direction of arrows is <em>“if we had to change something, which parts of the system would need to be touched?”</em>. If you had to change several pieces of your system simultaneously to implement a use case, try turning things around and repeat that thought experiment. A concrete example are service mails in e-commerce. There are tons of events which may include a mail: User registered, password lost, order placed, parcel shipped, etc. Should the use cases call the mail service to send that mail or should the mail service poll the use cases if a new mail needs to be sent?</p><p>As a rule of thumb, I like to focus on the use cases and keep the business rules together. Whoever has to make sure that certain things happen, should initiate communication. In my mail example above I definitely favor the use case reaching out to the mail service and push information. I come to a different conclusion when looking at order placement and order fulfillment. To me they are two different use cases and they are even timely decoupled. A user does not expect the order being fulfilled synchronously as part of placing the order. Here, it does make sense for the fulfillment service to poll the placement service asynchronously and reap the benefits of polling. Such use cases make good boundaries for services, even for teams.</p><h4>Synchronous and Asynchronous Processing</h4><p>While every call is technically synchronous we can consciously decide to make the processing and message flow synchronous or asynchronous. An asynchronous call has the notion of accepting the request, immediately returning, and then working in the background. When we learn programming we usually start out with synchronous calls (e.g. calling a function, sending an http request).</p><p>At first glance synchronous calls look awesome! They tend to be easy to follow along, easy to debug, work on current data, perform the thing they are supposed to do at the earliest point in time possible. Why would anyone ever need anything else? On second sight we notice, that the error modes need some work to be dealt with properly. What should happen if a synchronous call fails? Report back to the user? Retry? If so, how often or until when? A chain of synchronous calls may increase the wait time until all involved parties did complete their work. All timeouts need to consider all the calls and their timeouts down the road. If multiple services are involved and all work on data, we may be confronted with transactional requirements. A failure in a chain may result in inconsistent data. Another interesting aspect is scaling, if one tier of services receives increased load, synchronous calls cascade the pressure throughout the system. I am surely just scratching the surface, however, it should become clear that synchronous calls are a double-edged sword.</p><p>Asynchronous processing on the other side usually comes with a retry mechanism baked in, they allow buffering which safeguards from overload, enable concurrent designs (I highly recommend Rob Pike’s talk “<a href="https://www.youtube.com/watch?v=oV9rvDllKEg">Concurrency is not Parallelism</a>”), and can be equally fast compared to synchronous calls. However, asynchronous processing feels awkward, especially when you are not used to it. It may lead to opaqueness which makes it hard to follow what is happening where and when, which makes it extremely taxing to think and reason about. In addition, there is no guarantee as to when the work will be finished. Reporting back errors can only be done in an asynchronous way, which may or may not fit the use case. Also, asynchronous processing promotes eventual consistency, which can be mind boggling on its own. Eureka! Asynchronous processing is a double-edged sword as well. Welcome to engineering.</p><p>Depending on your environment a choice between synchronous and asynchronous processing can be huge. I work a lot with event-driven architecture where asynchronous processing fits in quite nicely. As asynchronous processing reduces the dependency on other parts of the system being available and properly scaled, I came to <strong>default to asynchronous processing over synchronous processing</strong>, except for good reason.</p><h3>TL;DR</h3><p>IMHO coupling and cohesion are at the heart of architectural thinking. Deciding <em>what goes where and who talks how to whom</em> plus dealing with the implications of those decisions are what architects do in a software world. While cohesion is a discussion about boundaries (lib, service, team), coupling is an discussion about dependencies, message flow (push/pull), and processing modes (sync/async). I focus on use cases for orientation in deciding what goes where as well as dependency management and message flow. As I usually default to asynchronous processing over synchronous processing (except for good reason), I also lean towards pull over push.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=32a63aef7039" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What Spring can teach us about framework design]]></title>
            <link>https://seb-sprenger.medium.com/what-spring-can-teach-us-about-framework-design-559c7d6fafd8?source=rss-2938ff25802e------2</link>
            <guid isPermaLink="false">https://medium.com/p/559c7d6fafd8</guid>
            <category><![CDATA[spring-boot]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[spring]]></category>
            <category><![CDATA[plugins]]></category>
            <category><![CDATA[framework]]></category>
            <dc:creator><![CDATA[Sebastian Sprenger]]></dc:creator>
            <pubDate>Mon, 18 Jan 2021 19:08:05 GMT</pubDate>
            <atom:updated>2021-01-18T19:08:05.376Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*cA00pgFasN1-WsRbIikbHQ.jpeg" /></figure><p>In <a href="https://seb-sprenger.medium.com/the-difference-between-frameworks-and-libraries-6255cb977c53">this article</a> I claimed that every framework works somewhat like this:</p><ol><li>Write a plugin.</li><li>Register plugin with the framework.</li><li>Transfer control to framework.</li></ol><p>I also explained that <em>most </em>frameworks do this by offering an <em>interface </em>which we can implement (writing plugin). Then tell the framework when to use the implementation of the interface (registering plugin), and finally call a function of the framework which might not return (transfer of control). The Spring Framework follows the same (abstract) pattern, but its practical approach is a little different. It yields two interesting insights when thinking about frameworks. Let us have a quick comparison to other frameworks before we look at how Spring is handling plugins.</p><h3>express.js</h3><p>A popular web framework in the JavaScript world is <a href="https://expressjs.com/"><strong>express.js</strong></a>. A <em>hello world</em> looks like this:</p><pre>const express = require(&#39;express&#39;)<br>const app = express()</pre><pre>// write a plugin<br>var greeting = (req, res) =&gt; {<br>  res.send(&#39;Hello World!&#39;)<br>}</pre><pre>// register plugin with framework<br>app.get(&#39;/hello&#39;, greeting)</pre><pre>// transfer control to framework<br>app.listen(8080)</pre><p>Once traffic hits :8080/hello the framework invokes our plugin. Perfect.</p><p>JavaScript is a dynamic programming language which does not know explicit interface types. However, by calling functions on something you are implicitly defining an interface (<a href="https://en.wikipedia.org/wiki/Duck_typing">duck typing</a>) — and Express calls (read <em>expects</em>) a function with the signature (request, response).</p><h3>Go standard library</h3><p>The Go programming language ships with a <a href="https://gobyexample.com/http-servers">web framework</a> in its standard library under net/http:</p><pre>package main</pre><pre>import (<br>  &quot;fmt&quot;<br>  &quot;net/http&quot;<br>)</pre><pre>func main() {<br>  // write a plugin<br>  var greeting = func(w http.ResponseWriter, r *http.Request) {<br>    fmt.Fprintf(w, &quot;Hello World&quot;)<br>  }</pre><pre>// register plugin with framework  <br>  http.HandleFunc(&quot;/hello&quot;, greeting)</pre><pre>// transfer control to framework<br>  http.ListenAndServe(&quot;:8080&quot;, nil)<br>}</pre><p>Go is a statically typed language. The http.HandleFunc() explicitly wants us to provide something according to the specified interface. So, here as well interfaces are at work to accomplish the plugin functionality.</p><h3>Spring</h3><p>In the Java world <a href="https://spring.io/">Spring</a> is a popular framework for <em>nearly everything</em> including web. For the hello world we typically write a so called controller:</p><pre>package com.example.hello;</pre><pre>import org.springframework.stereotype.Controller;<br>import org.springframework.web.bind.annotation.GetMapping;<br>import org.springframework.web.bind.annotation.ResponseBody;</pre><pre>@Controller<br>class Hello {<br>    @ResponseBody<br>    @GetMapping(&quot;/hello&quot;)<br>    String greeting() {<br>        return &quot;Hello World&quot;;<br>    }<br>}</pre><p>And then have another class which includes the main() function:</p><pre>package com.example.hello;</pre><pre>import org.springframework.boot.SpringApplication;<br>import org.springframework.boot.autoconfigure.SpringBootApplication;</pre><pre>@SpringBootApplication<br>class HelloWorld {<br>   public static void main(String[] args) {<br>      SpringApplication.<em>run</em>(HelloWorld.class, args);<br>   }<br>}</pre><p>We can clearly see the controller acting as plugin. Considering that Java is statically typed language it is surprising though that we do not have to implement an interface in the Hello class ¯\_(ツ)_/¯.</p><p>The @GetMapping in the Hello class maps the path to the function.</p><p>First thing we do in our main() function is transferring control to Spring by calling a static function.</p><p>Please note that we <strong>never </strong>created a reference to the plugin and provided it to the framework. How exactly did Spring know about our plugin — or in other words, where exactly did we register our plugin with the framework?</p><h3>The Spring way</h3><p>Let us try to follow the code. In the main() function we call a static run() function of Spring and provide the main class HelloWorld as parameter. Spring then analyzes HelloWorld and finds @SpringBootApplication which really is a shortcut for @ComponentScanamongst other things. Because of that annotation the run() function (remember annotations by themselves do not do anything) traverses down all packages starting with HelloWorld‘s package — in our case com.example.hello and looks at each and every class in there. If the looked at classes are annotated with a @Component or one of its pals (@Controller, @Service, @Repository, etc) Spring will <em>take care</em> of it. You might say Spring considers it as a plugin.</p><p>For each class that Spring considers a plugin it creates a so called <em>bean definition</em>. It <strong>uses reflection</strong> to get an idea how the class is structured, how its constructors look like and which parameters they require. This allows Spring to create instances of the classes it is taking care of. Quite noteworthy, since it is using reflection, <strong>it does so without ever actually mentioning the name of the class or constructor in its code</strong>. Instead of using an interface to know upfront what needs to be called, Spring identifies everything dynamically. You may think of every bean as a plugin to Spring’s dependency injection functionality.</p><p>While analyzing the classes Spring also finds the @GetMapping annotation in the Hello class and therefore maps the /hello path to the greeting() function. Since Spring basically resolves to <a href="https://en.wikipedia.org/wiki/Duck_typing">duck typing</a> in Java our function has to have a certain signature for it to work.</p><h3>Takeaway</h3><p>There are two things to take away here.</p><ol><li><strong>The traversal and scanning allows Spring to register plugins in a declarative way with annotations</strong>. This is incredibly generic and simply brilliant looking from an <em>Open-Closed-Principle (OCP)</em> perspective.</li><li>Frameworks need to know how to interact with a plugin without having a dependency on the specifics of the plugin (e.g. its name). <strong>Interfaces are <em>one </em>solution to the problem and there are other solutions as well, like Spring impressively demonstrates with reflection.</strong> Another possible approach is a protocol describing the interaction contract via IPC or network.</li></ol><h3>Think bigger</h3><p>Frameworks are not a code-only thing, I like to think of them as a <em>pattern</em> to organize components and responsibilities. With that being said, frameworks can be a fantastic way to make your solution architecture more flexible. If you are interested in a networked example checkout the <a href="https://www.openservicebrokerapi.org/">OpenServiceBroker API</a> which is a framework to bring together 3rd party services with your apps running on Cloud Foundry or Kubernetes — and it interacts with its plugins via REST.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=559c7d6fafd8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The difference between frameworks and libraries]]></title>
            <link>https://seb-sprenger.medium.com/the-difference-between-frameworks-and-libraries-6255cb977c53?source=rss-2938ff25802e------2</link>
            <guid isPermaLink="false">https://medium.com/p/6255cb977c53</guid>
            <category><![CDATA[code]]></category>
            <category><![CDATA[software]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[framework]]></category>
            <category><![CDATA[engineering]]></category>
            <dc:creator><![CDATA[Sebastian Sprenger]]></dc:creator>
            <pubDate>Mon, 11 Jan 2021 20:56:01 GMT</pubDate>
            <atom:updated>2021-01-13T20:53:11.077Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bwq2DZgDEedqDGAxZM8I1Q.jpeg" /></figure><p>In software engineering we often reuse code. There is even a Clean Code principle called <em>Don’t Repeat Yourself (DRY)</em> which is encouraging code reuse. <em>Frameworks </em>and <em>libraries </em>are not written to solve a distinct or unique problem. They are written to be reused in specific cases and that way solve thousands and millions of problems. Let us take a look at both of them and discuss the difference.</p><h3>Libraries</h3><p>A library is a piece of code that ships in a decent format to be integrated into other programs. Instead of kicking off a main function it usually provides classes and/or functions that can be used by your application. Libraries solve reoccurring problems that are usually super annoying and complicated. Examples are parsing stuff (JWT, JSON, XML, date formats, command line arguments), utilities, or specialized data structures. <strong>A library knows the details</strong> and in a way you ask it for an answer to a question.</p><p>The critical observation here is this: <strong>Your code orchestrates the library</strong>. When using a library in your code you have to mention its name (I will call that a <em>compile time dependency</em> even if you use a dynamic language) and you will have to call one its functions and they will return. At runtime your code calls into the library.</p><h3>Frameworks</h3><p>Frameworks and libraries are <strong>very </strong>similar in that frameworks also solve annoying, complicated, and reoccurring problems — but they differ in their approach. A framework always <em>does something. </em>It does something where it ultimately does not know the answer to and needs your help in form of a <em>plugin</em>. <strong>The plugin provides the details</strong>.</p><p>A classic example is a web framework: Web frameworks spin up a server listening on a given port, probably deal with TLS, parse HTTP messages coming in, looking for markers like host-names, paths, and then try to handover control to a plugin — which has to come from you. By using a framework you reuse a ton of code so you do not have to deal with all that jazz around dealing with HTTP messages and can focus instead on defining the answer to that web request — or in framework terms: you can focus on writing a plugin (we often call this “controller”).</p><p>The framework needs a way to call the plugin without knowing its specific name. Often (not always), you need to implement one of the frameworks interfaces, e.g. an void handle(HttpRequest request, HttpResponse response) method and then tell the framework when to use this implementation.</p><p>In my experience <strong>every </strong>framework works somewhat like this:</p><ol><li>Write a plugin</li><li>Register the plugin with the framework</li><li>Transfer control to the framework</li></ol><p>The critical observation here is this: <strong>The framework orchestrates your code</strong>. When using a framework you have to mention its name for initialization and configuration, so again you have a compile time dependency. But <strong>once you transfer control </strong>to the framework it (usually) does not return. Because the framework starts <em>doing its thing</em>.</p><h3>And that’s the difference</h3><p>When using a library, at runtime, your code is calling into the library. When using a framework, at runtime, the framework is calling into your code (via plugins).</p><p>When talking about frameworks we often refer to this concept as Inversion of Control (IoC), as <strong>the flow of control opposes the compile time dependencies</strong>.</p><h3>Encore</h3><p>This concept can also be used on a much smaller scale. Imagine you have some code with lots of branches:</p><pre>void handle(String status) {<br>  switch (status) {<br>    case &quot;ALL_GOOD&quot;:<br>      green(); break;<br>    case &quot;NEEDS_ATTENTION&quot;:<br>      amber(); break;<br>    case &quot;CRITICAL&quot;:<br>      red(); break;<br>  }<br>}</pre><p>You could instead create implementations of an interface Handler and map them to a Status in a Map&lt;String, Handler&gt;, then lookup the handler, and just call it:</p><pre>statusHandlers.put(&quot;ALL_GOOD&quot;, greenHandler);<br>statusHandlers.put(&quot;NEEDS_ATTENTION&quot;, amberHandler);<br>statusHandlers.put(&quot;CRITICAL&quot;, redHandler);</pre><pre>statusHandlers.get(status).handle();</pre><p>This style is also known as <em>if-less programming</em> and is an example of the <em>Open-Closed-Principle (OCP)</em>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6255cb977c53" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>