<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
    <title>ralfw-de</title>
    <link href="https://ralfw.de/feed.xml" rel="self" />
    <link href="https://ralfw.de" />
    <updated>2022-06-29T15:55:48+08:00</updated>
    <author>
        <name>Ralf Westphal</name>
    </author>
    <id>https://ralfw.de</id>

    <entry>
        <title>Flüssiger bloggen</title>
        <author>
            <name>Ralf Westphal</name>
        </author>
        <link href="https://ralfw.de/fluessiger-bloggen/"/>
        <id>https://ralfw.de/fluessiger-bloggen/</id>

        <updated>2022-06-29T15:55:48+08:00</updated>
            <summary>
                <![CDATA[
                    Es ist stiller geworden auf meiner Homepage - denn meine Aktivität habe ich auf einen Newsletter verlagert: https://ralfwestphal.substack.com/. Wahrscheinlich wäre eine Abnahme meiner Aktivität sogar eine natürliche Entwicklung über all die Jahre. Immerhin schreibe ich seit 2003 Blog-Artikel. Dass ich nach knapp 20 Jahren nicht&hellip;
                ]]>
            </summary>
        <content type="html">
            <![CDATA[
                <p>Es ist stiller geworden auf meiner Homepage - denn meine Aktivität habe ich auf einen Newsletter verlagert: <a href="https://ralfwestphal.substack.com/" target="_blank" rel="noopener noreferrer">https://ralfwestphal.substack.com/</a>.</p>
<p>Wahrscheinlich wäre eine Abnahme meiner Aktivität sogar eine natürliche Entwicklung über all die Jahre. Immerhin schreibe ich seit 2003 Blog-Artikel. Dass ich nach knapp 20 Jahren nicht mehr so ideensprudelnd bin, kann ich mir eigentlich nicht verdenken.</p>
<p>Einerseits. Denn andererseits haben mich gerade die letzten beiden Jahre gedrängt, einiges zu schreiben - nur nicht unbedingt über die Softwareentwicklung. Die Corona-Jahre haben mich tief bewegt und ich musste "da etwas loswerden". Das passte allerdings nicht zu meiner softwaretechnisch orientierten Homepage. Also habe ich angefangen, auf anderen Plattformen zu bloggen.</p>
<p>Interessanterweise fiel mir dort der Schreibprozess auch leichter; ich konnte wieder flüssiger schreiben. Die Editoren zuerst bei medium und dann bei Substack waren schlicht besser als der für meine Homepage. Und das live Schalten von Beiträgen war auch etwas einfacher. (Seit einigen Jahren habe ich mich von Wordpress für meine Homepage verabschiedet und setze auf static HTML; so habe ich keine Last mit irgendwelchen Plug-Ins oder Cookies. Alles so schön schlank mit <a href="https://getpublii.com/" target="_blank" rel="noopener noreferrer">Publii</a> und GitHub Pages.)</p>
<p>Doch nach längerer Zeit der Divergenz möchte ich jetzt das Dortige zum Hiesigen hinzufügen. Deshalb gibt es im Blog-Menü einen neuen Eintrag: "Newsletter". Der verweist auf mein <a href="https://ralfwestphal.substack.com/" target="_blank" rel="noopener noreferrer">Substack-Blog</a>, das Substack <em>Newsletter</em> nennt, weil über neue Beiträge immer gleich auch per Email informiert wird, wenn man sich als Abonnent eingetragen hat. Dieses Feature hatte meinem Blog in all den Jahren gefehlt.</p>
<p>Die Beiträge hier auf meiner Homepage werde ich einstellen. Ich nutze sie nur noch für recht statische Inhalte, z.B. die Beschreibung meiner Trainings. Alles, was dynamisch ist, findet zukünftig bei Substack statt. Ich denke, das ich eine hübsche Trennung im Sinne des <em>Separation of Concern</em> (<em>SoC</em>) Prinzips. (Ob das für SEO der Hit ist, weiß ich nicht. Aber hinter dem besten Google-Ranking renne ich ohnehin nicht hinterher.)</p>
<p>Mein Substack-Blog kann man per kostenlosem Email-Abo verfolgen oder sich als RSS-Feed in einen RSS-Reader wie <a href="https://reederapp.com/" target="_blank" rel="noopener noreferrer">Reeder</a> ziehen lassen. Ich bin seit einiger Zeit wieder Fan dieser alten Technologie; sie fühlt sich der Idee des Internet näher an als die Social Media Plattformen.</p>
<p>Bei Substack ist mein Blog in mehrere Kategorien unterteilt. So kann ich sowohl über Technisches wie Gesellschaftliches und Politisches berichten, ohne dass es sich zu sehr in die Quere kommt. Auf der Hauptseite kommt zwar alles aus den Kategorien zusammen, doch wer sich nur für Technisches interessiert, kann sich z.B. auf den Newsletter "<a href="https://ralfwestphal.substack.com/s/clean-code-development" target="_blank" rel="noopener noreferrer">Clean Code Development</a>" konzentrieren.</p>
<figure class="post__image"><img loading="lazy"  style="color: var(--text-primary-color); font-family: var(--editor-font-family); font-size: inherit; font-weight: var(--font-weight-normal); outline: 3px solid rgba(var(--color-primary-rgb), 0.55)  !important;" src="https://ralfw.de/media/posts/152/newsletter-screenshot.jpg" sizes="(max-width: 48em) 100vw, 768px" srcset="https://ralfw.de/media/posts/152/responsive/newsletter-screenshot-xs.jpg 300w ,https://ralfw.de/media/posts/152/responsive/newsletter-screenshot-sm.jpg 480w ,https://ralfw.de/media/posts/152/responsive/newsletter-screenshot-md.jpg 768w ,https://ralfw.de/media/posts/152/responsive/newsletter-screenshot-lg.jpg 1024w ,https://ralfw.de/media/posts/152/responsive/newsletter-screenshot-xl.jpg 1360w ,https://ralfw.de/media/posts/152/responsive/newsletter-screenshot-2xl.jpg 1600w"  alt="" width="800" height="646"></figure>
<p><span style="color: var(--text-primary-color); font-family: var(--editor-font-family); font-size: inherit; font-weight: var(--font-weight-normal);">Ich weiß, solche Änderungen bringen Unruhe in meinen Web-Auftritt. Sollte der nicht stabil sein und alles, alles auf der Homepage unter meiner Domain zusammenziehen? Ja, vielleicht. Aber ich möchte neue Entwicklungen auch mitnehmen können, hier: eine Plattform, die das Bloggen und den Versand von Newslettern noch einfacher macht. Ich vertraue deshalb einfach mal darauf, dass der Effekt nicht zu negativ sein wird.</span></p>
<p>Insofern: Ich würde mich freuen, wenn Sie mir auch zu Substack folgen würden, mit oder ohne Email-Abo.</p>
            ]]>
        </content>
    </entry>
    <entry>
        <title>Wert mehr als Komplexität</title>
        <author>
            <name>Ralf Westphal</name>
        </author>
        <link href="https://ralfw.de/wert-mehr-als-komplexitaet/"/>
        <id>https://ralfw.de/wert-mehr-als-komplexitaet/</id>
            <category term="Scrum"/>
            <category term="Agilität"/>

        <updated>2021-01-31T15:03:20+08:00</updated>
            <summary>
                <![CDATA[
                        <img src="https://ralfw.de/media/posts/151/Bildschirmfoto-2021-01-30-um-16.48.10.png" alt="" />
                    Wie misst ein agiles Softwareteam - gar eines, das Scrum einsetzt - eigentlich seinen Fortschritt? In Erinnerung sind mir da noch burn-down und burn-up Charts, in denen Story Points aufgetragen werden. Ist das aber wirklich hilfreich und zeitgemäß? Interessanterweise kommen Story Points im Scrum Guide&hellip;
                ]]>
            </summary>
        <content type="html">
            <![CDATA[
                    <img src="https://ralfw.de/media/posts/151/Bildschirmfoto-2021-01-30-um-16.48.10.png" alt="" />
                <p>Wie misst ein agiles Softwareteam - gar eines, das Scrum einsetzt - eigentlich seinen Fortschritt? In Erinnerung sind mir da noch burn-down und burn-up Charts, in denen Story Points aufgetragen werden. Ist das aber wirklich hilfreich und zeitgemäß?</p>
<p>Interessanterweise kommen Story Points im <a href="https://www.scrumguides.org/scrum-guide.html" target="_blank" rel="noopener noreferrer">Scrum Guide</a> ja nicht mehr vor. Der erwähnt zwar noch burn-down Diagramme für den "forecast" - auch der Begriff "estimation" ist aus dem Guide gestrichen -, doch was da heruntergebrannt wird, ist nicht benannt. Eine "velocity" findet ebenfalls keine Erwähnung mehr.</p>
<p>Damit hängen zumindest Scrum-Teams ein bisschen in der Luft, oder? Die Quelle der Wahrheit gibt keine Guidance.</p>
<p>Natürlich hält sich die Praxis der Story Point Schätzung hartnäckig und auch die Velocity steht in den meisten Scrum-Teams, die ich kenne, ganz oben auf der Beobachtungsliste. Konstante Geschwindigkeit ist das Ideal - auch wenn man inzwischen mit wissendem Blick betont, dass Geschwindigkeitsunterschiede normal seien.</p>
<h2>Komplexität kaschiert Aufwand</h2>
<p>Die Velocity ist die Zahl der Story Points, die pro Sprint umgesetzt wurden. Und Story Points stehen für eine Einschätzung der Komplexität einer umzusetzenden Anforderung, wie sie von den Entwickler eingeschätzt wird.</p>
<p>Eine vom Product Owner präsentierte Anforderungen wird diskutiert und dann wird in einem mehr oder weniger komplizierten Schätzverfahren eine Komplexität dafür bestimmt. Die Komplexität ist ganz bewusst keine Schätzung eines Umsetzungsaufwands oder einer Umsetzungsdauer. Agile Entwickler lassen sich zu einer Zeitschätzung nicht mehr herab; dass die daneben liegen muss, weiß doch jeder. Auf solche ein Spiel lassen sie sich nicht mehr ein.😤</p>
<p>Sie versprechen nur noch, dass sie eine bestimmte Menge an Anforderungsinkrementen mit einer bestimmten Komplexitätssumme in einer festgelegten Zeit umsetzen.😉</p>
<p>Auch wenn Story Points keine genaue Dauer für eine Umsetzung angeben, ist allen Beteiligten natürlich klar, dass die mit der Dauer positiv korrelieren. Mehr Story Points für eine Anforderung bedeuten längere Umsetzungsdauer. Ob 8 Story Points im Vergleich zu 5 Story Points nun genau 60% länger dauern oder nur 30% oder 100% oder mal so und mal so, das würde kein agiler Entwickler definieren wollen. Eine Komplexität von 8 ist eben nur höher als eine von 5. Und eine von 13 ist mehr höher im Vergleich zu 8 als 8 im Vergleich zu 5. Ich denke, darüber gibt es keinen Zweifel.</p>
<p>Alles andere würde auch keinen Sinn ergeben. Denn der PO will ja eine Idee bekommen, ob die Anforderung A in der Umsetzung wohl länger dauern wird als die Anforderung B. Denn wenn das so ist, könnte das für ihn ein Signal sein, A vorzuziehen - oder A zu verschieben.</p>
<p>Eine Komplexitätsschätzung ist also eine verbrämte Aufwandsschätzung. Und ein Diagramm, das Komplexitätswerte darstellt, stellt also Aufwände dar.</p>
<p>Was sagt dann ein Velocity Chart aus? Dass man in einer Periode eine Komplexität bewältigt, gar überwältigt und niedergerungen hat.💪Entwickler sind eben Helden! Jeden Tag schauen sie dem Komplexitätsmonster unerschüttert ins Auge!👹</p>
<p>Das klingt irgendwie gut - nur was bedeutet das wirklich? Hat das einen Wert? Wenn ja, für wen?</p>
<p>Wie gesagt: Sich die Komplexitätsfrage zu stellen, ist eine gute Sache. Um sie beantworten zu können, muss man mit dem Product Owner ins Gespräch kommen. Im Gespräch erkundet man die Anforderungen. Alle werden sich darüber klarer. Wo man große Komplexität erkennt, mit der große Unklarheit und Unverlässlichkeit in der Umsetzung einhergehen, kann man sich um Reduktion schon im Vorfeld bemühen.</p>
<p>Das ist alles super! Nur warum diese Werte tracken?</p>
<h2>It's the focus, stupid!</h2>
<p>Für mich ist nur eine Motivation plausibel: Indem man Story Points nicht nur schätzt, sondern auch verspricht, die niederzuringen in einem Zeitraum, setzt man sich ein Ziel. Dieses Ziel soll fokussieren. Dieses Ziel soll einen <em>sense of urgency</em> induzieren. Wer versucht ist, einer Ablenkung nachzugeben im Verlauf eines Sprints, der wird durch das Commitment auf eine zu erreichende Velocity zurück ins Glied geholt. Und je größer die zu bewältigenden Story Points, desto dringlicher ist der Fokus! Hohe Komplexität kommt mit großer Unklarheit; da zählt jede Minute im Sprint.</p>
<p>Am Ende einer Periode kann man dann schauen, inwiefern der Fokus geglückt ist. Wurde die angepeilte Gesamtkomplexität bewältigt? Wenn nein, wo hat es gehakt? Oder war sogar Luft nach oben?</p>
<p>Auf eine solche Retrospektive finde ich wunderbar. Man nimmt sich etwas vor und schaut am Ende, ob man es geschafft hat. Indem man sich etwas vornimmt, sich ein Ziel setzt, wird die Fokussierung befördert. Im Zweifelsfall weiß man immer, wo Aufmerksamkeit investiert werden sollte.</p>
<p>Warum aber die Story Points zur Fokussierung benutzen? Reicht es nicht, die auch aus den Story Points abgeleiteten Anforderungen zu tracken? Am Anfang einer Periode stehen 10 Anforderungen zur Diskussion. Die werden in der Komplexität geschätzt. Dadurch werden daraus 12 Anforderungen. Von diesen 12 Anforderungen nimmt man sich für die Periode 7 vor. Fertig.</p>
<p>Nachdem man sich für diese 7, das Sprint Backlog, entschieden hat, ist es doch egal, warum man das getan hat. Entweder man schafft alle 7 oder nicht. Am Ende der Periode kann man dann auf sein digitales Team-Kerbholz 7 oder auch nur 5 oder gar 8 Kerben machen und diese Anzahl einer Summe hinzufügen für eine kummulierende Darstellung.</p>
<p>Wenn man den Plan unter- oder übererfüllt, dann kann man gern darüber reflektieren und dabei auch die Komplexitätsschätzungen heranziehen. "Bei welcher Anforderung haben wir die Komplexität wieder zu niedrig eingeschätzt?" ist dabei wahrscheinlich die häufigste Frage.</p>
<p>Ein Tracking der Komplexitätssumme jedoch braucht es dafür nicht. Das ist nicht nur nicht hilfreich, das ist sogar missweisend.</p>
<h2>Fortschritt nur mit Wert</h2>
<p>Softwareentwicklung soll kundenorientiert sein. Wert soll für den Kunden geschaffen werden. Wo ist der in einer Komplexitätsschätzung zu finden? Welche Wertentwicklung hat eine Software, wenn die Velocity stets ähnlich ist?</p>
<p>Korreliert Wert mit Komplexität positiv? Höchstens schwach, würde ich sagen. So schwach, dass ein Diagramm, das die Entwicklung heldenhafter Komplexitätsbewältigung zeigt, nicht mit einer kundenorientierten Wertschaffung verwechselt werden darf.</p>
<blockquote>
<p>Wert ≠ Komplexität</p>
</blockquote>
<p>Was soll also ein Kunde davon halten, wenn ein Team in dieser Periode mehr und in der nächsten weniger und dann wieder etwas mehr Komplexität bewältigt?</p>
<p>Nichts!</p>
<p>Komplexität interessiert den Kunden nicht. Oder sie interessiert ihn nur indirekt, wenn er eine Antwort auf die Frage will: "Wann bekomme ich das Features, das mir sehr wertvoll erscheint?"</p>
<p>Entwickler geben darauf mit ihren Komplexitätsangaben keine Antwort, selbst wenn die mit Aufwand positiv korrelieren. Für eine so konkrete Prognose braucht es andere Mittel. Ich empfehle: <a href="https://ralfw.de/magically-predictable-software-production-for-projects/">Vorhersagen basierend auf historischen Daten.</a> Aber das ist ein anderes Thema.</p>
<p>Jeder Kunde kann unmittelbar den Fortschritt der Zeit spüren. Die kostet ihn nämlich gewöhnlich Geld auf die eine oder andere Weise, solange die Software noch zu wünschen übrig lässt:</p>
<ul>
<li>Entweder der Kunde gibt für die Softwareentwicklung Geld aus.</li>
<li>Und/oder der Kunde kann einen Wert der Software noch nicht realisieren, weil ihre Feature fehlen.</li>
</ul>
<h3>Wert entsteht im Auge des Kunden</h3>
<p>Nur der Kunde kann einer Software Wert beimessen. Ihr Produzent - Product Owner und Entwickler - können nur vermuten, was nach Auslieferung für den Kunden werthaltig sein könnte. Das ist sogar der Hauptantrieb hinter der Agilität! Dem Kunden soll möglichst zügig nach Äußerung einer Idee für eine werthaltige Veränderung eine Umsetzung präsentiert werden, um zu überprüfen, ob die Hypothese des Kunden - denn mehr ist es nicht - stimmig ist.</p>
<p>Das Entwicklungsteam vermutet, der Kunde vermutet ebenfalls. Softwareentwicklung ist eine komplexe Angelegenheit. Geradlinig ist der Weg zu einem werthaltigen Produkt nicht.</p>
<p>Und was ist Wert für den Kunden? Ich glaube, das lässt sich auf einen Begriff zusammendampfen:</p>
<blockquote>
<p>Nur <strong>Gewinnzuwachs</strong> stellt für den Kunden Wert dar.</p>
</blockquote>
<p>Wenn der Kunde heute 30.000€ pro Monat Gewinn ohne eine Software macht, dann möchte er morgen mit einer Software z.B. 15% mehr Gewinn machen, also 34.500€. Ob die Software hilft, den Umsatz zu erhöhen oder die Kosten zu reduzieren, ist dabei egal.</p>
<p>Hier ein Beispiel für eine solche Situation für eine Periode von 3 Jahren:</p>
<figure class="post__image"><img loading="lazy"  src="https://ralfw.de/media/posts/151/Bildschirmfoto-2021-01-30-um-16.13.54.png" sizes="(max-width: 48em) 100vw, 768px" srcset="https://ralfw.de/media/posts/151/responsive/Bildschirmfoto-2021-01-30-um-16.13.54-xs.png 300w ,https://ralfw.de/media/posts/151/responsive/Bildschirmfoto-2021-01-30-um-16.13.54-sm.png 480w ,https://ralfw.de/media/posts/151/responsive/Bildschirmfoto-2021-01-30-um-16.13.54-md.png 768w ,https://ralfw.de/media/posts/151/responsive/Bildschirmfoto-2021-01-30-um-16.13.54-lg.png 1024w ,https://ralfw.de/media/posts/151/responsive/Bildschirmfoto-2021-01-30-um-16.13.54-xl.png 1360w ,https://ralfw.de/media/posts/151/responsive/Bildschirmfoto-2021-01-30-um-16.13.54-2xl.png 1600w"  alt="Gewinnentwicklung ohne Software" width="312" height="655"></figure>
<p>Ausgehend von einer solchen Vorstellung von Gewinnzuwachs durch eine Software, ist der Kunde bereit, erstens Geld für die Software auszugeben und zweitens auf die Softwarelieferung zu warten.</p>
<p>Er könnte Beispielsweise bereit sein, 270.000€ für eine Software auszugeben. Diesen Preis würde ein Gewinnzuwachs nach 60 Monaten (5 Jahren) wieder einspielen. Danach würde der Gewinn wirklich realisiert.</p>
<p>Ob das eine zu lange Wartezeit ist, sei dahingestellt. Es geht mir um die prinzipielle Rechnung.</p>
<p>Wenn die Softwareentwicklung im Wasserfall über 18 Monate stattfinden würde, sähe die Gewinnentwicklung so aus ab Auftragsvergabe:</p>
<figure class="post__image"><img loading="lazy"  src="https://ralfw.de/media/posts/151/Bildschirmfoto-2021-01-30-um-16.29.56.png" sizes="(max-width: 48em) 100vw, 768px" srcset="https://ralfw.de/media/posts/151/responsive/Bildschirmfoto-2021-01-30-um-16.29.56-xs.png 300w ,https://ralfw.de/media/posts/151/responsive/Bildschirmfoto-2021-01-30-um-16.29.56-sm.png 480w ,https://ralfw.de/media/posts/151/responsive/Bildschirmfoto-2021-01-30-um-16.29.56-md.png 768w ,https://ralfw.de/media/posts/151/responsive/Bildschirmfoto-2021-01-30-um-16.29.56-lg.png 1024w ,https://ralfw.de/media/posts/151/responsive/Bildschirmfoto-2021-01-30-um-16.29.56-xl.png 1360w ,https://ralfw.de/media/posts/151/responsive/Bildschirmfoto-2021-01-30-um-16.29.56-2xl.png 1600w"  alt="Entwicklung der Software im Wasserfall. Gewinnzuwachs tritt erst nach vollständiger Auslieferung ein." width="490" height="688"></figure>
<p>Zuerst hat der Kunde 18 Monate lang Kosten von 15.000€ pro Monat zu tragen; 50% seines monatlichen Gewinns investiert er für den späteren Gewinnzuwachs.</p>
<p>Nach Auslieferung der Software fallen die Entwicklungskosten weg und jeden Monat liegt der Gewinn um 15% höher als ohne Software. Der Kunde hat sein Ziel erreicht! (Dass es nie so einfach ist, ist mir klar. Prinzipiell sollte es aber so funktionieren.)</p>
<p>Alle umgesetzten Anforderungen zusammen haben für den Kunden einen Wert von 4.500€ pro Monat.</p>
<p>Dieser Wert ist für den Kunden interessant. Nichts sonst. Wer ihm diesen Wert schneller liefert, ist für ihn attraktiver als Entwicklungspartner.</p>
<p>Natürlich hat der Kunde die Befürchtung, dass sich die Lieferung solch wertvoller Software verzögern könnte. Er will deshalb über den Fortschritt der Entwicklung informiert werden. Wie kann das geschehen? Was kann ihm ein Softwareteam als Metrik nennen, die für den Kunden relevant ist?</p>
<p>Solange der Kunde nichts in die Hand bekommt, solange führ ihn kein Wert entsteht, sind alle Metriken abstrakt. Er lässt sich notgedrungen auf sie ein. "Wir haben schon 25% der Anforderungen umgesetzt!" klingt gut - ist aber auch untauglich, solange der Kunde davon nichts hat. "Wir sind schon mit der Anbindung des Buchhaltungssystems fertig!" ist auch nicht hilfreich, solange der Kunde davon nichts hat. "Wir haben schon Meilenstein 1 mit den Anforderungen A und B und C erreicht!" fällt letztlich auch in die Kategorie "heiße Luft", solange der Kunde nichts davon hat.</p>
<p>Mit "davon haben" meine ich, dass die Software bei ihm im Einsatz ist und schon Gewinnzuwachs produziert. Nur dann ist für den Kunden Wert hergestellt.</p>
<p><a href="https://agilemanifesto.org/iso/de/principles.html" target="_blank" rel="noopener noreferrer">Das hat die Agilität erkannt und bemüht sich genau darum:</a></p>
<blockquote>
<p>Unsere höchste Priorität ist es, den Kunden durch frühe und kontinuierliche Auslieferung wertvoller Software zufrieden zu stellen.</p>
</blockquote>
<p>Das Ideal agiler Softwareentwicklung sieht dann so aus:</p>
<figure class="post__image"><img loading="lazy"  src="https://ralfw.de/media/posts/151/Bildschirmfoto-2021-01-30-um-16.40.06.png" sizes="(max-width: 48em) 100vw, 768px" srcset="https://ralfw.de/media/posts/151/responsive/Bildschirmfoto-2021-01-30-um-16.40.06-xs.png 300w ,https://ralfw.de/media/posts/151/responsive/Bildschirmfoto-2021-01-30-um-16.40.06-sm.png 480w ,https://ralfw.de/media/posts/151/responsive/Bildschirmfoto-2021-01-30-um-16.40.06-md.png 768w ,https://ralfw.de/media/posts/151/responsive/Bildschirmfoto-2021-01-30-um-16.40.06-lg.png 1024w ,https://ralfw.de/media/posts/151/responsive/Bildschirmfoto-2021-01-30-um-16.40.06-xl.png 1360w ,https://ralfw.de/media/posts/151/responsive/Bildschirmfoto-2021-01-30-um-16.40.06-2xl.png 1600w"  alt="Agile Softwareentwicklung liefert früher und mehr Wert." width="1184" height="1186"></figure>
<p>Nicht erst nach der geplanten Projektlaufzeit von 18 Monaten wird etwas wertvolles geliefert, sondern ständig. Im Beispiel gibt es jeden Monat ein Release, das die Software ein bisschen werthaltiger macht.</p>
<ul>
<li>Ab dem 3. Monat kann der Kunde schon kleine und dann wachsende Gewinnzuwächse realisieren.</li>
<li>Am Ende ist der erwünschte Gewinnzuwachs sogar übertroffen. Das ist möglich, weil der Kunde durch frühzeitigen Einsatz Erkenntnisse gewinnen konnte, wie die Software für ihn noch wertvoller gestaltet werden könnte.</li>
</ul>
<p>Der Wertzuwachs ist natürlich nicht linear. Am Anfang fehlt es noch an Voraussetzungen für große "Wertsprünge", dann können die gemacht werden - und nach etwas mehr als der halben Projektlaufzeit sind ca. 80% des späteren Gesamtwertes erreicht.</p>
<figure class="post__image"><img loading="lazy"  src="https://ralfw.de/media/posts/151/Bildschirmfoto-2021-01-30-um-16.50.27.png" sizes="(max-width: 48em) 100vw, 768px" srcset="https://ralfw.de/media/posts/151/responsive/Bildschirmfoto-2021-01-30-um-16.50.27-xs.png 300w ,https://ralfw.de/media/posts/151/responsive/Bildschirmfoto-2021-01-30-um-16.50.27-sm.png 480w ,https://ralfw.de/media/posts/151/responsive/Bildschirmfoto-2021-01-30-um-16.50.27-md.png 768w ,https://ralfw.de/media/posts/151/responsive/Bildschirmfoto-2021-01-30-um-16.50.27-lg.png 1024w ,https://ralfw.de/media/posts/151/responsive/Bildschirmfoto-2021-01-30-um-16.50.27-xl.png 1360w ,https://ralfw.de/media/posts/151/responsive/Bildschirmfoto-2021-01-30-um-16.50.27-2xl.png 1600w"  alt="Nicht linearer Anstieg des Wertes bei inkrementeller Lieferung." width="575" height="363"></figure>
<p><em>Das</em> ist, was den Kunden interessiert. Er will sehen, wie sich seine Ausgaben in Wert verwandeln. Wie viel mehr Gewinn lässt ihn die Software schon realisieren? Wenn die Kurve "Wert kummuliert" kontinuierlich steigt, wenn sie sogar steil steigt, dann ist der Kunde glücklich.</p>
<blockquote>
<p>Fortschritt gibt es für den Kunden nur, wenn Software für ihn werthaltiger geworden ist.</p>
</blockquote>
<p>Flacht die Kurve ab oder wächst der Wert gar nicht oder - auch das ist möglich - sinkt er sogar, dann ist der Kunde unglücklich.</p>
<p>Wenn die Agilität also kundenorientiert sein will, dann sollte sie sich doch daran messen, ob sie Wert für den Kunden produziert. Oder? Alles andere ist irrelevant.</p>
<p>Und wenn der Product Owner einen Anlass für das Gespräch mit Entwicklern sucht, dann kann er die Wertentwicklung heranziehen. Gemeinsam lässt sich darüber reflektieren, warum Wert gesunken ist - das wäre eine Regression - oder warum die Kurve nur so schwach steigt. Warum dauert es so lange, bis wieder etwas an den Kunden geliefert wird, das der als wertvoll erachtet?</p>
<h2>Fazit</h2>
<p>Scrum ist von den Ideen der Lean Production inspiriert. Und die ist darauf aus, flüssige, konfliktfreie Produktion herzustellen. Was ist es also, das in einem agilen oder gar Scrum-Prozess hergestellt werden soll?</p>
<p>Das kann nur Wert sein. Etwas anderes kann "valuable software" nicht meinen. Und Wert entsteht nur und ausschließlich im Auge des Kunden. Konkret ist das ein Zuwachs an Gewinn auf die eine oder andere Weise. Je früher er den realisiert, desto besser.</p>
<p>Agile Softwareentwicklung, die nicht den Fokus auf die Entwicklung von Wert legt und deshalb die Wertproduktion protokolliert, geht am Kern der Agilität vorbei. Wert ist wichtiger als Komplexität. Deshalb im Stile des agilen Manifests:</p>
<blockquote>
<p>Wert mehr als Komplexität</p>
</blockquote>
<p>Komplexitätseinschätzung hat ihren Platz in der Softwareentwicklung; mehr verdient es jedoch der Wert, dass sie sich daran ausrichtet.</p>
<p>Dass für die Lieferung von Wert Komplexität bewältigt werden muss, ist unbenommen. Einen Orden verdient jedoch nicht der, der Komplexität wie versprochen in einer Periode niederringt, sondern der, der einen bestimmten Wert zuverlässig liefert.</p>
<p>Dass es nicht einfach ist, den Wert von Software als Ganzes oder eines Inkrements zu bestimmen, steht auf einem anderen Blatt. Es bleibt die Aufgabe der Softwareentwicklung, die Wertproduktion zu optimieren. Dafür muss sie sich halt anstrengen, Wert greifbar zu machen. Das halte ich für eine wirklich lohnende Mühe.</p>
<p>Als Kunde würde ich jedenfalls lieber mit einem Softwareteam arbeiten, das mir ein Diagramm der Entwicklung des angepeilten Wertes meiner Software zeigt, als eines, auf dem eine obskure Komplexität getrackt wird.</p>
<hr>
<h4>P.S. Nicht realisierter Wert durch nicht-inkrementelle Entwicklung</h4>
<p>Der Nachteil einer verzögerten Auslieferung von Wert lässt sich übrigens auch an den Beispieldaten ablesen. Ein nicht-inkrementelles Vorgehen wie im Wasserfall ist dafür ein extremes Beispiel. Doch auch bei bemüht agilem Vorgehen kann es immer wieder dazu kommen, das etwas eigentlich für den Kunden Werthaltiges (noch) nicht übergeben wird.</p>
<p>Die Summe des markierten Bereichs ist 46.150€. Dieser Gewinnzuwachs konnte bei agiler Entwicklung schon "unterwegs" bis Projektende vom Kunden realisiert werden:</p>
<figure class="post__image"><img loading="lazy"  src="https://ralfw.de/media/posts/151/2021-01-30_17-16-00.png" sizes="(max-width: 48em) 100vw, 768px" srcset="https://ralfw.de/media/posts/151/responsive/2021-01-30_17-16-00-xs.png 300w ,https://ralfw.de/media/posts/151/responsive/2021-01-30_17-16-00-sm.png 480w ,https://ralfw.de/media/posts/151/responsive/2021-01-30_17-16-00-md.png 768w ,https://ralfw.de/media/posts/151/responsive/2021-01-30_17-16-00-lg.png 1024w ,https://ralfw.de/media/posts/151/responsive/2021-01-30_17-16-00-xl.png 1360w ,https://ralfw.de/media/posts/151/responsive/2021-01-30_17-16-00-2xl.png 1600w"  alt="Agiles Vorgehen reduziert cost of delay." width="425" height="411"></figure>
<p>Das Vorgehen nach Wasserfall verwehrt dem Kunden diesen Gewinnzuwachs. Es lässt ihn auf die Software warten. Die 46.150€ stellen deshalb <em>cost of delay (CoD)</em> dar, die durch eine <em>big bang</em> Auslieferung entstehen.</p>
<p>Der zentrale Wertmaßstab für die agile Softwareentwicklung ist daher CoD. Alles Bestreben agilen Vorgehens sollte auf die Minimierung von CoD gerichtet sein.</p>
            ]]>
        </content>
    </entry>
    <entry>
        <title>Event Sourcing Challenge: Bowling Game Kata</title>
        <author>
            <name>Ralf Westphal</name>
        </author>
        <link href="https://ralfw.de/event-sourcing-challenge-bowling-game-kata/"/>
        <id>https://ralfw.de/event-sourcing-challenge-bowling-game-kata/</id>
            <category term="Event-Orientation"/>

        <updated>2021-01-27T23:40:14+08:00</updated>
            <summary>
                <![CDATA[
                        <img src="https://ralfw.de/media/posts/138/DraggedImage-3.png" alt="" />
                    Event Sourcing ist für mich die Zukunft der grundsätzlichen Zustandshaltung in Software. Alles andere ist eine Optimierung, die man nicht leichtfertig und schon gar nicht vorzeitig vornehmen sollte. Mit Event Sourcing verdrängt endlich Konstruktivismus den bisherigen Materialismus des immer noch dominierenden RDBMS/OO-Denkens.1 Und ich halte&hellip;
                ]]>
            </summary>
        <content type="html">
            <![CDATA[
                    <img src="https://ralfw.de/media/posts/138/DraggedImage-3.png" alt="" />
                <p><!-- wp:paragraph --></p>
<p>Event Sourcing ist für mich die Zukunft der grundsätzlichen Zustandshaltung in Software. Alles andere ist eine Optimierung, die man nicht leichtfertig und schon gar nicht vorzeitig vornehmen sollte.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Mit Event Sourcing verdrängt endlich <a href="#INTERNAL_LINK#/post/NaN">Konstruktivismus</a> den bisherigen Materialismus des immer noch dominierenden RDBMS/OO-Denkens.<sup><a id="ffn1" class="footnote" href="#fn1">1</a></sup> Und ich halte Event Sourcing für die Grundlage von Antifragilität in der Softwareentwicklung.<sup><a id="ffn2" class="footnote" href="#fn2">2</a></sup></p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Ich finde Event Sourcing also sehr spannend und wichtig – nur leicht ist es nicht. Denn auch wenn Event Sourcing auf das eine Datenmodell, die eine große Datenstruktur verzichtet, bedeutet das nicht, dass man sich keine Gedanken um Datenmodelle machen muss.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Damit meine ich nicht die vielen situationsspezifischen Strukturen, die nun sehr einfach möglich werden. Für jede Interaktion mit einer Software kann es nun ein daraufhin optimiertes Datenmodell geben.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Ich meine die Events, die beim Event Sourcing in einem stetig wachsenden Strom gespeichert werden und den sich entwickelnden Systemzustand repräsentieren. Statt des einen großen Datenmodells gibt es im Event Sourcing ein Granulat bestehend aus kleinen und kleinsten Datenstrukturen, den Events.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Das ist für das RDBMS- oder auch Dokumenten-gewohnte Denken eine Umstellung. Während man bisher versuchen konnte, „die Struktur der Welt“ zu erkennen und möglichst realitätsgetreu in Software abzubilden, geht es jetzt um ihre Entfaltung über die Zeit. Es geht nicht mehr um statische Resultate von letztlich irrelevanten Ereignissen, sondern um höchst relevante Ereignisse, aus denen alle möglichen Resultate in Zukunft abgeleitet werden können.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Die Welt der Zustandshaltung steht damit Kopf, würde ich sagen.🙃😁</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Gedanken muss man sich also beim Event Sourcing um die Events machen. Klingt auch ohne große Einleitungsworte plausible, oder?😉</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Wie findet man aber „die besten“ Events? Was sind überhaupt „gute“ Events? Das sind Fragen, die mich deshalb bewegen. Ich suche Prinzipien und Heuristiken, um für gegebenen Anforderungen mindestens „ziemlich gute“ Events zu finden.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:heading {"level":2} --></p>
<h2>Die Challenge</h2>
<p><!-- /wp:heading --></p>
<p><!-- wp:paragraph --></p>
<p>Deshalb habe ich im Domain Driven Design Slack-Workspace „DDD Germany“ mal nachgefragt, wie man dort die Sache sieht. Getan habe ich das mit einer kleinen Aufgabe, die mir einerseits sehr überschaubar scheint, andererseits aber doch ein bisschen Herausforderung bietet.<sup><a id="ffn3" class="footnote" href="#fn3">3</a></sup></p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p><a href="https://paper.dropbox.com/doc/EventSourcing-Challenge-Die-Bowling-Game-Kata--AqiYiJ05NEjMjfC6iUSFxU2lAg-MrmZs8ODudTrrlrvSi5i0" target="_blank" rel="noopener">Als Aufgabe</a> habe ich die aus Coding Dojos bekannte Bowling Game Kata gewählt:</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:image {"id":2773, "align": "center"} --></p>
<div class="wp-block-image">
<figure class="aligncenter"><figure class="alignnone wp-image-2773"><img loading="lazy"  src="https://ralfw.de/media/posts/138/DraggedImage.png" sizes="(max-width: 48em) 100vw, 768px" srcset="https://ralfw.de/media/posts/138/responsive/DraggedImage-xs.png 300w ,https://ralfw.de/media/posts/138/responsive/DraggedImage-sm.png 480w ,https://ralfw.de/media/posts/138/responsive/DraggedImage-md.png 768w ,https://ralfw.de/media/posts/138/responsive/DraggedImage-lg.png 1024w ,https://ralfw.de/media/posts/138/responsive/DraggedImage-xl.png 1360w ,https://ralfw.de/media/posts/138/responsive/DraggedImage-2xl.png 1600w"  alt="" width="548" height="1244"></figure></figure>
</div>
<p><!-- /wp:image --></p>
<p><!-- wp:paragraph --></p>
<p>Es soll ein „Ergebniszähler“ realisiert werden, der die Punktzahl eines Bowling-Spiels bestimmt. Dieser Zähler reagiert auf zwei CQS-Nachrichten: dass ein Wurf registriert und dass das Ergebnis geliefert werden soll. Mehr nicht.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Es gibt also zwei glasklare Interaktionen der Umwelt mit einer Zähler-Software. Darüber muss nicht spekuliert werden. Die einzige Frage, die die Aufgabe stellt, ist die nach den Events.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Die Interaktionen basieren auf gemeinsamem Zustand. Dieser Zustand soll mit Event Sourcing realisiert gedacht werden, d.h. als Strom von Events. Welche Events sollten das sein?</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Mehr ist nicht zu liefern, nur die Events. Die Lösung soll gerade nicht komplett implementiert werden, weil es mir ja darum geht, wie Events <em>a priori</em> gefunden werden können.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Event Storming - nomen es omen - ist eine Technik, die dafür zum Einsatz kommen könnte; allerdings sehe ich sie vor allem bei Szenarien, die deutlich größer sind und/oder bei denen es viele Sichtweisen zu berücksichtigen gilt.<sup><a id="ffn4" class="footnote" href="#fn4">4</a></sup></p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Dass man nach Implementation und Betrieb einer Lösung immer schlauer ist und also vielleicht auch eine noch bessere Idee hat, welche Events nützlich wären, scheint mir ausgemacht. Wie bei RDBMS oder umfänglichen Objektmodellen ist eine Änderung der Datenbasis dann jedoch schwierig. Und Event Sourcing verspricht ja, dass man gerade das nicht tun muss/soll.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Events versionieren, weitere Events später nachschieben, einen Eventstrom komplett umschreiben: das kann man alles machen und es mag zuzeiten nötig sein. Doch so, wie es einige Kriterien für RDBMS-Schemata gibt, um nicht gleich mit dem falschen Fuß aufzustehen, so gibt es ja vielleicht auch Kriterien für das Schneiden von Events, um den Zeitpunkt hinauszuzögern, da man sich in eine Ecke gepinselt hat. Was meint die DDD-Community dazu?</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:heading {"level":2} --></p>
<h2>Die Lösungen</h2>
<p><!-- /wp:heading --></p>
<p><!-- wp:paragraph --></p>
<p>Ich hatte zuerst für mich selbst die Aufgabe gelöst (und natürlich doch nicht darauf verzichtet, den kompletten Code dafür zu schreiben🤪). Ohne meine Events zu verraten, habe ich dann die Aufgabe der Community vorgelegt und weitere vier Lösungen bekommen.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Ich liste sie einfach mal mit den Slack-Benutzernamen ihrer Einreicher in alphabetischer Reihenfolge:</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:image {"id":2772, "align": "center"} --></p>
<div class="wp-block-image">
<figure class="aligncenter"><figure class="wp-image-2772"><img loading="lazy"  src="https://ralfw.de/media/posts/138/DraggedImage-1.png" sizes="(max-width: 48em) 100vw, 768px" srcset="https://ralfw.de/media/posts/138/responsive/DraggedImage-1-xs.png 300w ,https://ralfw.de/media/posts/138/responsive/DraggedImage-1-sm.png 480w ,https://ralfw.de/media/posts/138/responsive/DraggedImage-1-md.png 768w ,https://ralfw.de/media/posts/138/responsive/DraggedImage-1-lg.png 1024w ,https://ralfw.de/media/posts/138/responsive/DraggedImage-1-xl.png 1360w ,https://ralfw.de/media/posts/138/responsive/DraggedImage-1-2xl.png 1600w"  alt="Lösung von @akii" width="241" height="79"></figure>
<figcaption>Lösung von @akii</figcaption>
</figure>
</div>
<p><!-- /wp:image --></p>
<p><!-- wp:image {"id":2774, "align": "center"} --></p>
<div class="wp-block-image">
<figure class="aligncenter"><figure class="wp-image-2774"><img loading="lazy"  src="https://ralfw.de/media/posts/138/DraggedImage-2.png" sizes="(max-width: 48em) 100vw, 768px" srcset="https://ralfw.de/media/posts/138/responsive/DraggedImage-2-xs.png 300w ,https://ralfw.de/media/posts/138/responsive/DraggedImage-2-sm.png 480w ,https://ralfw.de/media/posts/138/responsive/DraggedImage-2-md.png 768w ,https://ralfw.de/media/posts/138/responsive/DraggedImage-2-lg.png 1024w ,https://ralfw.de/media/posts/138/responsive/DraggedImage-2-xl.png 1360w ,https://ralfw.de/media/posts/138/responsive/DraggedImage-2-2xl.png 1600w"  alt="Lösung von @bwaidelich" width="273" height="77"></figure>
<figcaption>Lösung von @bwaidelich</figcaption>
</figure>
</div>
<p><!-- /wp:image --></p>
<p><!-- wp:image {"id":2769, "align": "center"} --></p>
<div class="wp-block-image">
<figure class="aligncenter"><figure class="wp-image-2769"><img loading="lazy"  src="https://ralfw.de/media/posts/138/DraggedImage-3.png" sizes="(max-width: 48em) 100vw, 768px" srcset="https://ralfw.de/media/posts/138/responsive/DraggedImage-3-xs.png 300w ,https://ralfw.de/media/posts/138/responsive/DraggedImage-3-sm.png 480w ,https://ralfw.de/media/posts/138/responsive/DraggedImage-3-md.png 768w ,https://ralfw.de/media/posts/138/responsive/DraggedImage-3-lg.png 1024w ,https://ralfw.de/media/posts/138/responsive/DraggedImage-3-xl.png 1360w ,https://ralfw.de/media/posts/138/responsive/DraggedImage-3-2xl.png 1600w"  alt="Lösung von @phj" width="405" height="338"></figure>
<figcaption>Lösung von @phj</figcaption>
</figure>
</div>
<p><!-- /wp:image --></p>
<p><!-- wp:image {"id":2770, "align": "center"} --></p>
<div class="wp-block-image">
<figure class="aligncenter"><figure class="wp-image-2770"><img loading="lazy"  src="https://ralfw.de/media/posts/138/DraggedImage-4.png" sizes="(max-width: 48em) 100vw, 768px" srcset="https://ralfw.de/media/posts/138/responsive/DraggedImage-4-xs.png 300w ,https://ralfw.de/media/posts/138/responsive/DraggedImage-4-sm.png 480w ,https://ralfw.de/media/posts/138/responsive/DraggedImage-4-md.png 768w ,https://ralfw.de/media/posts/138/responsive/DraggedImage-4-lg.png 1024w ,https://ralfw.de/media/posts/138/responsive/DraggedImage-4-xl.png 1360w ,https://ralfw.de/media/posts/138/responsive/DraggedImage-4-2xl.png 1600w"  alt="Meine eigene Lösung (@ralfw)" width="443" height="396"></figure>
<figcaption>Meine eigene Lösung (@ralfw)</figcaption>
</figure>
</div>
<p><!-- /wp:image --></p>
<p><!-- wp:image {"id":2771, "align": "center"} --></p>
<div class="wp-block-image">
<figure class="aligncenter"><figure class="wp-image-2771"><img loading="lazy"  src="https://ralfw.de/media/posts/138/DraggedImage-5.png" sizes="(max-width: 48em) 100vw, 768px" srcset="https://ralfw.de/media/posts/138/responsive/DraggedImage-5-xs.png 300w ,https://ralfw.de/media/posts/138/responsive/DraggedImage-5-sm.png 480w ,https://ralfw.de/media/posts/138/responsive/DraggedImage-5-md.png 768w ,https://ralfw.de/media/posts/138/responsive/DraggedImage-5-lg.png 1024w ,https://ralfw.de/media/posts/138/responsive/DraggedImage-5-xl.png 1360w ,https://ralfw.de/media/posts/138/responsive/DraggedImage-5-2xl.png 1600w"  alt="Lösung von @sebastian" width="231" height="211"></figure>
<figcaption>Lösung von @sebastian</figcaption>
</figure>
</div>
<p><!-- /wp:image --></p>
<p><!-- wp:paragraph --></p>
<p>Die Lösungen wurden in Pseudocode, Typescript, C#, F# eingereicht. Ich habe sie zur besseren Vergleichbarkeit alle nach C# übersetzt. Ein bisschen ging dabei die Ausdrucksfähigkeit von F# (@phj) verloren, aber das finde ich nicht schlimm.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Außerdem habe ich sie insofern vereinheitlicht, als dass ich eine Game ID, die in manchen Lösungen in den Events stand, gelöscht habe. Ich denke, sie trägt in Bezug auf diese Aufgabe nichts zur Erkenntnis von Prinzipien und Heuristiken bei und betrifft einen orthogonalen Belang.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:heading {"level":3} --></p>
<h3>Lösungsebenen</h3>
<p><!-- /wp:heading --></p>
<p><!-- wp:paragraph --></p>
<p>Die Aufgabe war nicht groß. Die Lösungsvorschläge sollten also nicht so weit auseinander liegen. So hatte ich es mir gedacht - und war dann doch überrascht, dass selbst hier eine Lösungsvielfalt entstanden ist.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Ich sehe die Lösungen auf drei Ebenen:</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:list {"ordered":true} --></p>
<ol>
<li>Minimallösung (@akii, @bwaidelich): Es wird nur ein Event benötigt, der die über das Kommando gemeldeten geworfenen Pins aufzeichnet.</li>
<li>Aufzeichnung von Bonuspunkten (@sebastian): Zusätzlich zum Event der Minimallösung wird aufgezeichnet, dass ein Wurf als Bonus für einen vorhergehenden anerkannt wurde.</li>
<li>Aufzeichnung von Frames und Bonuswürdigkeit (@phj, @ralfw): Zusätzlich zu den Events der zweiten Ebene wird aufgezeichnet, falls ein Wurf einen Frame beendet hat und ob der Frame bonuswürdig ist (Spare oder Strike).</li>
</ol>
<p><!-- /wp:list --></p>
<p><!-- wp:heading {"level":3} --></p>
<h3>Analyse</h3>
<p><!-- /wp:heading --></p>
<p><!-- wp:paragraph --></p>
<p>Die Idee hinter der Aufgabe war, dass ein Event Store befüllt wird mit Events im Rahmen der Verarbeitung des einen Kommandos - und dass die Events während der einen Query zu einem Gesamtergebnis verarbeitet werden.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Die Logik zur Herstellung des Verhaltens würde sich in einer Implementation also auf einen Command- und einen Query-Handler verteilen. Die Wahl der Events hat darauf einen großen Einfluss.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Die Minimallösungen zeichnen im Grunde nur die mit dem Kommando gemeldeten Pins eines Wurfes 1:1 auf. Das ist trivial, so dass die ganze Last der Ergebnisberechnung bei der Query-Verarbeitung liegt. Die Minimallösungen betreiben mithin eigentlich kein Event Sourcing, sondern eher ein Command Sourcing.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Die Bonuspunktlösung verschiebt die Last zum Command-Handling. Bei der Query-Verarbeitung müssen nur die Pins aus den Events für die Würfe und die Bonuspunkte addiert werden. Das ist trivial - dafür muss die Kommando-Verarbeitung allerdings vorher entschieden haben, wann ein Bonuspunkt-Event aufzuzeichnen ist.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Die Frame-/Bonuswürdigkeit-Lösungen vereinfachen die Logik der Query-Verarbeitung nicht weiter; die bleibt trivial. Die zusätzlichen Events wirken sich vielmehr auf das Command-Handling differenzierend aus. Vielleicht wächst die Logik dort noch ein wenig, vor allem scheint es mir aber einfacher, in der Kommando-Verarbeitung Verantwortlichkeiten zu trennen: festzustellen, ob/ab wann ein Bonus gewährt wird, und einen Bonus zuzuweisen, sind eben zwei verschiedene Aufgaben.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Interessant finde ich, dass keine Lösung einen Event zur Anzeige eines Spielendes definiert.<sup><a id="ffn5" class="footnote" href="#fn5">5</a></sup> Ist das kein Aufzeichnungswürdiges Ereignis? Oder war die Aufgabe so formuliert, dass alle angenommen haben, dass am Spielende der Eventstrom verschwindet? Dagegen spricht, dass einige Lösungen auch die Aufzeichnung einer Game ID vorgeschlagen haben. Da wurde augenscheinlich größer gedacht.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Oder war die Aufgabe unterspezifiziert insofern, als dass nicht angegeben war, was passieren soll, wenn ein Wurf über die maximale Wurfzahl eines Spiels hinaus gemeldet wird? Damit war sozusagen das Spielende kein Thema in der Aufgabenbeschreibung? Hm…🤔</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:heading {"level":3} --></p>
<h3>Diskussion</h3>
<p><!-- /wp:heading --></p>
<p><!-- wp:paragraph --></p>
<p>Was tun mit einem Spektrum an Lösungen? Sind sie alle gleichwertig, gleich gut? Welches Für und Wider gibt es? Genau um diese Erkenntnis ging es mir ja, als ich die Aufgabe gestellt habe.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Augenfällig ist zunächst der Unterschied zwischen den Minimallösungen und den anderen in der Verortung der Logik. Die Minimallösungen brauchen gewiss viel Logik während des Query-Handlings - wie viel sie im Command-Handling tun, ist eine Frage des Anspruchs an Validation/Konsistenzprüfung. Im einfachsten Fall ist dort im Grunde gar keine Logik nötig.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Das Argument der Vertreter dieses Ansatzes ist sehr simpel: „Ein Event reicht.“ Und das ist wahr. Aufzuzeichnen, dass ein Wurf gemacht wurde bedeutet, ein reales Ereignis in der Umwelt aufzuzeichnen. Das wird über ein Kommando gemeldet und ist die einzige Anweisung zur Zustandsänderung. Wenn man sich das merkt, kann der Rest jederzeit daraus abgeleitet werden.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Wenn es so einfach funktioniert, warum sind dann aber 60% der Einreicher auf weitere Events gekommen? Ich denke, das liegt an der Abhängigkeit, die mit der Minimallösung einhergeht: Ein bei der Query nach außen gemeldeter Zustand ist vollständig abhängig von Logik. Ändern sich z.B. die Regeln, können die Ergebnisse alter Spiele u.U. nicht mehr nachvollzogen werden.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Das mag ok sein, wenn eine solche Änderung nicht zu erwarten ist, weil die Domäne sehr stabil ist. Oder es mag ok sein für ein so kleines Beispiel mit angenommener Kurzlebigkeit. Für „richtige“ Software jedoch scheint mir da eine Gefahr fehlender Reproduzierbarkeit zu liegen.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Event Sourcing Lösungen sind mehr von Logik abhängig als Lösungen, die Zustand in einem dauerhaften Modell aktuell halten, weil ständig Projektionen von Events auf temporäre, grundsätzlich flüchtige Modelle stattfinden. Deshalb würde ich mich nicht auf nur den einen minimal notwendigen Event verlassen wollen.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Wie viele Events mehr sollen es dann aber sein?</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Events repräsentieren Weggabelungen in der Entwicklung der Welt. Wenn etwas passiert, dann kollabiert ein Möglichkeitsraum; ein Weg ist eingeschlagen worden. Vor dem ersten Wurf ist es noch möglich, dass nach dem Wurf 10, 9, …, 1, 0 Pins abgeräumt sein werden; nach dem Wurf ist klar, dass genau z.B. 4 Pins abgeräumt wurden.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Dasselbe ist der Fall bei Entscheidungen: Sie lassen einen Möglichkeitsraum zusammenschnurren auf genau eine Möglichkeit, nämlich die, für die sich entschieden wurde. Vor einer Entscheidung ist es noch möglich, dass z.B. beim Sturz eines Fußballspielers nach Zusammenstoß mit einem anderen ein Fowl gepfiffen wird oder nicht. Der Schiedsrichter kann sich für oder gegen Fowl entscheiden und er kann sich sogar für ein Fowl mit oder ohne Vorteil entscheiden (wenn ich es recht erinnere). Mit der Entscheidung des Schiedsrichters erst schnurrt der Möglichkeitsraum zusammen auf genau ein Urteil; was passiert ist, ist dann ganz klar z.B. ein Fowl gewesen.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Entscheidungen lassen nichts direkt passieren. Vielmehr deuten sie etwas, das passiert ist - und lassen als Ergebnis wieder etwas passieren. Ein Urteil, eine Entscheidung ist ebenfalls ein Ereignis. Mit jeder Entscheidung verändert sich der Weg eines Systems, d.h. sein Zustand. Wer sich nach links wendet, ist in einem anderen Zustand, als hätte er sich nach rechts gewendet.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Die Aufzeichnung des per Kommando gemeldeten Pins betrifft also quasi ein Ereignis 1. Ordnung, ein unmittelbares Ereignis. Das Programm „erleidet“ dieses Ereignis, es kann nichts dafür.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Die Einreicher von Lösungen oberhalb der Minimallösung haben sich nun überlegt, dass es hilfreich wäre, weitere Ereignisse aufzuzeichnen. Die nenne ich mal Ereignisse 2. und höherer Ordnung. Sie repräsentieren Entscheidungen der Spiellogik.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Bei @sebastian wird nur festgehalten, dass die Logik im Command-Handling erkannt hat, dass ein Wurf als Bonus für einen vorhergehenden Frame zu zählen ist. Das reicht aus, um die Query-Logik drastisch zu vereinfachen.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Die Angriffsfläche von Regeländerungen auf die Berechnung eines Spielergebnisses ist damit deutlich kleiner geworden, würde ich sagen. Es muss zwar immer noch summiert werden, doch das liegt auf der Hand, würde ich sagen. Nur ein Spielende-Ereignis, in dem man das Ergebnis festschreibt, würde noch mehr Robustheit gegenüber Regeländerungen versprechen.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Und was ist mit den darüber hinaus gehenden Events der Lösungen von @phj und @ralfw? Sie dokumentieren auch Entscheidungen; oder ich könnte es auch Erkenntnisse nennen. Die Logik entscheidet, dass mit einem Wurf ein Frame abgeschlossen wurde. Die Logik erkennt den Abschluss eines Frame.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Warum diese Entscheidungen auch noch aufzeichnen? Die Ergebnisberechnung profitiert davon nicht mehr. Vielleicht wird es mit diesen Events aber einfacher, einen Bonuswurf zu erkennen? Das könnte sein. Dann wären es „funktionale“ Events.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Oder dienen sie nur der Dokumentation von Entscheidungen, damit die dauerhaft nachvollziehbar und für zukünftige Nachrichtenbehandlungen nützlich sind? Dann wären es zunächst „dokumentierende“ Events.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>@phj hat sein Denken so erklärt:</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:quote --></p>
<blockquote class="wp-block-quote">
<p>[M]it nur “roll made” wäre ja nur eine nach events aussehende Fassade vor eine nicht wirklich event-orientierte Lösung gekommen. Das wichtige bei ES ist - und das habe ich versucht damit etwas herauszustellen - dass Logik nur in den Command Handlern, aber nicht in den Projektionen stattfindet. Die Entscheidungen, was ein Frame ist, wann ein Bonus erforderlich wird, etc. mussten damit vor dem Veröffentlichen von Events geschehen, und erfordern daher dann auch spezifische Events.</p>
</blockquote>
<p><!-- /wp:quote --></p>
<p><!-- wp:paragraph --></p>
<p>Etwas zugespitzt formuliert ist der für mich wesentliche Punkt: <em>„dass [Entscheidungsl]ogik nur in Command Handlern“</em> steht.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>@phj sagt weiter:</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:quote --></p>
<blockquote class="wp-block-quote">
<p>dass in den Projektionen keine Entscheidungen […] getroffen werden dürfen, [weil] die eventuell nicht dauerhaft in ihrer Struktur oder Parametrisierung sind. […] Ansonsten würde eine zukünftige Regeländerung zu einer nachträglich anderen Interpretation von bereits durchgeführten Spielen führen. Also müssen die Events die Struktur der Vorbedingungen und der Entscheidungsergebnisse der Geschäftslogik festhalten</p>
</blockquote>
<p><!-- /wp:quote --></p>
<p><!-- wp:paragraph --></p>
<p>Das deckt sich mit meinem Verständnis; nicht umsonst sind wir auf sehr ähnliche Lösungen gekommen😉</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:heading {"level":2} --></p>
<h2>Ergebnis</h2>
<p><!-- /wp:heading --></p>
<p><!-- wp:paragraph --></p>
<p>Events zu finden für gegebene Kommandos und Queries lässt Raum für Kreativität. Hier wie auch sonst in der Softwareentwicklung ist eine Balance zwischen dem unzweifelhaft jetzt Erkennbaren und dem möglichen Zukünftigen zu finden. Auch beim Schneiden von Events kann man ansonsten wohl vorzeitig optimieren.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Allerdings scheinen mir lieber mehr als weniger Events tendenziell eine relativ harmlose und billige Optimierung im Hinblick auf zukünftige Nachvollziehbarkeit und Events als Ausgangsmaterial für weitere Nachrichtenverarbeitungen.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Sich beim einmaligen Schreiben etwas mehr Mühe zu geben, erleichtert später das häufige Lesen aus unterschiedlichen Blickwinkeln. Event Sourcing unterscheidet sich da nicht von der Programmierung, würde ich sagen.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Die Kunst des Event Sourcing besteht dann wohl darin, schon aus den Anforderungen die wesentlichen, aufzeichnungswürdigen, zu stabilisierenden Entscheidungen herauszudestillieren.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Zu berücksichtigen sind dabei Kommandos wie Queries. Und was man da an Entscheidungen findet, ist in Events zu gießen, die beim Command-Handling generiert werden.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Dass ein Wurf stattgefunden hat, ist keine Entscheidung innerhalb einer Lösung. Aber wenn die Regeln von Frames sprechen, wenn es besondere Wurf-Kombinationen gibt und Boni zugesprochen werden… dann stecken dahinter Entscheidungen und die lohnen der Aufzeichnung „für die Nachwelt“.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Dazu mag noch kommen, Begriffe der Domäne materialisieren. Wenn in den Regeln „Frame“, „Spare“, „Strike“, „Bonus“ als Begriffe vorkommen, dann liegt es nahe zu erwarten, sie in einem Eventstrom zu finden.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Das sind lohnende Erkenntnisse aus der Übung. Ein schönes Beispiel für <em>deliberate practice</em>. Für mich hat sich die Challenge also gelohnt. Ich bin mir klarer geworden über Prinzipien und Heuristiken des Event Sourcing. Damit werde ich in die nächste Challenge gehen… Stay tuned!😁</p>
<p> </p>
<p>Endnoten:</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:list {"ordered":true} --></p>
<ol>
<li id="fn1">Materialismus verstehe ich hier als Haltung, die annimmt, dass es außerhalb von Software eine Realität gibt, die es sich lohnt, 1:1 innerhalb der Software mit stabilen Datenstrukturen abzubilden.<br>Konstruktivismus hingegen macht für mich keine solche Annahme. Er konstruiert nach Bedarf immer wieder neue Repräsentationen aus „rohen Wahrnehmungen“, die nicht mehr und nicht weniger als nützlich sind. Ob sie einer „objektiven Realität“ entsprechen oder nicht, ist ihm einerlei. <a href="#ffn1">↩</a></li>
<li id="fn2">Antifragil ist Software bzw. die Softwareentwicklung für mich, wenn sie Änderungswünsche begrüßt. Dann trägt jede Änderung dazu bei, dass Software besser wird und sogar besser im besser werden. <a href="#ffn2">↩</a></li>
<li id="fn3">Auf eine CRUD-Aufgabe habe ich verzichtet, weil die wohl Naserümpfen bei einigen Event Sourcing Freunden hervorgerufen hätte. Die Meinung, dass Event Sourcing sich nicht für CRUD-Szenarien lohne, hält sich noch. Ich bin allerdings anderer Ansicht. Aber davon ein andermal mehr. <a href="#ffn3">↩</a></li>
<li id="fn4">Und das Ergebnis scheinen mir dann auch oft Domänenevents zu sein, die ich in CQNS <a href="https://ralfw.de/command-query-notification-separation-cqns/">Notifications</a> nenne.<br>Domänenevents sind für mich Nachrichten, die zwischen „Akteuren“ fließen. Das bedeutet nicht, dass sie 1:1 in einem Eventstrom aufgezeichnet werden. <a href="#ffn4">↩</a></li>
<li id="fn5">Nur bei @sebastian gibt es eine Frame-Nummer, die implizit eine relativ leichte Erkennung des Spielendes erlaubt, weil jedes Spiel aus 10 Frames besteht. <a href="#ffn5">↩</a></li>
</ol>
<p><!-- /wp:list --></p>
            ]]>
        </content>
    </entry>
    <entry>
        <title>Magically Predictable Software Production for Projects</title>
        <author>
            <name>Ralf Westphal</name>
        </author>
        <link href="https://ralfw.de/magically-predictable-software-production-for-projects/"/>
        <id>https://ralfw.de/magically-predictable-software-production-for-projects/</id>
            <category term="noestimates"/>

        <updated>2021-01-28T17:24:29+08:00</updated>
            <summary>
                <![CDATA[
                        <img src="https://ralfw.de/media/posts/137/DraggedImage-14-1.png" alt="" />
                    Do you remember the story about the magic black box transforming software requirements into release at no cost at all? I wrote about it in a previous article - and since then have received many questions about how it could be deployed in real software&hellip;
                ]]>
            </summary>
        <content type="html">
            <![CDATA[
                    <img src="https://ralfw.de/media/posts/137/DraggedImage-14-1.png" alt="" />
                <p><!-- wp:paragraph --></p>
<p>Do you remember the story about the magic black box transforming software requirements into release at no cost at all? I wrote about it <a href="https://ralfw.de/magically-predictable-software-production/">in a previous article</a> - and since then have received many questions about how it could be deployed in real software projects. Because what I described were simplistic scenarios with just single requirements.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Here’s a short reminder of what this thing is, the magic black box:</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:heading {"level":2} --></p>
<h2>Magic Black Box Recap</h2>
<p><!-- /wp:heading --></p>
<p><!-- wp:paragraph --></p>
<p>Imagine you are a product owner. One day a black box appears on your desk with the promise to produce high quality software for your for free. Yes, for free! You just hook it up to a GitHub repository and feed it requirements as issues. The black box works on them one-by-one and drops the finished code as releases into the repository.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:image {"id":2762, "align": "center"} --></p>
<div class="wp-block-image">
<figure class="aligncenter"><figure class="wp-image-2762"><img loading="lazy"  src="https://ralfw.de/media/posts/137/DraggedImage-24.png" sizes="(max-width: 48em) 100vw, 768px" srcset="https://ralfw.de/media/posts/137/responsive/DraggedImage-24-xs.png 300w ,https://ralfw.de/media/posts/137/responsive/DraggedImage-24-sm.png 480w ,https://ralfw.de/media/posts/137/responsive/DraggedImage-24-md.png 768w ,https://ralfw.de/media/posts/137/responsive/DraggedImage-24-lg.png 1024w ,https://ralfw.de/media/posts/137/responsive/DraggedImage-24-xl.png 1360w ,https://ralfw.de/media/posts/137/responsive/DraggedImage-24-2xl.png 1600w"  alt="" width="372" height="145"></figure></figure>
</div>
<p><!-- /wp:image --></p>
<p><!-- wp:paragraph --></p>
<p>The only downside to the magic is, that you don’t know how long it’s going to take the black box to transform an issue into a new release.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>But since the black box did not cost you anything you try it out and record the <em>cycle time</em> for some issues from start to finish. Some issues take 1 day, some 3 day, and there is even one with 10 days.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:image {"id":2751, "align": "center"} --></p>
<div class="wp-block-image">
<figure class="aligncenter"><figure class="wp-image-2751"><img loading="lazy"  src="https://ralfw.de/media/posts/137/DraggedImage-1-1.png" sizes="(max-width: 48em) 100vw, 768px" srcset="https://ralfw.de/media/posts/137/responsive/DraggedImage-1-1-xs.png 300w ,https://ralfw.de/media/posts/137/responsive/DraggedImage-1-1-sm.png 480w ,https://ralfw.de/media/posts/137/responsive/DraggedImage-1-1-md.png 768w ,https://ralfw.de/media/posts/137/responsive/DraggedImage-1-1-lg.png 1024w ,https://ralfw.de/media/posts/137/responsive/DraggedImage-1-1-xl.png 1360w ,https://ralfw.de/media/posts/137/responsive/DraggedImage-1-1-2xl.png 1600w"  alt="" width="451" height="247"></figure></figure>
</div>
<p><!-- /wp:image --></p>
<p><!-- wp:paragraph --></p>
<p>You realize there is some method to the magic. The black box is not at all useless to you, even though you cannot ask it in advance for an estimation of how long it’s probably gonna work on an issue.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Instead of getting an estimate from it, you observe it and make your own forecast.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:image {"id":2753, "align": "center"} --></p>
<div class="wp-block-image">
<figure class="aligncenter"><figure class="wp-image-2753"><img loading="lazy"  src="https://ralfw.de/media/posts/137/DraggedImage-2-1.png" sizes="(max-width: 48em) 100vw, 768px" srcset="https://ralfw.de/media/posts/137/responsive/DraggedImage-2-1-xs.png 300w ,https://ralfw.de/media/posts/137/responsive/DraggedImage-2-1-sm.png 480w ,https://ralfw.de/media/posts/137/responsive/DraggedImage-2-1-md.png 768w ,https://ralfw.de/media/posts/137/responsive/DraggedImage-2-1-lg.png 1024w ,https://ralfw.de/media/posts/137/responsive/DraggedImage-2-1-xl.png 1360w ,https://ralfw.de/media/posts/137/responsive/DraggedImage-2-1-2xl.png 1600w"  alt="" width="422" height="283"></figure></figure>
</div>
<p><!-- /wp:image --></p>
<p><!-- wp:paragraph --></p>
<p>For example: Based on the issues implemented so far the next one has a 84% chance of being finished in 7 days (or even less).</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>And if you update your log of cycle times with each issue done, your next forecast will be even more realistic. With three more issues implemented you see how the situation even changes towards the better. 6 days (or less) has moved up from 79% probability to 82%.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:image {"id":2752, "align": "center"} --></p>
<div class="wp-block-image">
<figure class="aligncenter"><figure class="wp-image-2752"><img loading="lazy"  src="https://ralfw.de/media/posts/137/DraggedImage-3-1.png" sizes="(max-width: 48em) 100vw, 768px" srcset="https://ralfw.de/media/posts/137/responsive/DraggedImage-3-1-xs.png 300w ,https://ralfw.de/media/posts/137/responsive/DraggedImage-3-1-sm.png 480w ,https://ralfw.de/media/posts/137/responsive/DraggedImage-3-1-md.png 768w ,https://ralfw.de/media/posts/137/responsive/DraggedImage-3-1-lg.png 1024w ,https://ralfw.de/media/posts/137/responsive/DraggedImage-3-1-xl.png 1360w ,https://ralfw.de/media/posts/137/responsive/DraggedImage-3-1-2xl.png 1600w"  alt="" width="464" height="323"></figure></figure>
</div>
<p><!-- /wp:image --></p>
<p><!-- wp:paragraph --></p>
<p>I think, this is a much more realistic information compared to some developer’s gut feeling. The simple reason: this prediction is based on facts, on historical data. No wishful thinking, no invisible padding, no deadline-driven distortion. And you did not need to go through frustrating discussions with developers.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>So much for a quick recap. Read the previous article for a couple of more details.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:heading {"level":2} --></p>
<h2>Single Black Box, Multiple Issues</h2>
<p><!-- /wp:heading --></p>
<p><!-- wp:paragraph --></p>
<p>Forecasting the implementation time for a single feature is not bad. But it’s not more than a start. Managers and customer are rarely asking „How long will only this one feature take?“ Rather they want to know how long it takes to get the next 5, 17, 31 features done.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>For example: What’s your answer to „How long will 4 features take?“ if the answer to the single feature question is „With an 82% chance it’s gonna take 6 days.“? Do you just calculate 6+6+6+6=24 and say „It’s gonna take 24 days with a probability of 82%.“?</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>No, that’s not gonna work. Or: It works, but then your prediction (cycle time for 4 features) is worse than it needs to be and wrong (with regard to the probability).</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Instead what you do is run simulations.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:heading {"level":3} --></p>
<h3>Monte Carlo Simulation</h3>
<p><!-- /wp:heading --></p>
<p><!-- wp:paragraph --></p>
<p>A single simulation looks like this: Sample the historical data 4 times (since you want to forecast the total cycle time for 4 features), i.e. pick 4 cycle times at random. This might result in these cycle times: (1, 1, 3, 7). The total cycle time would be 12 days.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Then do it again: (2, 4, 5, 3)=14.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Then do it again: (9, 1, 3, 7)=20.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>And so on, and so on… Do it 1000 or 50000 times. That’s called a <a href="https://en.wikipedia.org/wiki/Monte_Carlo_method" target="_blank" rel="nofollow noopener noreferrer">Monte Carlo Simulation</a>.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Then for each of the maybe 1000 total cycle times count how often it occurs, e.g. 5=4 times, 9=50 times, 14=98 times, 25=10 times…</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Here are the results of 1000 such simulations for 4 features based on the latest historical data from above:</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:image {"id":2755, "align": "center"} --></p>
<div class="wp-block-image">
<figure class="aligncenter"><figure class="wp-image-2755"><img loading="lazy"  src="https://ralfw.de/media/posts/137/DraggedImage-4-1.png" sizes="(max-width: 48em) 100vw, 768px" srcset="https://ralfw.de/media/posts/137/responsive/DraggedImage-4-1-xs.png 300w ,https://ralfw.de/media/posts/137/responsive/DraggedImage-4-1-sm.png 480w ,https://ralfw.de/media/posts/137/responsive/DraggedImage-4-1-md.png 768w ,https://ralfw.de/media/posts/137/responsive/DraggedImage-4-1-lg.png 1024w ,https://ralfw.de/media/posts/137/responsive/DraggedImage-4-1-xl.png 1360w ,https://ralfw.de/media/posts/137/responsive/DraggedImage-4-1-2xl.png 1600w"  alt="" width="158" height="490"></figure></figure>
</div>
<p><!-- /wp:image --></p>
<p><!-- wp:paragraph --></p>
<p>It’s pretty clear that 4 features cannot be done in less than 2 days, since a single issue always took the black box at least 0.5 days. And it’s clear that it cannot be more than 40 days, i.e. 4 times the maximum cycle time so far.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>But as you can see from the above simulation both the minimum or maximum might not even happen. At least they did not happen during 1000 „trial runs“.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Now look at the simulation data turned into a histogram. Interesting, isn’t it?</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:image {"id":2757, "align": "center"} --></p>
<div class="wp-block-image">
<figure class="aligncenter"><figure class="wp-image-2757"><img loading="lazy"  src="https://ralfw.de/media/posts/137/DraggedImage-5-1.png" sizes="(max-width: 48em) 100vw, 768px" srcset="https://ralfw.de/media/posts/137/responsive/DraggedImage-5-1-xs.png 300w ,https://ralfw.de/media/posts/137/responsive/DraggedImage-5-1-sm.png 480w ,https://ralfw.de/media/posts/137/responsive/DraggedImage-5-1-md.png 768w ,https://ralfw.de/media/posts/137/responsive/DraggedImage-5-1-lg.png 1024w ,https://ralfw.de/media/posts/137/responsive/DraggedImage-5-1-xl.png 1360w ,https://ralfw.de/media/posts/137/responsive/DraggedImage-5-1-2xl.png 1600w"  alt="" width="567" height="294"></figure></figure>
</div>
<p><!-- /wp:image --></p>
<p><!-- wp:paragraph --></p>
<p>The original distribution had two „humps“ (see above): one at cycle time 2, another at 9. But the distribution of total cycle times does not resemble the original distribution. It’s close to a normal distribution. That’s due to the <a href="https://www.thoughtco.com/importance-of-the-central-limit-theorem-3126556" target="_blank" rel="nofollow noopener noreferrer">Central Limit Theorem</a> and was bound to happen. But don’t worry. No need to get deeper into math here.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>And of what use is this to answer the question „When will 4 features be done?“? Like with single feature forecasts it’s about percentiles again: How many simulation results are equal or less than a certain total cycle time?</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>If you still think a bearable risk is 18% then 19 days are your forecast: 82% of all simulation results predicted 19 days or less for 4 features.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:image {"id":2761, "align": "center"} --></p>
<div class="wp-block-image">
<figure class="aligncenter"><figure class="wp-image-2761"><img loading="lazy"  src="https://ralfw.de/media/posts/137/DraggedImage-6-1.png" sizes="(max-width: 48em) 100vw, 768px" srcset="https://ralfw.de/media/posts/137/responsive/DraggedImage-6-1-xs.png 300w ,https://ralfw.de/media/posts/137/responsive/DraggedImage-6-1-sm.png 480w ,https://ralfw.de/media/posts/137/responsive/DraggedImage-6-1-md.png 768w ,https://ralfw.de/media/posts/137/responsive/DraggedImage-6-1-lg.png 1024w ,https://ralfw.de/media/posts/137/responsive/DraggedImage-6-1-xl.png 1360w ,https://ralfw.de/media/posts/137/responsive/DraggedImage-6-1-2xl.png 1600w"  alt="" width="557" height="315"></figure></figure>
</div>
<p><!-- /wp:image --></p>
<p><!-- wp:paragraph --></p>
<p>Now you see, why 24 days where too much. 24 days, i.e. 4 times the 82% cycle time for a single feature, would offer you even 96% confidence!</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>That’s why the usual padding of estimations is so wrong: The manager asks developer A for his estimation of feature 1 and gets 10 days including a (unknown) 30% padding. She asks developers B, C, D for three more features each including a padding of 30%. Even these 4x30% padding are too much; they are the same as 24 for the simplistic total cycle time for 4 feature. But nevertheless she adds another 10% to be on the safe side. This decreases the risk, sure, but not explicitly. Receivers of the updated estimates don’t know about it; it might be contrary to their risk attitude. It probably creates a prospect of higher costs than necessary.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>But never mind. Those days of excessive padding are over. With forecasting and a black box the predictions are much more realistic: no hidden padding, no excess padding.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>You see, predicting the development of multiple features is possible even if you’re working with a black box you cannot ask for an estimation. The math is simple, the approach straightforward. It can be done in some 50 lines of logic in C# plus a bit of Excel for visualization. That’s no rocket science.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:heading {"level":2} --></p>
<h2>Multiple Black Boxes, Multiple Issues</h2>
<p><!-- /wp:heading --></p>
<p><!-- wp:paragraph --></p>
<p>So far the story about the Magic Black Box assumes you as a PO only get one. Since each Black Box probably works best on a single issue at a time, features get implemented in a sequential way.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>That’s great for a single project. Work-in-progress is naturally kept to 1. All issues get implemented in the fastest way possible.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>But if there are multiple POs working on parts of a larger project and each one was presented with a black box… How can a prediction for the whole project be done? Multiple black boxes surely are working in parallel. Releases get crunched out in parallel.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:image {"id":2758, "align": "center"} --></p>
<div class="wp-block-image">
<figure class="aligncenter"><figure class="wp-image-2758"><img loading="lazy"  src="https://ralfw.de/media/posts/137/DraggedImage-7-1.png" sizes="(max-width: 48em) 100vw, 768px" srcset="https://ralfw.de/media/posts/137/responsive/DraggedImage-7-1-xs.png 300w ,https://ralfw.de/media/posts/137/responsive/DraggedImage-7-1-sm.png 480w ,https://ralfw.de/media/posts/137/responsive/DraggedImage-7-1-md.png 768w ,https://ralfw.de/media/posts/137/responsive/DraggedImage-7-1-lg.png 1024w ,https://ralfw.de/media/posts/137/responsive/DraggedImage-7-1-xl.png 1360w ,https://ralfw.de/media/posts/137/responsive/DraggedImage-7-1-2xl.png 1600w"  alt="" width="454" height="99"></figure></figure>
</div>
<p><!-- /wp:image --></p>
<p><!-- wp:paragraph --></p>
<p>Maybe 3 POs with their black boxes are supposed to deliver 10 features. How long is that gonna take? For a single black box working sequentially simulation would deliver a result like this:</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:image {"id":2763, "align": "center"} --></p>
<div class="wp-block-image">
<figure class="aligncenter"><figure class="wp-image-2763"><img loading="lazy"  src="https://ralfw.de/media/posts/137/DraggedImage-8-1.png" sizes="(max-width: 48em) 100vw, 768px" srcset="https://ralfw.de/media/posts/137/responsive/DraggedImage-8-1-xs.png 300w ,https://ralfw.de/media/posts/137/responsive/DraggedImage-8-1-sm.png 480w ,https://ralfw.de/media/posts/137/responsive/DraggedImage-8-1-md.png 768w ,https://ralfw.de/media/posts/137/responsive/DraggedImage-8-1-lg.png 1024w ,https://ralfw.de/media/posts/137/responsive/DraggedImage-8-1-xl.png 1360w ,https://ralfw.de/media/posts/137/responsive/DraggedImage-8-1-2xl.png 1600w"  alt="" width="576" height="314"></figure></figure>
</div>
<p><!-- /wp:image --></p>
<p><!-- wp:paragraph --></p>
<p>10 features would take 44 days (or less) with a a probability of 82%.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>But that does not take into account any work done in parallel. Working independently on multiple features at the same time sure should take less time. But how much less? How to forecast simultaneous work?</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:heading {"level":3} --></p>
<h3>Throughput Instead of Cycle Time</h3>
<p><!-- /wp:heading --></p>
<p><!-- wp:paragraph --></p>
<p>When measuring the productivity of several resources the metric switches away from cycle time. When work starts on an issue K it’s not clear if issue K is the next one to get finished (regardless of the cycle time). Maybe issue J or H is the next to be released.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Hence, what’s more interesting than cycle time is <em>throughput</em>: How many features get finished in a period of time (e.g. a day or a week)?</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>You can get throughput data from your historical cycle time data if you recorded when a work item got fed to a resource (here: issues to multiple black boxes) and when it was „spit out“ finished:</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:image {"id":2750, "align": "center"} --></p>
<div class="wp-block-image">
<figure class="aligncenter"><figure class="wp-image-2750"><img loading="lazy"  src="https://ralfw.de/media/posts/137/DraggedImage-9-1.png" sizes="(max-width: 48em) 100vw, 768px" srcset="https://ralfw.de/media/posts/137/responsive/DraggedImage-9-1-xs.png 300w ,https://ralfw.de/media/posts/137/responsive/DraggedImage-9-1-sm.png 480w ,https://ralfw.de/media/posts/137/responsive/DraggedImage-9-1-md.png 768w ,https://ralfw.de/media/posts/137/responsive/DraggedImage-9-1-lg.png 1024w ,https://ralfw.de/media/posts/137/responsive/DraggedImage-9-1-xl.png 1360w ,https://ralfw.de/media/posts/137/responsive/DraggedImage-9-1-2xl.png 1600w"  alt="" width="321" height="482"></figure></figure>
</div>
<p><!-- /wp:image --></p>
<p><!-- wp:paragraph --></p>
<p>In this excerpt from a cycle time log, for example issues A and B entered „production“ on July 1st, but A left it on July 3rd and B on July 4th. Their cycle times were 3 and 4 days. Other features just took 2 days, e.g. D, others 10 (M). (Never mind that each day on the table seems to be a work day; no weekends included for simplicity.)</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Throughput is not interested in how long each issue takes from start to finish, but how many items get processed and leave the system in a given time period.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>As you can see, not every day issues got finished according to the above log. But on some days 1 was released, on others 2 or 3.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:image {"id":2760, "align": "center"} --></p>
<div class="wp-block-image">
<figure class="aligncenter"><figure class="wp-image-2760"><img loading="lazy"  src="https://ralfw.de/media/posts/137/DraggedImage-10-1.png" sizes="(max-width: 48em) 100vw, 768px" srcset="https://ralfw.de/media/posts/137/responsive/DraggedImage-10-1-xs.png 300w ,https://ralfw.de/media/posts/137/responsive/DraggedImage-10-1-sm.png 480w ,https://ralfw.de/media/posts/137/responsive/DraggedImage-10-1-md.png 768w ,https://ralfw.de/media/posts/137/responsive/DraggedImage-10-1-lg.png 1024w ,https://ralfw.de/media/posts/137/responsive/DraggedImage-10-1-xl.png 1360w ,https://ralfw.de/media/posts/137/responsive/DraggedImage-10-1-2xl.png 1600w"  alt="" width="171" height="110"></figure></figure>
</div>
<p><!-- /wp:image --></p>
<p><!-- wp:paragraph --></p>
<p>Throughput values like cycle time values thus have a frequency distribution:</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:image {"id":2754, "align": "center"} --></p>
<div class="wp-block-image">
<figure class="aligncenter"><figure class="wp-image-2754"><img loading="lazy"  src="https://ralfw.de/media/posts/137/DraggedImage-11-1.png" sizes="(max-width: 48em) 100vw, 768px" srcset="https://ralfw.de/media/posts/137/responsive/DraggedImage-11-1-xs.png 300w ,https://ralfw.de/media/posts/137/responsive/DraggedImage-11-1-sm.png 480w ,https://ralfw.de/media/posts/137/responsive/DraggedImage-11-1-md.png 768w ,https://ralfw.de/media/posts/137/responsive/DraggedImage-11-1-lg.png 1024w ,https://ralfw.de/media/posts/137/responsive/DraggedImage-11-1-xl.png 1360w ,https://ralfw.de/media/posts/137/responsive/DraggedImage-11-1-2xl.png 1600w"  alt="" width="357" height="238"></figure></figure>
</div>
<p><!-- /wp:image --></p>
<p><!-- wp:heading {"level":3} --></p>
<h3>Simulating Parallel Work</h3>
<p><!-- /wp:heading --></p>
<p><!-- wp:paragraph --></p>
<p>To simulate the production multiple black boxes can achieve, the approach is slightly different. Frequency values don’t get added, but subtracted. A single simulation looks like this:</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Pick a throughput value from the list of historical data in the granularity of the relevant time period, e.g. days or weeks.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:image {"id":2759, "align": "center"} --></p>
<div class="wp-block-image">
<figure class="aligncenter"><figure class="wp-image-2759"><img loading="lazy"  src="https://ralfw.de/media/posts/137/DraggedImage-12-1.png" sizes="(max-width: 48em) 100vw, 768px" srcset="https://ralfw.de/media/posts/137/responsive/DraggedImage-12-1-xs.png 300w ,https://ralfw.de/media/posts/137/responsive/DraggedImage-12-1-sm.png 480w ,https://ralfw.de/media/posts/137/responsive/DraggedImage-12-1-md.png 768w ,https://ralfw.de/media/posts/137/responsive/DraggedImage-12-1-lg.png 1024w ,https://ralfw.de/media/posts/137/responsive/DraggedImage-12-1-xl.png 1360w ,https://ralfw.de/media/posts/137/responsive/DraggedImage-12-1-2xl.png 1600w"  alt="" width="94" height="597"></figure></figure>
</div>
<p><!-- /wp:image --></p>
<p><!-- wp:paragraph --></p>
<p>Then subtract the value picked from the number of features to implement, e.g. 10 features, 2 got picked, the number of remaining features is 8.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Do this until all features are finished, e.g. for 10 features that could look like this: 2:8, 0:8, 1:7, 0:7, 0:7, 1:6, 3:3, 0:3, 0:3, 1:2: 0:2, 0:2, 3:-1.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>The number of picks needed is the number of days required to accomplish the features, e.g. 13.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Repeat this a 1000 or more times. The result again is a table of frequencies. But this time they stand for the total number of days needed until completion of the features:</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:image {"id":2756, "align": "center"} --></p>
<div class="wp-block-image">
<figure class="aligncenter"><figure class="wp-image-2756"><img loading="lazy"  src="https://ralfw.de/media/posts/137/DraggedImage-13-1.png" sizes="(max-width: 48em) 100vw, 768px" srcset="https://ralfw.de/media/posts/137/responsive/DraggedImage-13-1-xs.png 300w ,https://ralfw.de/media/posts/137/responsive/DraggedImage-13-1-sm.png 480w ,https://ralfw.de/media/posts/137/responsive/DraggedImage-13-1-md.png 768w ,https://ralfw.de/media/posts/137/responsive/DraggedImage-13-1-lg.png 1024w ,https://ralfw.de/media/posts/137/responsive/DraggedImage-13-1-xl.png 1360w ,https://ralfw.de/media/posts/137/responsive/DraggedImage-13-1-2xl.png 1600w"  alt="" width="266" height="383"></figure></figure>
</div>
<p><!-- /wp:image --></p>
<p><!-- wp:paragraph --></p>
<p>The resulting histogram also again looks almost like a normal distribution:</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:image {"id":2764, "align": "center"} --></p>
<div class="wp-block-image">
<figure class="aligncenter"><figure class="wp-image-2764"><img loading="lazy"  src="https://ralfw.de/media/posts/137/DraggedImage-14-1.png" sizes="(max-width: 48em) 100vw, 768px" srcset="https://ralfw.de/media/posts/137/responsive/DraggedImage-14-1-xs.png 300w ,https://ralfw.de/media/posts/137/responsive/DraggedImage-14-1-sm.png 480w ,https://ralfw.de/media/posts/137/responsive/DraggedImage-14-1-md.png 768w ,https://ralfw.de/media/posts/137/responsive/DraggedImage-14-1-lg.png 1024w ,https://ralfw.de/media/posts/137/responsive/DraggedImage-14-1-xl.png 1360w ,https://ralfw.de/media/posts/137/responsive/DraggedImage-14-1-2xl.png 1600w"  alt="" width="556" height="303"></figure></figure>
</div>
<p><!-- /wp:image --></p>
<p><!-- wp:paragraph --></p>
<p>And based on the percentiles from the table you can highlight the number of days you feel comfortable with for delivering multiple features with multiple black boxes at work. In this case it’s 16 days for 10 features with a risk of 15%.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Please don’t compare these 16 days to the above 44 days for 10 features with a single black box. Both are based on different datasets. They need to, since the above cycle times are just from a single black box. Multiple black boxes sure differ in their cycle time logs; and all those logs get merged. For a forecast it’s not important which black box did what. Only the overall throughput is of interest. The customer does not care which PO with her black box actually works on a feature.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:heading {"level":1} --></p>
<h1>Fin</h1>
<p><!-- /wp:heading --></p>
<p><!-- wp:paragraph --></p>
<p>Can you believe it? Black Boxes happily humming while implementing issues from Github backlogs, but mute, can still be used to deliver on time. You cannot ask them for an estimation - nevertheless you can make a prediction for when multiple features likely will be finished. (With „likely“ being a probability you choose according to your risk attitude.)</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Think of all the time and energy saved by not arguing about estimations. Think about the blame avoided because nobody got the padding wrong.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Talking to developers about feature complexity is still worthwhile - but for a different reason. Don’t get prioritization mixed up with prediction.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Talk with developers about complexity and categorization to help you with prioritization.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Don’t talk with developers about estimations. They get it wrong 100% of the time, and everybody is feeling bad sooner or later.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Don’t look into a crystal ball. Look at facts, look at historical data. Do your math! Calculate a probability distribution (or histogram) and pick a number according to the risk you are willing to take. That’s entirely your choice (or whoever wants a prediction anyway).</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>And then <a href="https://ralfw.de/steering-software-development-with-priorities-instead-of-deadlines/">don’t tell the developers about your deadline</a>! That’s crucial. Only that way they will deliver all qualities required: functionality, efficiency, sustainability.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>You can even pick two numbers, if you like. The probability distribution is clear. That’s an important improvement compared to any estimation you can possibly get. So pick a number to communicate to the customer, e.g. from the 95% percentile, and another number for internal use, e.g. from the 85% percentile.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>After that: Lean back and watch the development unfold… No, don’t lean back. Walk around. Keep yourself informed about the progress towards your personal goal. Actively steer the development with ongoing re-prioritizations, scope reduction, impediment removal.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>But don’t take just my work for it. Read <em>the</em> book on it: <a href="https://leanpub.com/whenwillitbedone" target="_blank" rel="nofollow noopener noreferrer">When Will It Be Done? </a>by Daniel S. Vacanti. There’s more to „predictable software development.“</p>
<p><!-- /wp:paragraph --></p>
            ]]>
        </content>
    </entry>
    <entry>
        <title>Über den fundamentalen Zielkonflikt in Unternehmen - und in der Schule</title>
        <author>
            <name>Ralf Westphal</name>
        </author>
        <link href="https://ralfw.de/ueber-den-fundamentalen-zielkonflikt-in-unternehmen-und-in-der-schule/"/>
        <id>https://ralfw.de/ueber-den-fundamentalen-zielkonflikt-in-unternehmen-und-in-der-schule/</id>
            <category term="Führung"/>

        <updated>2021-01-25T22:26:43+08:00</updated>
            <summary>
                <![CDATA[
                        <img src="https://ralfw.de/media/posts/136/DraggedImage-6.png" alt="" />
                    Fürs Leben lernen wir, nicht für die Schule. Und der Kunde steht stets an erster Stelle. So wird es doch immer wieder beteuert, oder? Das halte ich für fromme Wünsche. Denn es kann nicht funktionieren. Mein Argument ist aber kein politisches, sondern ein strukturelles. Ich&hellip;
                ]]>
            </summary>
        <content type="html">
            <![CDATA[
                    <img src="https://ralfw.de/media/posts/136/DraggedImage-6.png" alt="" />
                <p><!-- wp:paragraph --></p>
<p>Fürs Leben lernen wir, nicht für die Schule. Und der Kunde steht stets an erster Stelle. So wird es doch immer wieder beteuert, oder?</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Das halte ich für fromme Wünsche. Denn es kann nicht funktionieren. Mein Argument ist aber kein politisches, sondern ein strukturelles. Ich möchte ein Modell beschreiben, mit dem man so manche Verhältnisse erklären kann, über die man sonst nur ratlos den Kopf schüttelt.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Das versuche ich mal mit einer Reihe von Bildern zu erklären. Damit habe ich mich schon einmal <a href="https://medium.com/gedankliche-umtriebe/evolution-der-dysfunktion-teil-1-e376c90e0395" target="_blank" rel="noopener">in einer Artikelserie</a> beschäftigt, doch damals sah ich noch nicht den Zusammenhang zwischen Schule und Unternehmen.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Die Beteuerungen sind naiv bis hohl, weil sie einen Zielkonflikt übersehen (wollen), der der fundamentalen Struktur der Organisationen Schule bzw. Unternehmen zugrunde liegt. Der sorgt dafür, dass nicht oder nur zufällig oder nur unter übermäßigem Aufwand das beteuerte Resultat entsteht: ein allseits gebildeter Schüler bzw. ein zufriedener Kunde.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Und dieser Zielkonflikt entsteht so…</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:heading {"level":2} --></p>
<h2>Bedürfnisse motivieren</h2>
<p><!-- /wp:heading --></p>
<p><!-- wp:paragraph --></p>
<p>Warum tun wir freiwillig, gar selbstständig, was wir tun? Weil wir damit ein Bedürfnis befriedigen. Das ist meine hoffentlich nicht zu simple Weltsicht.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Unsere Bedürfnisse reichen vom Biologischen bis zum „Ideellen“. Manche können wir nicht länger als Sekunden leugnen, andere aber ein Leben lang. Zwischen manchen lässt sich die Befriedigung vereinbaren, zwischen anderen steht sie durchaus im Konflikt. Niemand hat gesagt, dass das Leben einfach sei.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Wenn wir ein Bedürfnis genügend stark empfinden, werden wir tätig, um es zu stillen. Wir interagieren im einfachsten Fall mit der „menschenleeren“ Umwelt. Indem wir auf sie Mühe aufwenden, ernten wir etwas als Lohn, der uns befriedigt.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:image {"id":2738, "align": "center"} --></p>
<div class="wp-block-image">
<figure class="aligncenter"><figure class="wp-image-2738"><img loading="lazy"  src="https://ralfw.de/media/posts/136/DraggedImage.png" sizes="(max-width: 48em) 100vw, 768px" srcset="https://ralfw.de/media/posts/136/responsive/DraggedImage-xs.png 300w ,https://ralfw.de/media/posts/136/responsive/DraggedImage-sm.png 480w ,https://ralfw.de/media/posts/136/responsive/DraggedImage-md.png 768w ,https://ralfw.de/media/posts/136/responsive/DraggedImage-lg.png 1024w ,https://ralfw.de/media/posts/136/responsive/DraggedImage-xl.png 1360w ,https://ralfw.de/media/posts/136/responsive/DraggedImage-2xl.png 1600w"  alt="" width="295" height="208" /></figure></figure>
</div>
<p><!-- /wp:image --></p>
<p><!-- wp:paragraph --></p>
<p>Wenn ich Durst habe, stehe ich auf und hole mir etwas zu trinken. Eine geringe Mühe für ein lohnendes Glas Wasser. In anderer Situation ist vielleicht kein Wasserhahn in der Nähe, dann muss ich einen weiteren Weg zu einem Supermarkt zurücklegen. Oder in dürregeplagten Weltgegenden müsste ich womöglich viele Kilometer bis zu einem Brunnen laufen, um etwas zu Trinken zu finden.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Manchmal ist die Mühe sekundenkurz, manchmal sind Jahre nötig, um den Lohn der Mühe zu ernten, der ein Bedürfnis befriedigt (oder auch nur einen Wunsch erfüllt).</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Selbstbestimmung bedeutet, dass ich wählen kann, welches Bedürfnis ich befriedigen will und wie viel Mühe ich bereit bin, dafür zu investieren. Ob es sich am Ende lohnt, mag ungewiss sein. Doch gerade in Selbstbestimmtheit nehmen Menschen auch Unglaubliches auf sich, um selbst bei geringer Erfolgsaussicht ein tiefes Bedürfnis zu stillen. Man kann ihnen nicht vorwerfen, dass sie „im Naturzustand“ faul oder unwillig seien. Nur muss eben die Motivation stimmen, d.h. ein Bedürfnis stark genug sein. Dann ist ihnen kein Weg zu weit, kein Berg zu hoch.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:heading {"level":2} --></p>
<h2>Bedürfnisbefriedigung in Interaktion</h2>
<p><!-- /wp:heading --></p>
<p><!-- wp:paragraph --></p>
<p>An diesem Grundsätzlichen Willen ändert sich auch nichts, wenn Menschen ihre Bedürfnisse nicht direkt an der „menschenleeren“ Natur stillen, sondern durch Interaktion mit anderen Menschen. Das geschieht zunächst auch ganz natürlich direkt:</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:image {"id":2736, "align": "center"} --></p>
<div class="wp-block-image">
<figure class="aligncenter"><figure class="wp-image-2736"><img loading="lazy"  src="https://ralfw.de/media/posts/136/DraggedImage-1.png" sizes="(max-width: 48em) 100vw, 768px" srcset="https://ralfw.de/media/posts/136/responsive/DraggedImage-1-xs.png 300w ,https://ralfw.de/media/posts/136/responsive/DraggedImage-1-sm.png 480w ,https://ralfw.de/media/posts/136/responsive/DraggedImage-1-md.png 768w ,https://ralfw.de/media/posts/136/responsive/DraggedImage-1-lg.png 1024w ,https://ralfw.de/media/posts/136/responsive/DraggedImage-1-xl.png 1360w ,https://ralfw.de/media/posts/136/responsive/DraggedImage-1-2xl.png 1600w"  alt="" width="288" height="175" /></figure></figure>
</div>
<p><!-- /wp:image --></p>
<p><!-- wp:paragraph --></p>
<p>Die Mühe des einen richtet sich hier auf einen anderen, der den einen dafür entlohnt. Die Mühe kann sich in einem Haarschnitt ausdrücken und der Lohn in einem Blumenstrauß. Oder die Mühe besteht darin, ein Geschenk zu basteln, und der Lohn in Begeisterung und einer Umarmung. Oder jemand macht sich die Mühe, einem anderen bei der Ernte zu helfen, und erhält dafür Kost und Logis.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Etwas speziell wird es dann jedoch, wenn der Lohn der Mühe Geld ist. Denn Geld ist in unserer Gesellschaft das universelle Mittel, um ganz verschiedene Bedürfnisse zu erfüllen, die man im Moment der Mühsal womöglich noch gar nicht spürt.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:image {"id":2741, "align": "center"} --></p>
<div class="wp-block-image">
<figure class="aligncenter"><figure class="wp-image-2741"><img loading="lazy"  src="https://ralfw.de/media/posts/136/DraggedImage-2.png" sizes="(max-width: 48em) 100vw, 768px" srcset="https://ralfw.de/media/posts/136/responsive/DraggedImage-2-xs.png 300w ,https://ralfw.de/media/posts/136/responsive/DraggedImage-2-sm.png 480w ,https://ralfw.de/media/posts/136/responsive/DraggedImage-2-md.png 768w ,https://ralfw.de/media/posts/136/responsive/DraggedImage-2-lg.png 1024w ,https://ralfw.de/media/posts/136/responsive/DraggedImage-2-xl.png 1360w ,https://ralfw.de/media/posts/136/responsive/DraggedImage-2-2xl.png 1600w"  alt="" width="381" height="163" /></figure></figure>
</div>
<p><!-- /wp:image --></p>
<p><!-- wp:paragraph --></p>
<p>Bei einer solchen Interaktion will ich den bedürftig Bemühten <em>Produzent</em> und den belohnenden Empfangenden <em>Kunde</em> nennen.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Für mich ist das im Grunde die Definition von Selbstständigkeit in der Arbeitswelt: Wer ein Produkt genau an den liefert, der genau ihn mit Geld genau für das Produkt entlohnt, ist selbstständig. Denn er kann entscheiden, wie er das Produkt gestaltet und welchen Lohn er dafür angemessen findet, den er mit dem Kunden dann auch aushandelt.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:heading {"level":3} --></p>
<h3>Vielschichtige Tauschbeziehungen</h3>
<p><!-- /wp:heading --></p>
<p><!-- wp:paragraph --></p>
<p>Insbesondere in der Interaktion zwischen Produzenten und Kunden scheint es mir nun so, dass der Austausch nicht immer nur aus dem Offensichtlichen, d.h. Produkt bzw. Lohn besteht. Mehr schwingt und fließt zwischen den Menschen.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Die Mühe, des Produzenten, die sich in der Qualität seines Produktes äußert, befriedigt womöglich nicht nur ein materielles Bedürfnis (z.B. Hunger) beim Kunden, sondern auch ein immaterielles (z.B. den Wunsch nach Respekt).</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Und der Lohn, den der Kunde dem Produzenten zahlt, befriedigt womöglich nicht nur zukünftige materielle Bedürfnisse, sonder auch immaterielle (z.B. den Wunsch nach Selbstwirksamkeit).</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Das, was zwischen den Parteien fließt ist also mehrschichtig, bunt - und das befriedigende Mischungsverhältnis kann sehr individuell und nicht unbedingt offensichtlich sein.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:image {"id":2737, "align": "center"} --></p>
<div class="wp-block-image">
<figure class="aligncenter"><figure class="wp-image-2737"><img loading="lazy"  src="https://ralfw.de/media/posts/136/DraggedImage-3.png" sizes="(max-width: 48em) 100vw, 768px" srcset="https://ralfw.de/media/posts/136/responsive/DraggedImage-3-xs.png 300w ,https://ralfw.de/media/posts/136/responsive/DraggedImage-3-sm.png 480w ,https://ralfw.de/media/posts/136/responsive/DraggedImage-3-md.png 768w ,https://ralfw.de/media/posts/136/responsive/DraggedImage-3-lg.png 1024w ,https://ralfw.de/media/posts/136/responsive/DraggedImage-3-xl.png 1360w ,https://ralfw.de/media/posts/136/responsive/DraggedImage-3-2xl.png 1600w"  alt="" width="275" height="234" /></figure></figure>
</div>
<p><!-- /wp:image --></p>
<p><!-- wp:paragraph --></p>
<p>Die Bedürfnisse der Menschen sind vielfältig, warum sollten die Interaktionen zu ihrer Befriedigung also nicht vielschichtig sein?</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Dennoch: primär ist, wenn es sich um Produzent und Kunde handelt, der finanzielle Lohn. Andere lohnende Rückflüsse ergänzen ihn nur oder kompensieren bis zu einem gewissen Grad, falls er geringer als gewünscht ausfällt.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:heading {"level":3} --></p>
<h3>Unternehmen als Interaktionspartner</h3>
<p><!-- /wp:heading --></p>
<p><!-- wp:paragraph --></p>
<p>Die Verhältnisse ändern sich nicht grundsätzlich, wenn Unternehmen die Interaktionspartner sind.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:image {"id":2718, "align": "center"} --></p>
<div class="wp-block-image">
<figure class="aligncenter"><figure class="wp-image-2718"><img loading="lazy"  src="https://ralfw.de/media/posts/136/DraggedImage-4.png" sizes="(max-width: 48em) 100vw, 768px" srcset="https://ralfw.de/media/posts/136/responsive/DraggedImage-4-xs.png 300w ,https://ralfw.de/media/posts/136/responsive/DraggedImage-4-sm.png 480w ,https://ralfw.de/media/posts/136/responsive/DraggedImage-4-md.png 768w ,https://ralfw.de/media/posts/136/responsive/DraggedImage-4-lg.png 1024w ,https://ralfw.de/media/posts/136/responsive/DraggedImage-4-xl.png 1360w ,https://ralfw.de/media/posts/136/responsive/DraggedImage-4-2xl.png 1600w"  alt="" width="516" height="123" /></figure></figure>
</div>
<p><!-- /wp:image --></p>
<p><!-- wp:paragraph --></p>
<p>Als „soziale Organismen“ (oder Organisationen) haben sie ebenfalls Bedürfnisse, die sie in Interaktion befriedigen wollen. Lediglich der Lohn für ein Unternehmen scheint mir hier reduzierter auf das reine Geld.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Wie es mit den Menschen im Unternehmen aussieht, ist eine andere Sache. Dazu unten mehr. Zunächst möchte ich Unternehmen als Black Boxes betrachten. So treten sie auf dem Markt auf: B2B wie B2C.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:heading {"level":2} --></p>
<h2>Interaktionsstrukturen</h2>
<p><!-- /wp:heading --></p>
<p><!-- wp:paragraph --></p>
<p>Die „Interaktionsatome“ sind die zwischen Begierigem/Bemühtem und Entlohnendem, sei das „menschenleere“ Natur, Mensch oder Organisation.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:image {"id":2723, "align": "center"} --></p>
<div class="wp-block-image">
<figure class="aligncenter"><figure class="wp-image-2723"><img loading="lazy"  src="https://ralfw.de/media/posts/136/DraggedImage-5.png" sizes="(max-width: 48em) 100vw, 768px" srcset="https://ralfw.de/media/posts/136/responsive/DraggedImage-5-xs.png 300w ,https://ralfw.de/media/posts/136/responsive/DraggedImage-5-sm.png 480w ,https://ralfw.de/media/posts/136/responsive/DraggedImage-5-md.png 768w ,https://ralfw.de/media/posts/136/responsive/DraggedImage-5-lg.png 1024w ,https://ralfw.de/media/posts/136/responsive/DraggedImage-5-xl.png 1360w ,https://ralfw.de/media/posts/136/responsive/DraggedImage-5-2xl.png 1600w"  alt="" width="423" height="180" /></figure></figure>
</div>
<p><!-- /wp:image --></p>
<p><!-- wp:paragraph --></p>
<p>Aus ihnen lassen sich allerdings beliebige größere Strukturen zusammensetzen, in denen Beteiligte beide Rollen spielen:</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:image {"id":2729, "align": "center"} --></p>
<div class="wp-block-image">
<figure class="aligncenter"><figure class="wp-image-2729"><img loading="lazy"  src="https://ralfw.de/media/posts/136/DraggedImage-6.png" sizes="(max-width: 48em) 100vw, 768px" srcset="https://ralfw.de/media/posts/136/responsive/DraggedImage-6-xs.png 300w ,https://ralfw.de/media/posts/136/responsive/DraggedImage-6-sm.png 480w ,https://ralfw.de/media/posts/136/responsive/DraggedImage-6-md.png 768w ,https://ralfw.de/media/posts/136/responsive/DraggedImage-6-lg.png 1024w ,https://ralfw.de/media/posts/136/responsive/DraggedImage-6-xl.png 1360w ,https://ralfw.de/media/posts/136/responsive/DraggedImage-6-2xl.png 1600w"  alt="" width="491" height="330" /></figure></figure>
</div>
<p><!-- /wp:image --></p>
<p><!-- wp:paragraph --></p>
<p>In ihnen gibt es dann z.B. Produktionsketten:</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:image {"id":2724, "align": "center"} --></p>
<div class="wp-block-image">
<figure class="aligncenter"><figure class="wp-image-2724"><img loading="lazy"  src="https://ralfw.de/media/posts/136/DraggedImage-7.png" sizes="(max-width: 48em) 100vw, 768px" srcset="https://ralfw.de/media/posts/136/responsive/DraggedImage-7-xs.png 300w ,https://ralfw.de/media/posts/136/responsive/DraggedImage-7-sm.png 480w ,https://ralfw.de/media/posts/136/responsive/DraggedImage-7-md.png 768w ,https://ralfw.de/media/posts/136/responsive/DraggedImage-7-lg.png 1024w ,https://ralfw.de/media/posts/136/responsive/DraggedImage-7-xl.png 1360w ,https://ralfw.de/media/posts/136/responsive/DraggedImage-7-2xl.png 1600w"  alt="" width="362" height="112" /></figure></figure>
</div>
<p><!-- /wp:image --></p>
<p><!-- wp:paragraph --></p>
<p>oder es gibt Aggregations- bzw. Integrationsleistungen:</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:image {"id":2730, "align": "center"} --></p>
<div class="wp-block-image">
<figure class="aligncenter"><figure class="wp-image-2730"><img loading="lazy"  src="https://ralfw.de/media/posts/136/DraggedImage-8.png" sizes="(max-width: 48em) 100vw, 768px" srcset="https://ralfw.de/media/posts/136/responsive/DraggedImage-8-xs.png 300w ,https://ralfw.de/media/posts/136/responsive/DraggedImage-8-sm.png 480w ,https://ralfw.de/media/posts/136/responsive/DraggedImage-8-md.png 768w ,https://ralfw.de/media/posts/136/responsive/DraggedImage-8-lg.png 1024w ,https://ralfw.de/media/posts/136/responsive/DraggedImage-8-xl.png 1360w ,https://ralfw.de/media/posts/136/responsive/DraggedImage-8-2xl.png 1600w"  alt="" width="272" height="252" /></figure></figure>
</div>
<p><!-- /wp:image --></p>
<p><!-- wp:paragraph --></p>
<p>Kunden können mehrere Produzenten entlohnen:</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:image {"id":2735, "align": "center"} --></p>
<div class="wp-block-image">
<figure class="aligncenter"><figure class="wp-image-2735"><img loading="lazy"  src="https://ralfw.de/media/posts/136/DraggedImage-9.png" sizes="(max-width: 48em) 100vw, 768px" srcset="https://ralfw.de/media/posts/136/responsive/DraggedImage-9-xs.png 300w ,https://ralfw.de/media/posts/136/responsive/DraggedImage-9-sm.png 480w ,https://ralfw.de/media/posts/136/responsive/DraggedImage-9-md.png 768w ,https://ralfw.de/media/posts/136/responsive/DraggedImage-9-lg.png 1024w ,https://ralfw.de/media/posts/136/responsive/DraggedImage-9-xl.png 1360w ,https://ralfw.de/media/posts/136/responsive/DraggedImage-9-2xl.png 1600w"  alt="" width="278" height="317" /></figure></figure>
</div>
<p><!-- /wp:image --></p>
<p><!-- wp:paragraph --></p>
<p>und Produzenten können mehrere Kunden bedienen:</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:image {"id":2725, "align": "center"} --></p>
<div class="wp-block-image">
<figure class="aligncenter"><figure class="wp-image-2725"><img loading="lazy"  src="https://ralfw.de/media/posts/136/DraggedImage-10.png" sizes="(max-width: 48em) 100vw, 768px" srcset="https://ralfw.de/media/posts/136/responsive/DraggedImage-10-xs.png 300w ,https://ralfw.de/media/posts/136/responsive/DraggedImage-10-sm.png 480w ,https://ralfw.de/media/posts/136/responsive/DraggedImage-10-md.png 768w ,https://ralfw.de/media/posts/136/responsive/DraggedImage-10-lg.png 1024w ,https://ralfw.de/media/posts/136/responsive/DraggedImage-10-xl.png 1360w ,https://ralfw.de/media/posts/136/responsive/DraggedImage-10-2xl.png 1600w"  alt="" width="257" height="320" /></figure></figure>
</div>
<p><!-- /wp:image --></p>
<p><!-- wp:heading {"level":3} --></p>
<h3>Entlohnung auf Augenhöhe</h3>
<p><!-- /wp:heading --></p>
<p><!-- wp:paragraph --></p>
<p>Egal wie Interaktionsstrukturen zwischen „Marktteilnehmern“ aber aussehen, sie sind grundsätzlich auf Augenhöhe; alle Beteiligten sind selbstständig. Kunde und Produzent stehen in direktem Austausch: der Produzent liefert an den Kunden, der Kunde entlohnt den Produzenten. (Das gilt auch, wenn die Leistung des Produzenten im Handel besteht. Ich verstehe Produktion hier sehr allgemein als Aufwendung einer Mühe gegen Geld. Handeln macht auch Mühe.)</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Der Produzent bekommt „am Markt“ unmittelbares Feedback vom Kunden. Das kann in einer mehr oder weniger prompten oder vollständigen Entlohnung bestehen. Oder es wird als zusätzliche Schicht dem Lohnfluss hinzugefügt. Der Produzent wird nicht nur befriedigt, sondern kann sein Produkt dem Kunden - d.h. dem Bedarf, der Nachfrage - anpassen. Will der Produzent weiterhin und mehr Geschäfte mit Kunden machen, ist er gut beraten, dieses direkte Verhältnis auszunutzen. Sensibilität den Kundenwünschen gegenüber und prompte, hochqualitative Produktion helfen, die eigenen Bedürfnisse zu befriedigen.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Das unmittelbare Verhältnis auf Augenhöhe zwischen Produzent und Kunde speist sich aus intrinsischer Motivation beim Produzenten. Zu beobachten ist das sehr schön auf jedem Wochenmarkt.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Dies gilt auch für „B2B“-Interaktionen innerhalb von größeren Strukturen:<figure class="wp-image-2719"><img loading="lazy"  src="https://ralfw.de/media/posts/136/DraggedImage.tiff" alt="" /></figure>
<div class="wp-block-image">
<figure class="aligncenter"><figure class="wp-image-2745 size-full aligncenter"><img loading="lazy"  src="https://ralfw.de/media/posts/136/2019-09-11_13-28-47.png" sizes="(max-width: 48em) 100vw, 768px" srcset="https://ralfw.de/media/posts/136/responsive/2019-09-11_13-28-47-xs.png 300w ,https://ralfw.de/media/posts/136/responsive/2019-09-11_13-28-47-sm.png 480w ,https://ralfw.de/media/posts/136/responsive/2019-09-11_13-28-47-md.png 768w ,https://ralfw.de/media/posts/136/responsive/2019-09-11_13-28-47-lg.png 1024w ,https://ralfw.de/media/posts/136/responsive/2019-09-11_13-28-47-xl.png 1360w ,https://ralfw.de/media/posts/136/responsive/2019-09-11_13-28-47-2xl.png 1600w"  alt="" width="366" height="265" /></figure></figure>
</div>
<p><!-- /wp:image --></p>
<p><!-- wp:paragraph --></p>
<p>Zwar hat der Produzent hier nicht mit dem Endkunden zu tun, sondern „nur“ mit einem weiteren Produzenten. Doch im direkten Verhältnis ist das einerlei. Dem Produzenten von Schnürsenkeln ist ein Verkauf an Schuhhersteller prinzipiell genauso recht wie an Schuhkäufer. Der höheren Marge bei diesen stehen z.B. größere Abnahmemengen bei jenen gegenüber. Das will abgewogen werden. Am unmittelbaren Verhältnis zu beiden ändert das nichts.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:heading {"level":2} --></p>
<h2>Unternehmensstruktur</h2>
<p><!-- /wp:heading --></p>
<p><!-- wp:paragraph --></p>
<p>So weit die Verhältnisse zwischen „Marktteilnehmern“. Sie sind alle unmittelbar und somit intrinsisch auf Produktqualität konzentriert, die zum Preis passt, so dass die Bedürfnisse des Produzenten befriedigt werden.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Der Fokus ist hier auf dem Produzenten, weil der durch seine Bedürfnisse angetrieben wird, aktiv zu werden, d.h. Mühe aufzuwenden oder gar etwas zu produzieren und dafür Kunden zu finden. Der Produzent investiert Mühe in Hoffnung auf Lohn. (Dass Produkte dann Bedürfnisse bei Kunden befriedigen, wofür die willens sind, zu entlohnen, ist eine genauso valide Sicht. Ich nehme sie hier nur nicht ein. Das Henne-Ei-Probleme gehe ich einfach mal von der Henne, dem Produzenten aus an.)</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Unternehmen verstanden als Organisationen, d.h. soziale Systeme bestehend aus mehreren Menschen zum Zwecke der Produktion gegen Geld, haben nun eine interessante interne Struktur. Die ist ganz bewusst anders gestaltet als Strukturen zwischen Marktteilnehmern.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Unternehmen bestehen mindestens aus zwei Funktionskategorien. Ich will sie Führung und Operation nennen.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:image {"id":2721, "align": "center"} --></p>
<div class="wp-block-image">
<figure class="aligncenter"><figure class="wp-image-2721"><img loading="lazy"  src="https://ralfw.de/media/posts/136/DraggedImage-11.png" sizes="(max-width: 48em) 100vw, 768px" srcset="https://ralfw.de/media/posts/136/responsive/DraggedImage-11-xs.png 300w ,https://ralfw.de/media/posts/136/responsive/DraggedImage-11-sm.png 480w ,https://ralfw.de/media/posts/136/responsive/DraggedImage-11-md.png 768w ,https://ralfw.de/media/posts/136/responsive/DraggedImage-11-lg.png 1024w ,https://ralfw.de/media/posts/136/responsive/DraggedImage-11-xl.png 1360w ,https://ralfw.de/media/posts/136/responsive/DraggedImage-11-2xl.png 1600w"  alt="" width="339" height="443" /></figure></figure>
</div>
<p><!-- /wp:image --></p>
<p><!-- wp:paragraph --></p>
<p>Die Operation wendet die Mühe auf, um Kunden zu befriedigen. Und die Führung definiert die Rahmenbedingungen dafür. Vor allem aber ist die Führung in meiner Betrachtung die Funktion, die das Geld des Kunden empfängt! (Nicht persönlich, aber stellvertretend für das Unternehmen.)</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:quote --></p>
<blockquote class="wp-block-quote">
<p>Das ist zentral: Die Operation leistet und die Führung kassiert.</p>
</blockquote>
<p><!-- /wp:quote --></p>
<p><!-- wp:paragraph --></p>
<p>Von außen ist das nicht sichtbar. Dem Kunden tritt das Unternehmen als Black Box entgegen. Er soll gewöhnlich nichts über seine Struktur wissen. Solange das Unternehmen ein preis-wertes Produkt liefert, bezahlt er den Preis. Der Kunde sieht im Grunde keinen Unterschied zwischen einem Unternehmen oder einem Einzelunternehmer/Freelancer, wo Führung und Operation in einer Person zusammenfallen.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:image {"id":2732, "align": "center"} --></p>
<div class="wp-block-image">
<figure class="aligncenter"><figure class="wp-image-2732"><img loading="lazy"  src="https://ralfw.de/media/posts/136/DraggedImage-12.png" sizes="(max-width: 48em) 100vw, 768px" srcset="https://ralfw.de/media/posts/136/responsive/DraggedImage-12-xs.png 300w ,https://ralfw.de/media/posts/136/responsive/DraggedImage-12-sm.png 480w ,https://ralfw.de/media/posts/136/responsive/DraggedImage-12-md.png 768w ,https://ralfw.de/media/posts/136/responsive/DraggedImage-12-lg.png 1024w ,https://ralfw.de/media/posts/136/responsive/DraggedImage-12-xl.png 1360w ,https://ralfw.de/media/posts/136/responsive/DraggedImage-12-2xl.png 1600w"  alt="" width="268" height="180" /></figure></figure>
</div>
<p><!-- /wp:image --></p>
<p><!-- wp:paragraph --></p>
<p>Doch diese andersartige Struktur von Unternehmen intern macht einen gewichtigen Unterschied!</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:quote --></p>
<blockquote class="wp-block-quote">
<p>Innerhalb von Unternehmen gibt es keinen Markt.</p>
</blockquote>
<p><!-- /wp:quote --></p>
<p><!-- wp:paragraph --></p>
<p>Bedürfnisbefriedigung (vermittelt durch Lohn), gibt es nur grundsätzlich gegen Mühe, also eine Leistung. Und die wird immer erbracht gegenüber dem Entlohner. Warum sonst sollte der auch entlohnen?</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Genauer betrachtet sehen die Verhältnisse in Unternehmen daher so aus:</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:image {"id":2727, "align": "center"} --></p>
<div class="wp-block-image">
<figure class="aligncenter"><figure class="wp-image-2727"><img loading="lazy"  src="https://ralfw.de/media/posts/136/DraggedImage-13.png" sizes="(max-width: 48em) 100vw, 768px" srcset="https://ralfw.de/media/posts/136/responsive/DraggedImage-13-xs.png 300w ,https://ralfw.de/media/posts/136/responsive/DraggedImage-13-sm.png 480w ,https://ralfw.de/media/posts/136/responsive/DraggedImage-13-md.png 768w ,https://ralfw.de/media/posts/136/responsive/DraggedImage-13-lg.png 1024w ,https://ralfw.de/media/posts/136/responsive/DraggedImage-13-xl.png 1360w ,https://ralfw.de/media/posts/136/responsive/DraggedImage-13-2xl.png 1600w"  alt="" width="321" height="338" /></figure></figure>
</div>
<p><!-- /wp:image --></p>
<p><!-- wp:paragraph --></p>
<p>Ich möchte fast sagen:</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:quote --></p>
<blockquote class="wp-block-quote">
<p>Die Verhältnisse in Unternehmen sind systematisch „widernatürlich“.</p>
</blockquote>
<p><!-- /wp:quote --></p>
<p><!-- wp:paragraph --></p>
<p>Die ursprüngliche Selbstständigkeit ist verschwunden. Sie ist ja erkennbar an der unmittelbaren Produkt-gegen-Lohn-Beziehung. In Unternehmen existiert die jedoch nicht.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:quote --></p>
<blockquote class="wp-block-quote">
<p>Lohn gibt es in Unternehmen nicht für Produkte! Lohn gibt es für die Einhaltung eines Arbeitsvertrags.</p>
</blockquote>
<p><!-- /wp:quote --></p>
<p><!-- wp:paragraph --></p>
<p>Im Arbeitsvertrag stecken zwar irgendwie die Produkte, aber mehr nicht, nur irgendwie.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:list {"ordered":false} --></p>
<ul>
<li>Der, der Mühe aufwendet, bekommt dafür keinen unmittelbaren Lohn vom Kunden. Die Feedbackschleife ist unterbrochen.</li>
<li>Der, der entlohnt wird, hat dafür nichts direkt geleistet. Die Feedbackschleife ist unterbrochen.</li>
<li>Der Lohn für die Mühe der Operation kommt intern von der Führung. Aber was bekommt die Führung dafür? Die Feedbackschleife ist unterspezifiziert.</li>
</ul>
<p><!-- /wp:list --></p>
<p><!-- wp:paragraph --></p>
<p>Damit sollte klar sein, dass es interne Kunden in Unternehmen per definitionem nicht geben kann. Egal, was ein Angestellter für einen anderen leistet, nie zahlt dieser jenem einen Lohn dafür.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Noch schlimmer werden die Verhältnisse, wenn die Unternehmensstruktur sich weiter ausdifferenziert, d.h. die Produktionskette länger wird und deshalb vermeintlich darüber eine Führungshierarchie aufgerichtet werden muss:</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:image {"id":2739, "align": "center"} --></p>
<div class="wp-block-image">
<figure class="aligncenter"><figure class="wp-image-2739"><img loading="lazy"  src="https://ralfw.de/media/posts/136/DraggedImage-14.png" sizes="(max-width: 48em) 100vw, 768px" srcset="https://ralfw.de/media/posts/136/responsive/DraggedImage-14-xs.png 300w ,https://ralfw.de/media/posts/136/responsive/DraggedImage-14-sm.png 480w ,https://ralfw.de/media/posts/136/responsive/DraggedImage-14-md.png 768w ,https://ralfw.de/media/posts/136/responsive/DraggedImage-14-lg.png 1024w ,https://ralfw.de/media/posts/136/responsive/DraggedImage-14-xl.png 1360w ,https://ralfw.de/media/posts/136/responsive/DraggedImage-14-2xl.png 1600w"  alt="" width="374" height="240" /></figure></figure>
</div>
<p><!-- /wp:image --></p>
<p><!-- wp:paragraph --></p>
<p>Positionen tiefer in der Hierarchie und weiter vom Kunden entfernt rücken von der grundsätzlichen Produzent-Kunde-Beziehung immer weiter ab. Sie sind aus der natürlichen Feedbackschleife ausgekoppelt. Ihre Leistungsbeziehungen haben weniger und weniger mit dem Kunden des Unternehmens zu tun, sondern sind zunehmend rein intern. Selbstbeschäftigung entsteht, die man Bürokratie nennen kann. Arbeit wird nicht horizontal auf das Produkt fokussiert, sondern vertikal auf die Hierarchie im Unternehmen.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Intern fließt das Geld nicht mehr aus Richtung des Kunden zurück durch die Operationsstruktur. Darin gibt es keine intrinsische Motivation in Bezug auf das Produkt, jedenfalls keine natürliche durch Geld motivierte. Denn das Geld kommt nicht „von vorne“, d.h. Operationseinheiten downstream zum Kunden hin. Das Geld kommt ausschließlich von oben. Es gibt ja keinen Markt.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Und wofür gibt es Geld von oben? In der Führungshierarchie sitzen keine Kunden, die am Produkt interessiert sind.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Gegenüber der Führungshierarchie ist nicht die Mühe entscheidend, die ins Produkt gesteckt wird, sondern die Mühe, die gegenüber der Führungskraft aufgewandt wird. Diese Mühe jedoch ist eine kategorial andere als die, die ins Produkt geht.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Das „Produkt“ gegenüber Führung ist nicht das Produkt, das zum Kunden fließt, sondern… Gehorsam: Gehorsam gegenüber Regeln - ausgesprochenen und unausgesprochenen - und Metriken.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:quote --></p>
<blockquote class="wp-block-quote">
<p>Für Gehorsam wird Lohn an abhängig Beschäftigte gezahlt.</p>
</blockquote>
<p><!-- /wp:quote --></p>
<p><!-- wp:paragraph --></p>
<p>Angestellte sind abhängig Beschäftigte, weil sie eben keine Freiheit besitzen, ihre Leistung auf einem Markt anzubieten, sobald sie sich einem Unternehmen per Anstellungsvertrag verpflichtet haben; sie sind eben nicht selbstständig. Das Produkt ihrer Mühe und die Empfänger ihrer Mühe werden durch die Führung vorgegeben; dafür werden sie entlohnt. Angestellte sind also zuallererst Weisungsempfänger der Unternehmensführungshierarchie.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Der Begriff „Gehorsam“ wird Ihnen aufstoßen. Ich habe ihn aber mit Bedacht gewählt, um genau dieses gedankliche Stolpern zu erzeugen. Er soll wachrütteln; er soll die Augen öffnen für die wahren Verhältnisse innerhalb von Unternehmen. Wenn er Ihnen aber zu quer sitzt, ersetzen sie ihn durch „compliance“; Englisch klingt das Verhältnis vielleicht etwas businessmäßiger, weniger deutsch-historisch beladen. Aber machen wir uns nichts vor: Solange von disziplinarischen Vorgesetzten gesprochen wird, geht es auch noch um Disziplin und Gehorsam.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Es gibt unternehmensintern keine Kunden, auch wenn der „interne Kunden“ noch so sehr beschworen wird, um irgendwie marktähnliche Verhältnisse zu suggerieren.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Es gibt unternehmensintern keine intrinsische Motivation, ein Produkt zu verbessern. Jedenfalls keine, die durch Geld vom Kunden motiviert würde. Es fehlt schlicht die direkte Beziehung zu ihm. Einzige Ausnahme vielleicht: der Operationsaspekt „Verkauf“. Deshalb gibt es dort auch durchaus erhebliche Provisionen. (Allerdings ist der Verkauf dann wieder von der Produktion entkoppelt. Das macht die Sache also nur vordergründig besser.)</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Es gibt unternehmensintern lediglich die Motivation genügend zu tun, um als pflichtbewusst (aka gehorsam) beurteil zu werden – damit der Lohn weiterhin fließt.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Umso mehr gilt das aus meiner Sicht, je größer die Unternehmensstruktur ist und je weiter innen Mitarbeiter in ihr angesiedelt sind.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Das bedeutet im Umkehrschluss: die Kunst der Führung besteht in der Motivation der Mitarbeiter in einer Weise, dass deren Mühe Produkte von hoher Qualität herstellt, obwohl (!) das Hauptaugenmerk aller Mitarbeiter auf der Beziehung zur Führung liegt und nicht auf der zum Kunden bzw. anderen Mitarbeitern downstream Richtung Kunde.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:quote --></p>
<blockquote class="wp-block-quote">
<p>Regeln und Metriken müssen so gewählt werden, dass pflichtschuldiger Gehorsam preis-werte Produkte hervorbringt.</p>
</blockquote>
<p><!-- /wp:quote --></p>
<p><!-- wp:paragraph --></p>
<p>Und nicht nur das! Denn Produkte sind nicht die einzige Leistung von Mitarbeitern. Sie sollen darüber hinaus auch noch etwas anderes herstellen: Veränderungen. Mitarbeiter sollen gerade heute ja auch innovativ sein und willig und fähig, „Change“ aller Art mitzumachen.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Das Kunststück von Führung wird mit jedem Tag größer, würde ich sagen. Geradezu unglaublich, dass Unternehmen überhaupt so funktionieren. Ja, wie kann das sein?</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Ich glaube, es liegt an der Vielschichtigkeit von Lohn. Abhängig Beschäftigte empfangen nicht-monetären Lohn im Rahmen der Unternehmensstruktur und auch von außerhalb aus vielen Richtungen.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:image {"id":2733, "align": "center"} --></p>
<div class="wp-block-image">
<figure class="aligncenter"><figure class="wp-image-2733"><img loading="lazy"  src="https://ralfw.de/media/posts/136/DraggedImage-15.png" sizes="(max-width: 48em) 100vw, 768px" srcset="https://ralfw.de/media/posts/136/responsive/DraggedImage-15-xs.png 300w ,https://ralfw.de/media/posts/136/responsive/DraggedImage-15-sm.png 480w ,https://ralfw.de/media/posts/136/responsive/DraggedImage-15-md.png 768w ,https://ralfw.de/media/posts/136/responsive/DraggedImage-15-lg.png 1024w ,https://ralfw.de/media/posts/136/responsive/DraggedImage-15-xl.png 1360w ,https://ralfw.de/media/posts/136/responsive/DraggedImage-15-2xl.png 1600w"  alt="" width="417" height="276" /></figure></figure>
</div>
<p><!-- /wp:image --></p>
<p><!-- wp:paragraph --></p>
<p>Allerdings dort, wo es diesen inoffiziellen „lohnenden Rückfluss“ nicht gibt… da allemal droht mindere Produktivität durch Dienst nach Vorschrift, Unachtsamkeit und mangelnde Qualität oder gar Burn-Out.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Und da, wo inoffizieller, unsichtbarer Lohn fließt, sind die Verhältnisse nur schwer zu kontrollieren. Denn wo ansetzen mit einer Intervention, wenn sich etwas verändern soll? Die Situation ist gerade dann sehr komplex, weil die Motivationsverhältnisse unklar sind.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>In einer Tayloristischen Organisation, die nur über Geld motivieren will, steckt also schon einige Weisheit. Nur funktioniert es nicht (mehr) so. Weil die Angestellten mehr wollen als Geld. Weil die Kunden mehr wollen, als die Qualität und die Reaktionsfähigkeit, die solche simplifizierten Unternehmen herstellen können.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:heading {"level":3} --></p>
<h3>Der Zielkonflikt</h3>
<p><!-- /wp:heading --></p>
<p><!-- wp:paragraph --></p>
<p>Der Zielkonflikt besteht zwischen den zwei Empfängern von Mühe, denen sich jeder Mitarbeiter gegenüber sieht.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:list {"ordered":false} --></p>
<ul>
<li>Soll er sich für den Kunden Mühe geben, sich downstream orientieren?</li>
<li>Oder soll er sich für die Führungshierarchie Mühe geben, sich orthogonal zum Produktionsfluss orientieren?</li>
</ul>
<p><!-- /wp:list --></p>
<p><!-- wp:paragraph --></p>
<p>Das ist nicht dasselbe, auch wenn sich Führung darum bemüht oder etwas anderes suggeriert. Es gibt den Winkel ϕ immer. Fragt sich nur, wie klein ihn Führung machen kann.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:image {"id":2720, "align": "center"} --></p>
<div class="wp-block-image">
<figure class="aligncenter"><figure class="wp-image-2720"><img loading="lazy"  src="https://ralfw.de/media/posts/136/DraggedImage-16.png" sizes="(max-width: 48em) 100vw, 768px" srcset="https://ralfw.de/media/posts/136/responsive/DraggedImage-16-xs.png 300w ,https://ralfw.de/media/posts/136/responsive/DraggedImage-16-sm.png 480w ,https://ralfw.de/media/posts/136/responsive/DraggedImage-16-md.png 768w ,https://ralfw.de/media/posts/136/responsive/DraggedImage-16-lg.png 1024w ,https://ralfw.de/media/posts/136/responsive/DraggedImage-16-xl.png 1360w ,https://ralfw.de/media/posts/136/responsive/DraggedImage-16-2xl.png 1600w"  alt="" width="584" height="282" /></figure></figure>
</div>
<p><!-- /wp:image --></p>
<p><!-- wp:paragraph --></p>
<p>Im Zweifelsfall siegt denn auch die Mühe gegenüber der Führung. Die Oberhand wird im offensichtlichen Konfliktfall der Gehorsam haben. Helden sind einfach so selten. Gehorsam einen Kundenwunsch nicht zu erfüllen findet im Verhältnis mehr Akzeptanz (bei der disziplinarisch relevanten und belohnenden Führung) als ungehorsam nicht belohnende Kunden zufrieden zu stellen.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Wann immer es heißt „Da kann ich Ihnen leider nicht helfen, das ist bei uns so Vorschrift.“ sollte das sonnenklar sein. Behörden und große Unternehmen sind dafür bekannt. Aber auch bei kleinen Unternehmen kann man solche Antworten erhalten.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Die Aufgabe von Führung besteht nun darin, würde ich sagen, den Winkel (ϕ für „Führungswinkel“) zwischen den „Zielrichtungen“ möglichst klein zu gestalten. Je weniger „in Linie“ (aligned) die Mühe in Richtung Hierarchie mit der Mühe in Richtung Kunde (downstream) ist, desto weniger Energie kommt dem Unternehmensprodukt zugute.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:image {"id":2740, "align": "center"} --></p>
<div class="wp-block-image">
<figure class="aligncenter"><figure class="wp-image-2740"><img loading="lazy"  src="https://ralfw.de/media/posts/136/DraggedImage-17.png" sizes="(max-width: 48em) 100vw, 768px" srcset="https://ralfw.de/media/posts/136/responsive/DraggedImage-17-xs.png 300w ,https://ralfw.de/media/posts/136/responsive/DraggedImage-17-sm.png 480w ,https://ralfw.de/media/posts/136/responsive/DraggedImage-17-md.png 768w ,https://ralfw.de/media/posts/136/responsive/DraggedImage-17-lg.png 1024w ,https://ralfw.de/media/posts/136/responsive/DraggedImage-17-xl.png 1360w ,https://ralfw.de/media/posts/136/responsive/DraggedImage-17-2xl.png 1600w"  alt="" width="587" height="214" /></figure></figure>
</div>
<p><!-- /wp:image --></p>
<p><!-- wp:paragraph --></p>
<p>Das funktioniert umso besser, je mehr Führung tatsächlich „hinter dem Kunden steht“. Poster an der Wand mit markigen Sprüchen, sind dafür allerdings ungenügende Lippenbekenntnisse.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:heading {"level":3} --></p>
<h3>Abteilungen vs. Prozesse</h3>
<p><!-- /wp:heading --></p>
<p><!-- wp:paragraph --></p>
<p>Umso größer ist das Gewicht des Gehorsams für die täglichen Entscheidungen jedes Mitarbeiters, je vertikaler ein Unternehmen organisiert ist. Wo Abteilungen die vordringliche Organisationsform sind, wird schlicht informelles Feedback unterdrückt. Und auch der Produktionsfluss muss immer wieder Barrieren überwinden.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:image {"id":2726, "align": "center"} --></p>
<div class="wp-block-image">
<figure class="aligncenter"><figure class="wp-image-2726"><img loading="lazy"  src="https://ralfw.de/media/posts/136/DraggedImage-18.png" sizes="(max-width: 48em) 100vw, 768px" srcset="https://ralfw.de/media/posts/136/responsive/DraggedImage-18-xs.png 300w ,https://ralfw.de/media/posts/136/responsive/DraggedImage-18-sm.png 480w ,https://ralfw.de/media/posts/136/responsive/DraggedImage-18-md.png 768w ,https://ralfw.de/media/posts/136/responsive/DraggedImage-18-lg.png 1024w ,https://ralfw.de/media/posts/136/responsive/DraggedImage-18-xl.png 1360w ,https://ralfw.de/media/posts/136/responsive/DraggedImage-18-2xl.png 1600w"  alt="" width="562" height="424" /></figure></figure>
</div>
<p><!-- /wp:image --></p>
<p><!-- wp:paragraph --></p>
<p>Eine Rückkopplung entlang des Produktionsflusses ist hier schwierig. Eine Operation im Sinne kundenorientierter Prozesse existiert quasi nicht. Wie soll da auch noch immaterieller Lohn upstream schwimmen?</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Das ist umso schlimmer, je mehr die Produktion nicht nur „durch Wände“ arbeiten muss, sondern auch noch die Hierarchie entlang. Führungskräfte sind gern mal in Doppelrollen unterwegs als „Expertenfachkraft“ plus Führungskraft. (Verständlich ist das, da ja oft Führungskräfte früher tiefer in der Hierarchie als operierende Fachkraft tätig waren. Davon kann man später nur schwer die Finger lassen. Allemal scheint aber auch die Einmischung in die Produktion dem Bild nach oben zu dienen. Ist das nicht pflichtschuldiges Handeln, Dinge zu kontrollieren und anzuweisen?)</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:image {"id":2722, "align": "center"} --></p>
<div class="wp-block-image">
<figure class="aligncenter"><figure class="wp-image-2722"><img loading="lazy"  src="https://ralfw.de/media/posts/136/DraggedImage-19.png" sizes="(max-width: 48em) 100vw, 768px" srcset="https://ralfw.de/media/posts/136/responsive/DraggedImage-19-xs.png 300w ,https://ralfw.de/media/posts/136/responsive/DraggedImage-19-sm.png 480w ,https://ralfw.de/media/posts/136/responsive/DraggedImage-19-md.png 768w ,https://ralfw.de/media/posts/136/responsive/DraggedImage-19-lg.png 1024w ,https://ralfw.de/media/posts/136/responsive/DraggedImage-19-xl.png 1360w ,https://ralfw.de/media/posts/136/responsive/DraggedImage-19-2xl.png 1600w"  alt="" width="572" height="338" /></figure></figure>
</div>
<p><!-- /wp:image --></p>
<p><!-- wp:paragraph --></p>
<p>Anders ist das, wenn Produktionsprozesse im Vordergrund stehen.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:image {"id":2734, "align": "center"} --></p>
<div class="wp-block-image">
<figure class="aligncenter"><figure class="wp-image-2734"><img loading="lazy"  src="https://ralfw.de/media/posts/136/DraggedImage-20.png" sizes="(max-width: 48em) 100vw, 768px" srcset="https://ralfw.de/media/posts/136/responsive/DraggedImage-20-xs.png 300w ,https://ralfw.de/media/posts/136/responsive/DraggedImage-20-sm.png 480w ,https://ralfw.de/media/posts/136/responsive/DraggedImage-20-md.png 768w ,https://ralfw.de/media/posts/136/responsive/DraggedImage-20-lg.png 1024w ,https://ralfw.de/media/posts/136/responsive/DraggedImage-20-xl.png 1360w ,https://ralfw.de/media/posts/136/responsive/DraggedImage-20-2xl.png 1600w"  alt="" width="577" height="299" /></figure></figure>
</div>
<p><!-- /wp:image --></p>
<p><!-- wp:paragraph --></p>
<p>Hier hat immaterielles Feedback eine Chance, zu befriedigen und zu motivieren. Cross-funktionale, kundenorientierte Organisation hilft, die negativen Effekte von Hierarchien zu mildern.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>And now for something completely different… (or maybe not)</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:heading {"level":2} --></p>
<h2>Die Hierarchie des Lernens</h2>
<p><!-- /wp:heading --></p>
<p><!-- wp:paragraph --></p>
<p>Natürliches, intrinsisch motiviertes Lernen findet unmittelbar gegenüber den Lerngegenstand statt:</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:image {"id":2731, "align": "center"} --></p>
<div class="wp-block-image">
<figure class="aligncenter"><figure class="wp-image-2731"><img loading="lazy"  src="https://ralfw.de/media/posts/136/DraggedImage-21.png" sizes="(max-width: 48em) 100vw, 768px" srcset="https://ralfw.de/media/posts/136/responsive/DraggedImage-21-xs.png 300w ,https://ralfw.de/media/posts/136/responsive/DraggedImage-21-sm.png 480w ,https://ralfw.de/media/posts/136/responsive/DraggedImage-21-md.png 768w ,https://ralfw.de/media/posts/136/responsive/DraggedImage-21-lg.png 1024w ,https://ralfw.de/media/posts/136/responsive/DraggedImage-21-xl.png 1360w ,https://ralfw.de/media/posts/136/responsive/DraggedImage-21-2xl.png 1600w"  alt="" width="330" height="162" /></figure></figure>
</div>
<p><!-- /wp:image --></p>
<p><!-- wp:paragraph --></p>
<p>Der Lohn der Mühe besteht in positivem Feedback. Neugierde wird befriedigt, Wissen wird gewonnen, Fähigkeiten werden erworben.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Lernen verändert sich jedoch grundsätzlich, wenn der Lernstoff erstens nicht selbst gewählt ist und zweitens das Feedback in Form von Zensuren gegeben wird. Lernen in der Schule ist eine ganz eigene Sache:</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:image {"id":2717, "align": "center"} --></p>
<div class="wp-block-image">
<figure class="aligncenter"><figure class="wp-image-2717"><img loading="lazy"  src="https://ralfw.de/media/posts/136/DraggedImage-22.png" sizes="(max-width: 48em) 100vw, 768px" srcset="https://ralfw.de/media/posts/136/responsive/DraggedImage-22-xs.png 300w ,https://ralfw.de/media/posts/136/responsive/DraggedImage-22-sm.png 480w ,https://ralfw.de/media/posts/136/responsive/DraggedImage-22-md.png 768w ,https://ralfw.de/media/posts/136/responsive/DraggedImage-22-lg.png 1024w ,https://ralfw.de/media/posts/136/responsive/DraggedImage-22-xl.png 1360w ,https://ralfw.de/media/posts/136/responsive/DraggedImage-22-2xl.png 1600w"  alt="" width="337" height="367" /></figure></figure>
</div>
<p><!-- /wp:image --></p>
<p><!-- wp:paragraph --></p>
<p>Wie beim abhängig Beschäftigten ist hier das natürliche Verhältnis aufgebrochen: der Lohn für die Mühe kommt nicht aus der Sache, sondern aus einer anderen Quelle, dem Lehrer. Und es wird dafür eine „Währung“ eingeführt: Zensuren.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Die Verhältnisse ähneln denen in Unternehmen. Es gibt eine Hierarchie, die in die natürlichen, unmittelbaren Verhältnisse eine Indirektion einführt. Dort stellt sich dem Feedback Führung in den Weg, hier der Lehrer.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Und auch in der Schule stellt sich die Frage, was die Mühe des Schülers gegenüber dem Lehrer ausmacht.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Die Mühe des Schülers besteht in angepasstem, zensurenoptimierendem Verhalten. Zensuren sind ja nicht nur das Produkt solider Kompetenz, wie die Schule es sich vielleicht wünscht. Nein, Zensuren können optimiert werden durch spezielles Verhalten, das nichts mit der Beherrschung des Lernstoffs zu tun hat. Das kann explizit gegenüber dem Lehrer sein; das kann aber auch darin bestehen, mit dem Lernstoff in bestimmter Weise umzugehen. Wer für gute Zensuren lernt, der lernt anders als für „Lebenskompetenz“.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Allemal wird diese Zensurenoptimierung plausibel, wenn man die Umwelt einbezieht, die in Zensuren belohnenswerte Mühe sieht:</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:image {"id":2728, "align": "center"} --></p>
<div class="wp-block-image">
<figure class="aligncenter"><figure class="wp-image-2728"><img loading="lazy"  src="https://ralfw.de/media/posts/136/DraggedImage-23.png" sizes="(max-width: 48em) 100vw, 768px" srcset="https://ralfw.de/media/posts/136/responsive/DraggedImage-23-xs.png 300w ,https://ralfw.de/media/posts/136/responsive/DraggedImage-23-sm.png 480w ,https://ralfw.de/media/posts/136/responsive/DraggedImage-23-md.png 768w ,https://ralfw.de/media/posts/136/responsive/DraggedImage-23-lg.png 1024w ,https://ralfw.de/media/posts/136/responsive/DraggedImage-23-xl.png 1360w ,https://ralfw.de/media/posts/136/responsive/DraggedImage-23-2xl.png 1600w"  alt="" width="521" height="376" /></figure></figure>
</div>
<p><!-- /wp:image --></p>
<p><!-- wp:heading {"level":3} --></p>
<h3>Der Zielkonflikt</h3>
<p><!-- /wp:heading --></p>
<p><!-- wp:paragraph --></p>
<p>Der Zielkonflikt beim schulischen Lernen besteht im Lernen für gute Zensuren vs Lernen für’s Leben, d.h. für echte Kompetenz und Retention.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Eine gute oder schlechte Zensur - allemal für einen nicht selbst gewählten Lernstoff - ist etwas anderes, als das unmittelbare Feedback, wenn man sich an einem selbst gewählten Problem versucht.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Das hat man in der Schule inzwischen auch durchaus erkannt. Fächerübergreifendes, projektbezogenes Lernen nimmt zu, um die Motivation durch Steigerung der Relevanzempfindung zu erhöhen und das Behalten durch Vernetzung verschiedener Sinneskanäle und Themen zu fördern. Auch Zensuren scheinen hier und da auf dem Rückzug.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Einstweilen jedoch sind Zensuren noch das vorherrschende Mittel für Feedback, mündliche wie schriftliche. Und damit befinden sich Lernende in einem irreführenden und kräftezehrenden Zielkonflikt.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Aber vielleicht soll der sie auf die Unternehmenswelt vorbereiten?</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:heading {"level":2} --></p>
<h2>Zusammenfassung</h2>
<p><!-- /wp:heading --></p>
<p><!-- wp:paragraph --></p>
<p>Mir scheint das wesentliche Merkmal eines Marktes die Freiwilligkeit und Selbstständigkeit. Austauschbeziehungen entstehen, wo Befriedigung möglich erscheint. Qualität entsteht, um Befriedigung aufrecht zu erhalten.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Wird der Markt jedoch ausgehebelt und die darin herrschenden unmittelbaren Beziehungen gekappt, d.h. werden die Freiheit beschränkt und die natürliche Feedbackschleife unterbrochen, dann sinkt die Qualität der Produkte. Und nicht nur die Qualität sinkt, es sinkt auch die Motivation in Bezug auf die Produkte. Der Blick wendet sich ab vom Empfänger der Produkte hin zum Belohnenden.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Es entsteht Verschwendung.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Statt die Mühe, d.h. die aufgewandte Energie wie einen Laser zu fokussieren, strahlt man sie in verschiedene Richtungen. Ohne „Marktverhältnisse“ werden Menschen allzu leicht zu Glühbirnen – die auch mal durchbrennen.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Eine Gesellschaft, die ganz allgemein immer weniger Gehorsam als Wert hat, die diskursiv sein will, kann sich an solchen hierarchischen Verhältnissen nur reiben. Die Menschen und auch die Aufgaben im Rahmen komplexer Produkte sind nicht mehr so, dass per Gehorsam die Energie vor allem der Sache zugute kommen würde.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Solange die Not des Einzelnen groß ist und die Sache einfach, mag es funktionieren. Beides ist aber nicht mehr der Fall. Deshalb hat aus meiner Sicht die disziplinarische Hierarchie, allemal die große, ausgedient.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Und was ist die Alternative?</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Kleinere Einheiten. Unmittelbarere Verhältnisse. Aufgabe des Kontrollwahns.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Unternehmen wollen durch den Aufbau der internen Hierarchie etwas sparen und etwas gewinnen: weniger Transaktionskosten, die sie am Markt hätten, mehr Kontrolle, die sie am Markt nicht hätten. Das ist verständlich und funktioniert – aber eben nur bis zu einem gewissen Grad.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Hier gespartes Geld und gewonnene Kontrolle werden dort bezahlt mit zunehmender Inflexibilität, abnehmender Motivation, sinkender Qualität, untreuer Kundschaft.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Ich glaube, da hilft nur ein Umdenken: Das, was man als lästige Kosten am Markt ansieht, was man als Kontrollmangel empfindet, ist Schmierstoff, der flexibel hält. Und es ist nicht mehr Effizienz, an der es mangelt, sondern Flexibilität.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Es wäre schön, wenn Unternehmen wie Schulen sich wieder mehr auf die natürlichen, nährenden, motivierenden Beziehungen besinnen würden. Das sind für mich die, in denen der primäre Austausch stattfindet: beim Unternehmen der mit dem Kunden, beim Schüler der mit dem Lehrstoff.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Menschen sind willig zur Veränderung, wenn sie fühlen, dass das Sinn macht. Und Sinn macht, was erleichtert, Lohn zur Befriedigung der eigenen Bedürfnisse zu erhalten. Das bedeutet für mich im Umkehrschluss: Veränderungen funktionieren vor allem in Bezug auf lohnenswerte Mühe. Wer Veränderungen bei anderen anstoßen will, muss sich daher erstmal im Klaren darüber werden, welche Beziehungen die als lohnenswert empfinden – und ob das dieselben sind, die verändert werden sollen.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Sind das nicht dieselben, besteht ein Konflikt, der Leistungen und Veränderungen am Ziel vorbeischießen lässt.</p>
<p><!-- /wp:paragraph --></p>

            ]]>
        </content>
    </entry>
    <entry>
        <title>Hamburg Style TDD - Bank Kata</title>
        <author>
            <name>Ralf Westphal</name>
        </author>
        <link href="https://ralfw.de/hamburg-style-tdd-bank-kata/"/>
        <id>https://ralfw.de/hamburg-style-tdd-bank-kata/</id>
            <category term="TDD"/>

        <updated>2021-01-28T17:33:34+08:00</updated>
            <summary>
                <![CDATA[
                    There are already a few different styles of TDD out there. Still, though, my feeling is something is missing in the realm of test-first or test-driven development. I tried to explain that in my posting introducing the „Hamburg style TDD“. And then I showed what&hellip;
                ]]>
            </summary>
        <content type="html">
            <![CDATA[
                <p><!-- wp:paragraph --></p>
<p>There are already a few different styles of TDD out there. Still, though, my feeling is something is missing in the realm of test-first or test-driven development. I tried to explain that in my posting introducing the „<a href="https://ralfw.de/hamburg-style-tdd/">Hamburg style TDD</a>“. And then I showed what that meant in practice in a second article <a href="https://ralfw.de/hamburg-style-tdd-diamond-kata/">applied to the Diamond kata</a>.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>But knowing how hard it is to get the nuances (or even the obvious aspects) of a method across in writing (or with a video), I think I need to provide more examples of the application of Hamburg style TDD.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>As a second example I’m choosing the kata Macro Emrich used to compare the established TDD styles: the Bank kata. If you like, check out Marco’s code samples in <a href="https://www.dropbox.com/s/94k73jylzprcbss/schools_of_tdd.pdf?dl=0" target="_blank" rel="nofollow noopener noreferrer">this presentation</a> he did at the <a href="https://www.developer-week.de/" target="_blank" rel="nofollow noopener noreferrer">DWX 2019 conference</a>.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Following I’ll share my version of the kata like I did with the Diamond kata. It differs from the Diamond kata in quite some aspects. Problem solving requires some breadth of approaches. Red-green-refactor + KISS is too simplistic.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:heading {"level":2} --></p>
<h2>Problem description</h2>
<p><!-- /wp:heading --></p>
<p><!-- wp:paragraph --></p>
<p>This is what I’ve distilled from descriptions of the Bank kata I found on the web. It’s a bit more specific than usual, I guess. But I like it that way. Without specific requirements software development is bound to become even more complex.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>An excerpt from my in-project <code>.md</code> documentation of my „stream of consciousness“ while working on the problem:</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:code --></p>
<pre class="wp-block-code"><code>A user should be able to deposit/withdraw funds from a bank 
account (object).
At any time a statement can be "printed" (requested) listing the 
timestamped transactions and the updated account balance.

Example:

`
Date       Amount  Balance
1.7.2019    +1000     1000
2.7.2019     -200      800
3.7.2019     +500     1300
`

Integer amounts are sufficient as are transaction timestamps with dates only.

No transaction is rejected, even if it leads to a negative account balance.
</code></pre>
<p><!-- /wp:code --></p>
<p><!-- wp:heading {"level":2} --></p>
<p> </p>
<h2>1. Analysis</h2>
<p><!-- /wp:heading --></p>
<p><!-- wp:paragraph --></p>
<p>With the problem description in hand I sit down and analyze it. I log my thoughts in a <code>.md</code> file. (The more I do that, the more I like it. It makes my thinking open for scrutiny.)</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:code --></p>
<pre class="wp-block-code"><code>## Analysis
Essentially the problem is about an event stream for which a report 
is generated.

There are two commands:

* deposit
* withdraw

And a single query:

* print statement

For testing purposes and also as to not dilute the responsibility of 
the account the statement should not really be printed 
(output to a device), but just generated as a data structure.

For the timestamp the current time is used, ie. a dependency to the 
system is needed.

Transactions will not be persisted. An account's state will be limited 
to the lifetime of it's object.

### 1. Functions

#### Deposit command
`
void Deposit(int amount)
`

#### Withdraw command
`
void Withdraw(int amount)
`

#### Print statement query
`
Statement PrintStatement()
`

#### Classes
The request handling functions can be aggregated by a single class `Account`.

More classes are needed for the statement if access to the statement 
details is needed:

`
class Statement
    Transaction* Transactions
    
class Transaction
    DateTime Date // set by the Account class
    int Amount
    int Balance
`

### 2. Test Cases
`
Input  | State            || State'
Amount | Date   | Balance || Balance'
+100     1.1.19         0        100
+200     1.1.19       100        300
-50      2.1.19       300        250
-300     3.1.19       250        -50
`

This development of an account will be expressed in a growing 
statement (output) after each transaction:

`
v1
1.1.19,+100,100

v2
1.1.19,+100,100
1.1.19,+200,300

v3
1.1.19,+100,100
1.1.19,+200,300
2.1.19,-50,250

v4
1.1.19,+100,100
1.1.19,+200,300
2.1.19,-50,250
3.1.19,-300,-50
`

</code></pre>
<p><!-- /wp:code --></p>
<p><!-- wp:paragraph --></p>
<p>This time I came up with an acceptance test case of my own. It’s exercising not just one function, though, but all functions I derived from the requirements. The acceptance test thus is more like a whole use case.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Also note that this problem leads to several classes. In the Diamond kata classes were of no concern. But here they are needed to aggregate functions and data.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>But the modularization is straightforward. It’s quite obvious, I’d say, because it is directly tied to the user’s needs. That’s why I would not say the classes are a product of design. I’m still in the analysis phase.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Maybe noteworthy is that I decided to not deliver a formatted textual account statement. Why should an account (object) care about report layout? It delivers a statement as a data structure some other part of a program can turn into a neatly layouted report.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Finally I encode my understanding:</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:image {"id":2698, "align": "center"} --></p>
<div class="wp-block-image">
<figure class="aligncenter"><figure class="wp-image-2698"><img loading="lazy"  src="https://ralfw.de/media/posts/135/DraggedImage-18.png" sizes="(max-width: 48em) 100vw, 768px" srcset="https://ralfw.de/media/posts/135/responsive/DraggedImage-18-xs.png 300w ,https://ralfw.de/media/posts/135/responsive/DraggedImage-18-sm.png 480w ,https://ralfw.de/media/posts/135/responsive/DraggedImage-18-md.png 768w ,https://ralfw.de/media/posts/135/responsive/DraggedImage-18-lg.png 1024w ,https://ralfw.de/media/posts/135/responsive/DraggedImage-18-xl.png 1360w ,https://ralfw.de/media/posts/135/responsive/DraggedImage-18-2xl.png 1600w"  alt="" width="1002" height="499"></figure></figure>
</div>
<p><!-- /wp:image --></p>
<p><!-- wp:paragraph --></p>
<p>There’s only one thing strange about this, I guess: why that kind of constructors on the <code>Account</code> class?</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:image {"id":2703, "align": "center"} --></p>
<div class="wp-block-image">
<figure class="aligncenter"><figure class="wp-image-2703"><img loading="lazy"  src="https://ralfw.de/media/posts/135/DraggedImage-1-4.png" sizes="(max-width: 48em) 100vw, 768px" srcset="https://ralfw.de/media/posts/135/responsive/DraggedImage-1-4-xs.png 300w ,https://ralfw.de/media/posts/135/responsive/DraggedImage-1-4-sm.png 480w ,https://ralfw.de/media/posts/135/responsive/DraggedImage-1-4-md.png 768w ,https://ralfw.de/media/posts/135/responsive/DraggedImage-1-4-lg.png 1024w ,https://ralfw.de/media/posts/135/responsive/DraggedImage-1-4-xl.png 1360w ,https://ralfw.de/media/posts/135/responsive/DraggedImage-1-4-2xl.png 1600w"  alt="" width="489" height="93"></figure></figure>
</div>
<p><!-- /wp:image --></p>
<p><!-- wp:paragraph --></p>
<p>During analysis I identified a dependency of my <em>system under test</em> (SUT, or system under development): It depends on the current date since the statement contains a date in each transaction, but requesting the transactions (<code>Deposit</code>, <code>Withdraw</code>) does not pass in a date.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>How could an automated test running on an arbitrary date have an expectation regarding transaction dates? Without making „date acquisition“ configurable that would be hard. Hence the public ctor for production, and the internal for testing. The public one sees to that the current date is used; but the acceptance test uses the internal one to pass in a substitute function to deliver a date from a fixed set for each transaction.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>That makes the test case a kind of whitebox test because it encodes an assumption about how many dates are required. But in this case that’s not severe, I’d say. Four transactions, four dates: that’s pretty obvious.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:heading {"level":2} --></p>
<h2>2. Design</h2>
<p><!-- /wp:heading --></p>
<p><!-- wp:paragraph --></p>
<p>Starting from the analysis I do some design. That’s not much, though. The problem is very simple. It’s just that I stop for a moment to gather my thoughts…</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:code --></p>
<pre class="wp-block-code"><code>## 2. Design
The `Account` class pretty much is an event stream with an 
aggregator attached.

* The commands add events to the stream. No checking is needed, all 
amounts are ok. But the date is added to the tx.
* The statement is an aggregation of the events in the stream where 
the balance is constantly updated.

The main functionality is statement generation. And within that it's 
updating the balance. That suggests a function (or even class of its own).

The event stream is a simple append-only list for (internal) transcactions.

// Open question: What should happen if a negative amount is passed to 
// `Deposit()` or `Withdraw()`?
</code></pre>
<p><!-- /wp:code --></p>
<p><!-- wp:paragraph --></p>
<p>After that I feel comfortable to start the implementation.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:heading {"level":2} --></p>
<h2>3. Implementation</h2>
<p><!-- /wp:heading --></p>
<p><!-- wp:heading {"level":3} --></p>
<h3>Recording transactions</h3>
<p><!-- /wp:heading --></p>
<p><!-- wp:paragraph --></p>
<p>This is an article about some form of test-first development. So what I’m doing here when I start the implementation of the <code>Account</code> class might seem horrible to you: I write logic without a test. I start with production code right away.😱</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>But after my design recording transactions (functions <code>Deposit</code> and <code>Withdraw</code>) seems so simple that I don’t see much of a danger therein.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:image {"id":2700, "align": "center"} --></p>
<div class="wp-block-image">
<figure class="aligncenter"><figure class="wp-image-2700"><img loading="lazy"  src="https://ralfw.de/media/posts/135/DraggedImage-2-4.png" sizes="(max-width: 48em) 100vw, 768px" srcset="https://ralfw.de/media/posts/135/responsive/DraggedImage-2-4-xs.png 300w ,https://ralfw.de/media/posts/135/responsive/DraggedImage-2-4-sm.png 480w ,https://ralfw.de/media/posts/135/responsive/DraggedImage-2-4-md.png 768w ,https://ralfw.de/media/posts/135/responsive/DraggedImage-2-4-lg.png 1024w ,https://ralfw.de/media/posts/135/responsive/DraggedImage-2-4-xl.png 1360w ,https://ralfw.de/media/posts/135/responsive/DraggedImage-2-4-2xl.png 1600w"  alt="" width="637" height="623"></figure></figure>
</div>
<p><!-- /wp:image --></p>
<p><!-- wp:paragraph --></p>
<p>There really is not much to test anyway. And if I wanted to test the effect of each function I would need to look under the hood of <code>Account</code>; it would only work with more whiteboxing.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>So I reason that in the end the correctness of transaction recording will show up immediately during statement production: If statement production is working, but delivers the wrong statements, then something must be wrong with recording transactions. In that case I would closer at the transaction methods.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>One word about the <code>Transaction</code> class inside of <code>Account</code>: It looks similar to the same named class inside of <code>Statement</code>. Why two classes for transactions? Because their „nature“ (or purpose) is different.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p><code>Statement.Transaction</code> is visible from the outside. It’s a class used for interaction with the system under development (a DTO). It’s subject to the user’s whim at any moment. I expect it to change due to changing requirements quite often.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p><code>Account.Transaction</code> on the other hand is an event object. It’s for recording what’s happening to the state of an <code>Account</code> object. (Never mind that it’s not phrased in the past tense.) This class is purely internal, an implementation detail. It’s not under direct stress from user requirements. I expect changing requirements not to lead to changes there, rather more events will be needed.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Two classes with the same name is simply a matter of decoupling. That’s a good architectural style. It’s clean code in my view.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Or let me say it the other way round more bluntly: Clean code does not mean the least amount of code possible to implement some runtime behavior! Just because you see more code than you think is technically needed, does not mean it’s smelling. The question always is: Why? Why more core than fore the bare functional necessity? And the answer has to show that future readers are kept in mind.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Yes, future readers over future requirements. It’s not that I don’t value future requirements on the right, but I find concern for future readers more important.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:heading {"level":3} --></p>
<h3>Printing the statement</h3>
<p><!-- /wp:heading --></p>
<p><!-- wp:paragraph --></p>
<p>Printing the statement is what the whole kata is about. It’s the crucial part and I want to get it right. Also I want to be able to work on it straightforwardly and independently.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>If I wrote a test for just the <code>PrintStatement</code> function, though, I would need to open the <code>Account</code> class in order to gain control over its state; <code>PrintStatement</code> is relying on that.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>To avoid this hassle I decide to switch to <a href="https://cumulative-hypotheses.org/2011/08/30/tdd-as-if-you-meant-it/" target="_blank" rel="nofollow noopener noreferrer">TDD as if you meant it (TDDaiymi)</a> from Keith Braithwaite. That means I use tests as my sole development environment; I won’t touch the production code until I’ve finished the functionality.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Also I’ll be moving forward with incremental tests since I’m not really sure how to solve this problem.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:heading {"level":4} --></p>
<h4>Iteration 1</h4>
<p><!-- /wp:heading --></p>
<p><!-- wp:paragraph --></p>
<p>Here’s my first iteration: What should the statement look like if there are no transactions yet? It should be empty.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:image {"id":2702, "align": "center"} --></p>
<div class="wp-block-image">
<figure class="aligncenter"><figure class="wp-image-2702"><img loading="lazy"  src="https://ralfw.de/media/posts/135/DraggedImage-3-4.png" sizes="(max-width: 48em) 100vw, 768px" srcset="https://ralfw.de/media/posts/135/responsive/DraggedImage-3-4-xs.png 300w ,https://ralfw.de/media/posts/135/responsive/DraggedImage-3-4-sm.png 480w ,https://ralfw.de/media/posts/135/responsive/DraggedImage-3-4-md.png 768w ,https://ralfw.de/media/posts/135/responsive/DraggedImage-3-4-lg.png 1024w ,https://ralfw.de/media/posts/135/responsive/DraggedImage-3-4-xl.png 1360w ,https://ralfw.de/media/posts/135/responsive/DraggedImage-3-4-2xl.png 1600w"  alt="" width="692" height="144"></figure></figure>
</div>
<p><!-- /wp:image --></p>
<p><!-- wp:paragraph --></p>
<p>I know this code looks pretty stupid. But it „simulates“ the situation in production: there are no transaction events (<code>new Account.Transaction[0]</code>). And the statement’s number of transactions mirrors that.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>As simple as lines 13 and 14 might look, they are crucial and I expect them to stay the same in next test cases. They are like a seed to grow the solution from. There is a small insight encoded in them.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:heading {"level":4} --></p>
<h4>Iteration 2</h4>
<p><!-- /wp:heading --></p>
<p><!-- wp:paragraph --></p>
<p>The next incremental test is about just one transaction event. I set that up with fixed data in line 23:</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:image {"id":2705, "align": "center"} --></p>
<div class="wp-block-image">
<figure class="aligncenter"><figure class="wp-image-2705"><img loading="lazy"  src="https://ralfw.de/media/posts/135/DraggedImage-4-3.png" sizes="(max-width: 48em) 100vw, 768px" srcset="https://ralfw.de/media/posts/135/responsive/DraggedImage-4-3-xs.png 300w ,https://ralfw.de/media/posts/135/responsive/DraggedImage-4-3-sm.png 480w ,https://ralfw.de/media/posts/135/responsive/DraggedImage-4-3-md.png 768w ,https://ralfw.de/media/posts/135/responsive/DraggedImage-4-3-lg.png 1024w ,https://ralfw.de/media/posts/135/responsive/DraggedImage-4-3-xl.png 1360w ,https://ralfw.de/media/posts/135/responsive/DraggedImage-4-3-2xl.png 1600w"  alt="" width="876" height="233"></figure></figure>
</div>
<p><!-- /wp:image --></p>
<p><!-- wp:paragraph --></p>
<p>Line 24 is the same as 13 in the first test. But it’s followed by a manual mapping of the transaction event to the statement transaction.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Line 28 is the only noteworthy line here: It could be reduced to <code>accountTransactions[0].Amount</code>, but by including <code>0  +</code> I make clear right away that I know the transaction’s <code>Balance</code> is an accumulating value.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:heading {"level":4} --></p>
<h4>Iteration 3</h4>
<p><!-- /wp:heading --></p>
<p><!-- wp:paragraph --></p>
<p>When doing TDDaiymi I actually often create new test cases by copying previous test cases and only change the expectation first. That way it’s immediately red and I’m forced to solve the problem: adjust the test input data, then adapt the logic. This is what I’m doing for iteration 3, too.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Now it’s two transaction events to „print“. The expectations (58ff) and input data (40ff) are set up accordingly. Line 45 and 56 still match 13 and 14 of the first iteration as expected.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:image {"id":2701, "align": "center"} --></p>
<div class="wp-block-image">
<figure class="aligncenter"><figure class="wp-image-2701"><img loading="lazy"  src="https://ralfw.de/media/posts/135/DraggedImage-5-3.png" sizes="(max-width: 48em) 100vw, 768px" srcset="https://ralfw.de/media/posts/135/responsive/DraggedImage-5-3-xs.png 300w ,https://ralfw.de/media/posts/135/responsive/DraggedImage-5-3-sm.png 480w ,https://ralfw.de/media/posts/135/responsive/DraggedImage-5-3-md.png 768w ,https://ralfw.de/media/posts/135/responsive/DraggedImage-5-3-lg.png 1024w ,https://ralfw.de/media/posts/135/responsive/DraggedImage-5-3-xl.png 1360w ,https://ralfw.de/media/posts/135/responsive/DraggedImage-5-3-2xl.png 1600w"  alt="" width="787" height="447"></figure></figure>
</div>
<p><!-- /wp:image --></p>
<p><!-- wp:paragraph --></p>
<p>And in between I copy the mapping from the previous test and adapt the second copy by changing the indexes.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Plus I need to think about how to carry over the balance from the previous statement transaction (line 54).</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:heading {"level":4} --></p>
<h4>Refactoring 1</h4>
<p><!-- /wp:heading --></p>
<p><!-- wp:paragraph --></p>
<p>My impression is I’ve solved the statement printing problem. I know how it’s gonna work. Now I just need to generalize it. Currently the number of transaction events is hardcoded. This is along the lines of the <a href="https://blog.cleancoder.com/uncle-bob/2013/05/27/TheTransformationPriorityPremise.html" target="_blank" rel="nofollow noopener noreferrer">Transformation Priority Premise</a>, I guess: <em>(constant-&gt;scalar)</em> and <em>(statement-&gt;recursion)</em>.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>I refactor the hardcoded solution to a variable solution:</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:image {"id":2704, "align": "center"} --></p>
<div class="wp-block-image">
<figure class="aligncenter"><figure class="wp-image-2704"><img loading="lazy"  src="https://ralfw.de/media/posts/135/DraggedImage-6-3.png" sizes="(max-width: 48em) 100vw, 768px" srcset="https://ralfw.de/media/posts/135/responsive/DraggedImage-6-3-xs.png 300w ,https://ralfw.de/media/posts/135/responsive/DraggedImage-6-3-sm.png 480w ,https://ralfw.de/media/posts/135/responsive/DraggedImage-6-3-md.png 768w ,https://ralfw.de/media/posts/135/responsive/DraggedImage-6-3-lg.png 1024w ,https://ralfw.de/media/posts/135/responsive/DraggedImage-6-3-xl.png 1360w ,https://ralfw.de/media/posts/135/responsive/DraggedImage-6-3-2xl.png 1600w"  alt="" width="769" height="434"></figure></figure>
</div>
<p><!-- /wp:image --></p>
<p><!-- wp:paragraph --></p>
<p>The basic mapping stays the same (lines 50 to 54), but I move the balance update up because I want to use a variable for it (line 49).</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>The loop around the mapping is trivial: for each transaction event a statement transaction is created. The same as before, just automatically done.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:heading {"level":4} --></p>
<h4>Refactoring 2</h4>
<p><!-- /wp:heading --></p>
<p><!-- wp:paragraph --></p>
<p>With the refactored/generalized logic still getting the test to green I extract it to the production code. I’m confident it will work there, too:</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:image {"id":2699, "align": "center"} --></p>
<div class="wp-block-image">
<figure class="aligncenter"><figure class="wp-image-2699"><img loading="lazy"  src="https://ralfw.de/media/posts/135/DraggedImage-7-3.png" sizes="(max-width: 48em) 100vw, 768px" srcset="https://ralfw.de/media/posts/135/responsive/DraggedImage-7-3-xs.png 300w ,https://ralfw.de/media/posts/135/responsive/DraggedImage-7-3-sm.png 480w ,https://ralfw.de/media/posts/135/responsive/DraggedImage-7-3-md.png 768w ,https://ralfw.de/media/posts/135/responsive/DraggedImage-7-3-lg.png 1024w ,https://ralfw.de/media/posts/135/responsive/DraggedImage-7-3-xl.png 1360w ,https://ralfw.de/media/posts/135/responsive/DraggedImage-7-3-2xl.png 1600w"  alt="" width="618" height="246"></figure></figure>
</div>
<p><!-- /wp:image --></p>
<p><!-- wp:paragraph --></p>
<p>The only adjustment I need to make is changing the source of the transaction events to the <code>Account</code> class’ global state <code>_transactions</code>.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>With <code>PrintStatement</code> filled in I check the acceptance test. It should be green now - if the implementation of the transaction functions was correct.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>And indeed it is!🎉</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Problem solved.😎🕺</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:heading {"level":2} --></p>
<h2>Refactoring</h2>
<p><!-- /wp:heading --></p>
<p><!-- wp:paragraph --></p>
<p>What’s left is to restrict the accessibility of functions and classes to <code>private</code> where necessary. The surface of the production code should be minimal.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>That’s only affecting the <code>Account.Transaction</code> class which I set to <code>internal</code> while going through the TDDaiymi iterations.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Now that it’s hidden, however, the TDDaiymi test becomes flagged. The incremental tests cannot be compiled anymore. Their true nature is revealed: they were <a href="https://ralfw.de/hamburg-style-tdd-diamond-kata/"><em>scaffolding tests</em></a> all along. That means they now have to be deleted.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>The acceptance test remains as the only test. That makes me free to refactor the solution below the surface at any time without breaking tests targeting details.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:heading {"level":2} --></p>
<h2>Summary</h2>
<p><!-- /wp:heading --></p>
<p><!-- wp:paragraph --></p>
<p>This problem required a somewhat different treatment compared to the Diamond kata: not writing tests for functions, doing TDDaiymi… That might feel new or uncomfortable to you. But I stand by my opinion: it’s legitimate, it’s even easier than sticking to one of the other schools of TDD.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>In the end it’s all about the result. How straightforwardly can you move towards functional and clean code? If ADC and TBC can help, then you should employ them.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>But Hamburg style TDD actually is not in opposition of Chicago style etc. Rather it’s embracing them all - and adding a twist. This twist is the recommendation to do explicit analysis and explicit design and to avoid functional dependencies. And that in turn leads to tests with no (or less) need for substitutes, i.e. less complexity.</p>
<p><!-- /wp:paragraph --></p>
            ]]>
        </content>
    </entry>
    <entry>
        <title>Co-creation at work</title>
        <author>
            <name>Ralf Westphal</name>
        </author>
        <link href="https://ralfw.de/co-creation-at-work/"/>
        <id>https://ralfw.de/co-creation-at-work/</id>
            <category term="Creative Process"/>
            <category term="Coworking Bansko"/>

        <updated>2021-01-25T22:26:43+08:00</updated>
            <summary>
                <![CDATA[
                        <img src="https://ralfw.de/media/posts/134/DraggedImage-3-3.png" alt="" />
                    Last night I experienced live within 15 minutes an example of co-creation. What an unexpected treat from David who was the presenter at the weekly Business Growth event at Coworking Bansko. David, who talked about visual communication, asked us at the end to apply what&hellip;
                ]]>
            </summary>
        <content type="html">
            <![CDATA[
                    <img src="https://ralfw.de/media/posts/134/DraggedImage-3-3.png" alt="" />
                <p><!-- wp:paragraph --></p>
<p>Last night I experienced live within 15 minutes an example of co-creation. What an unexpected treat from David who was the presenter at the weekly Business Growth event at <a href="http://coworkingbansko.com/" target="_blank" rel="noopener">Coworking Bansko</a>.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:image {"id":2693, "align": "center"} --></p>
<div class="wp-block-image">
<figure class="aligncenter"><figure class="wp-image-2693"><img loading="lazy"  src="https://ralfw.de/media/posts/134/DraggedImage-17.png" sizes="(max-width: 48em) 100vw, 768px" srcset="https://ralfw.de/media/posts/134/responsive/DraggedImage-17-xs.png 300w ,https://ralfw.de/media/posts/134/responsive/DraggedImage-17-sm.png 480w ,https://ralfw.de/media/posts/134/responsive/DraggedImage-17-md.png 768w ,https://ralfw.de/media/posts/134/responsive/DraggedImage-17-lg.png 1024w ,https://ralfw.de/media/posts/134/responsive/DraggedImage-17-xl.png 1360w ,https://ralfw.de/media/posts/134/responsive/DraggedImage-17-2xl.png 1600w"  alt="" width="628" height="324" /></figure></figure>
</div>
<p><!-- /wp:image --></p>
<p><!-- wp:paragraph --></p>
<p>David, who talked about visual communication, asked us at the end to apply what we’d heard to a simple task: create some „icon“ or visual sign for the coworking space. We were to form small groups, come up with a topic, and quickly draw something on a piece of paper.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>This was where it got really interesting on a meta-level I think :-)</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:heading {"level":3} --></p>
<h3>Team gathering</h3>
<p><!-- /wp:heading --></p>
<p><!-- wp:paragraph --></p>
<p>Finding a group was easy. The group members gathered quickly around the tables. In my group we did not experience noticeable forming, storming or norming throes. We were able to get right to work.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>I think that was, when groups turned into teams. Because there was a common goal for all group members they were supposed to achieve together. The exercise was not only about applying some visual concepts, but also about collaboration.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:heading {"level":3} --></p>
<h3>Phase 1: Taming chaos</h3>
<p><!-- /wp:heading --></p>
<p><!-- wp:paragraph --></p>
<p>However, working on the task in my team started in… chaos. No, we did not run around screaming and climbing over each other :-D Rather chaos was signified by a lack of alignment. There was no direction, no focus yet for what actually to draw.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Sure we knew that we had to create some visualization. But within this overall task we were clueless. What should our topic be?</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Other teams started right away with a fixed topic. They were able to get to work on drawings without discussion. Not us, though.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>It took us a couple of minutes to bring order to our chaos. Suggestions for topics where thrown around. Some were new, others refined previous ones… Some were discussed for a moment, others were just ignored…</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Then, after a few minutes we pretty suddenly agreed on a topic. To me it’s still strange how that happened. Why that and not another one? Maybe the topic had more of a general appeal to all of us? Or maybe it was more tangible than other ones?</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Anyway, it pretty much just happened. There was no ruling by any group member.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Our topic was: Visualizations of the coworking room categories</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:list {"ordered":false} --></p>
<ul>
<li>„quiet space“ (no talking allowed)</li>
<li>„semi-quiet space“ (some low voice talking allowed)</li>
<li>„social space“ (talking allowed, even doing phone calls or online sessions).</li>
</ul>
<p><!-- /wp:list --></p>
<p><!-- wp:paragraph --></p>
<p>With a topic in hand chaos had been tamed. We had drawn a line. Chaos to me is a state of dis-order, i.e. no clear-cut boundaries. In chaos right/wrong, good/bad and other dualities are missing. Dis-order equals dis-orientation.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>But now we knew what to focus on - and what not to consider anymore. That was the achieved duality. And it felt great to share this view with others. The team had found alignment.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:heading {"level":3} --></p>
<h3>Phase 2: Exploring the solution space</h3>
<p><!-- /wp:heading --></p>
<p><!-- wp:paragraph --></p>
<p>Once aligned the real work of visualization began. How could those coworking space categories possibly be represented in a „universal“ way so that people from different cultures and with different levels of experience with coworking would immediately understand them?</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>For that we stopped our discussion and each grabbed a pen and a piece of paper. All team members started sketching ideas. For a minute or two there was no interaction between team members. We were fanning out to explore the solution space individually; not physically, just mentally.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>And then we got back together and put our visual ideas in the middle of the table. We discussed the pros and cons of our varied approaches to visualizing the categories. Some were discarded pretty quickly, others were greeted with more agreement.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>In a second round some team members tried to build on what had been picked out as more promising visualizations. They went back to the solution space and explored further.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>What they found was put before all team members for further discussion.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:image {"id":2692, "align": "center"} --></p>
<div class="wp-block-image">
<figure class="aligncenter"><figure class="wp-image-2692"><img loading="lazy"  src="https://ralfw.de/media/posts/134/DraggedImage-1-3.png" sizes="(max-width: 48em) 100vw, 768px" srcset="https://ralfw.de/media/posts/134/responsive/DraggedImage-1-3-xs.png 300w ,https://ralfw.de/media/posts/134/responsive/DraggedImage-1-3-sm.png 480w ,https://ralfw.de/media/posts/134/responsive/DraggedImage-1-3-md.png 768w ,https://ralfw.de/media/posts/134/responsive/DraggedImage-1-3-lg.png 1024w ,https://ralfw.de/media/posts/134/responsive/DraggedImage-1-3-xl.png 1360w ,https://ralfw.de/media/posts/134/responsive/DraggedImage-1-3-2xl.png 1600w"  alt="" width="636" height="294" /></figure></figure>
</div>
<p><!-- /wp:image --></p>
<p><!-- wp:paragraph --></p>
<p>Although this might sound like a lengthy process if of course was not. It all happened in a matter of a dozen seconds.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>It was after this second iteration that one team member had a crucial idea: Why not let all three icons look the same except for a delta representing the category.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>That was our „plot point“ when we entered the final phase…</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:heading {"level":3} --></p>
<h3>Phase 3: Refining the product</h3>
<p><!-- /wp:heading --></p>
<p><!-- wp:paragraph --></p>
<p>One of the team members picked up this idea right away and started creating new icons. That way the suggestion manifested for the first time and it looked right.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>The discussion now was able to focus more on details. One aspect was to be simplified, another to be emphasised.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:image {"id":2694, "align": "center"} --></p>
<div class="wp-block-image">
<figure class="aligncenter"><figure class="wp-image-2694"><img loading="lazy"  src="https://ralfw.de/media/posts/134/DraggedImage-2-3.png" sizes="(max-width: 48em) 100vw, 768px" srcset="https://ralfw.de/media/posts/134/responsive/DraggedImage-2-3-xs.png 300w ,https://ralfw.de/media/posts/134/responsive/DraggedImage-2-3-sm.png 480w ,https://ralfw.de/media/posts/134/responsive/DraggedImage-2-3-md.png 768w ,https://ralfw.de/media/posts/134/responsive/DraggedImage-2-3-lg.png 1024w ,https://ralfw.de/media/posts/134/responsive/DraggedImage-2-3-xl.png 1360w ,https://ralfw.de/media/posts/134/responsive/DraggedImage-2-3-2xl.png 1600w"  alt="" width="641" height="295" /></figure></figure>
</div>
<p><!-- /wp:image --></p>
<p><!-- wp:paragraph --></p>
<p>With that information another team member drew a version of the icons which then was accepted and handed to David for the final presentation of all designs.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:heading {"level":2} --></p>
<h2>Summary</h2>
<p><!-- /wp:heading --></p>
<p><!-- wp:paragraph --></p>
<p>Crammed into maybe around 10 minutes this collaboration was a great experience of focused team work. We co-created something I would not have dreamed of before.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:image {"id":2691, "align": "center"} --></p>
<div class="wp-block-image">
<figure class="aligncenter"><figure class="wp-image-2691"><img loading="lazy"  src="https://ralfw.de/media/posts/134/DraggedImage-3-3.png" sizes="(max-width: 48em) 100vw, 768px" srcset="https://ralfw.de/media/posts/134/responsive/DraggedImage-3-3-xs.png 300w ,https://ralfw.de/media/posts/134/responsive/DraggedImage-3-3-sm.png 480w ,https://ralfw.de/media/posts/134/responsive/DraggedImage-3-3-md.png 768w ,https://ralfw.de/media/posts/134/responsive/DraggedImage-3-3-lg.png 1024w ,https://ralfw.de/media/posts/134/responsive/DraggedImage-3-3-xl.png 1360w ,https://ralfw.de/media/posts/134/responsive/DraggedImage-3-3-2xl.png 1600w"  alt="" width="620" height="445" /></figure></figure>
</div>
<p><!-- /wp:image --></p>
<p><!-- wp:paragraph --></p>
<p>In fact I had been a bit reluctant to join a group because I was skeptical about what could possibly be achieved. But I was wrong and am glad for the opportunity to see how co-creation can work even in such ad hoc situations. Thanks, David, for challenging me!</p>
<p><!-- /wp:paragraph --></p>

            ]]>
        </content>
    </entry>
    <entry>
        <title>Hamburg Style TDD - Diamond Kata</title>
        <author>
            <name>Ralf Westphal</name>
        </author>
        <link href="https://ralfw.de/hamburg-style-tdd-diamond-kata/"/>
        <id>https://ralfw.de/hamburg-style-tdd-diamond-kata/</id>
            <category term="TDD"/>

        <updated>2021-01-28T17:45:28+08:00</updated>
            <summary>
                <![CDATA[
                    In a previous article I tried to explain why I’m not satisfied with the existing schools of TDD: They are not really tapping the developers’ capability to think. At least for my taste. Or to say it more bluntly: They are dumbing down developers. Sure,&hellip;
                ]]>
            </summary>
        <content type="html">
            <![CDATA[
                <p><!-- wp:paragraph --></p>
<p>In a <a href="https://ralfw.de/hamburg-style-tdd/">previous article</a> I tried to explain why I’m not satisfied with the existing schools of TDD: They are not really tapping the developers’ capability to think. At least for my taste. Or to say it more bluntly: They are dumbing down developers.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Sure, their motivation behind that is honorable. And they all assure us of still, no, hence getting to the best possible code result. Nevertheless I think this is doing productivity a disservice.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Mileage always varies with different approaches, but for me the mileage so far has been too low with the established TDD styles. That’s why I came up with yet another one. I call it eclectic because it’s drawing from all sorts of approaches. And I might even not call it a programming style but a problem solving style.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>In my previous article I explained why I think TBC (Thinking Before Coding) and ADC (Analyse, Design, Code) are so important. But what does that mean when applied to concrete problems?</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Here’s a first problem I tackled to demonstrate this. I chose the Diamond kata because the originator of the Munich style TDD, David Völkel, was mentioned <a href="https://twitter.com/DataDuke/status/1151989878499897344" target="_blank" rel="noopener noreferrer">in a recent tweet</a> teaching his style using this kata.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Let’s start…</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:heading {"level":2} --></p>
<h2>Problem description</h2>
<p><!-- /wp:heading --></p>
<p><!-- wp:paragraph --></p>
<p>First a problem description as I found it on the web:</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:code --></p>
<pre class="wp-block-code"><code>Given a letter, print a diamond starting with ‘A’ with the supplied letter at the widest point.

For example: print-diamond ‘C’ prints

..A
.B.B
C...C
.B.B
..A

(The dots '.' are just placeholders for spaces ' ' to make the result more clear.)
</code></pre>
<p><!-- /wp:code --></p>
<p><!-- wp:heading {"level":2} --></p>
<p> </p>
<h2>1. Analysis</h2>
<p><!-- /wp:heading --></p>
<p><!-- wp:paragraph --></p>
<p>The first thing I do when faced with a programming problem is… I’m trying to understand it. Sure that’s also advocated by other TDD styles. But exactly does that mean? What’s the result of analysis?</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Analysis is the activity which in my view is supposed to produce understanding. But how to document my understanding?</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>In the end there is no unambiguous understanding except when I’m able to solve the problem (or very similar problems in the same problem class). That means any software I produce needs to be able to do the same. Otherwise I might have understood, but wasn’t able to encode my understanding.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Translated into code that means analysis results in two things:</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:list {"ordered":false} --></p>
<ul>
<li>examples of successful problem solving (aka test cases)</li>
<li>functions that actually show the behavior as described in the examples.</li>
</ul>
<p><!-- /wp:list --></p>
<p><!-- wp:paragraph --></p>
<p>I usually document my understanding in a file next to the code. In this case I used a <code>.md</code> file:</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:image {"id":2679, "align": "center"} --></p>
<div class="wp-block-image">
<figure class="aligncenter"><figure class="wp-image-2679"><img loading="lazy"  src="https://ralfw.de/media/posts/133/DraggedImage-16.png" sizes="(max-width: 48em) 100vw, 768px" srcset="https://ralfw.de/media/posts/133/responsive/DraggedImage-16-xs.png 300w ,https://ralfw.de/media/posts/133/responsive/DraggedImage-16-sm.png 480w ,https://ralfw.de/media/posts/133/responsive/DraggedImage-16-md.png 768w ,https://ralfw.de/media/posts/133/responsive/DraggedImage-16-lg.png 1024w ,https://ralfw.de/media/posts/133/responsive/DraggedImage-16-xl.png 1360w ,https://ralfw.de/media/posts/133/responsive/DraggedImage-16-2xl.png 1600w"  alt="" width="691" height="545"></figure></figure>
</div>
<p><!-- /wp:image --></p>
<p><!-- wp:paragraph --></p>
<p>You see, first there is some text explaining what I gleaned from the problem description. An important aspect of that are terms of the domain language.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>But then there is a function and test cases. They are the real expressions of my understanding.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>The sample problem is so easy, however, I did not come up with my own test case. But if it’s more complicated I will go beyond whatever has been presented by the client.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>My analysis is complete once I really get my insights encoded as <em>acceptance tests</em> and the signatures of behavior delivering functions:</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:image {"id":2667, "align": "center"} --></p>
<div class="wp-block-image">
<figure class="aligncenter"><figure class="wp-image-2667"><img loading="lazy"  src="https://ralfw.de/media/posts/133/DraggedImage-1-2.png" sizes="(max-width: 48em) 100vw, 768px" srcset="https://ralfw.de/media/posts/133/responsive/DraggedImage-1-2-xs.png 300w ,https://ralfw.de/media/posts/133/responsive/DraggedImage-1-2-sm.png 480w ,https://ralfw.de/media/posts/133/responsive/DraggedImage-1-2-md.png 768w ,https://ralfw.de/media/posts/133/responsive/DraggedImage-1-2-lg.png 1024w ,https://ralfw.de/media/posts/133/responsive/DraggedImage-1-2-xl.png 1360w ,https://ralfw.de/media/posts/133/responsive/DraggedImage-1-2-2xl.png 1600w"  alt="" width="805" height="302"></figure></figure>
</div>
<p><!-- /wp:image --></p>
<p><!-- wp:paragraph --></p>
<p>I don’t need to know how to create the results. Just the surface of my „system under development“ needs to be clearly specified.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>That’s easy in this case of course. But what if I had a hard time to come up with an interface? Isn’t TDD supposed to help with that?</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Well, my view is: As long as you don’t know which functions should provide the requested services, you should not touch your production code. You’re not even in a situation to write tests.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Lack of clarity of the interface is a clear sign of „chaos“ (in your head or the client’s head). <a href="https://en.wikipedia.org/wiki/Cynefin_framework" target="_blank" rel="noopener noreferrer">And when in chaos the first thing to do is: act!</a></p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>In the case of programming that means whipping up a REPL or some other scratchpad and start „drawing“, start experimenting. Play around with interfaces all you want. Write a whole prototype, even.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>But don’t touch your production code! Not even backed by a test. Otherwise you’ll later on be sorry because you have to go through much refactoring. And that’s always putting strain on your codebase.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>The remedy to cluelessness is not refactoring! As long as you don’t have a clue how a system under development’s surface should look like, you’re clueless. You can’t even come up with clear cut test cases.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>It’s time for a different mode. Not the test-first mode, but an experimentation mode outside production code.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Luckily that’s not the case for the Diamond kata, though. That means my analysis is complete.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Bottom line: For me TDD always means ATDD (Acceptance Test-Driven Development). Don’t start work on production code before there is an acceptance test, i.e. a comprehensive test describing the required behavior.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>An acceptance test to me is a guiding light or a north start. Once the acceptance tests are going green I know my job is done. I don’t mind them staying red for a longer while. I simply don’t execute them all the time ;-)</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:heading {"level":2} --></p>
<h2>2. Design</h2>
<p><!-- /wp:heading --></p>
<p><!-- wp:paragraph --></p>
<p>With the acceptance tests implemented I continue by TBC. I ask myself:</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:list {"ordered":true} --></p>
<ol>
<li>Can I partition the overall problem into smaller, complementary problems which I then solve independently?</li>
<li>Are there simpler problems nested inside the overall difficult one? Can I find a list of incremental tests?</li>
</ol>
<p><!-- /wp:list --></p>
<p><!-- wp:paragraph --></p>
<p>The second step is what TDD originally was about, I think. In my view, though, this only works well for very simple problems. It’s a not to be neglected question, but in my approach is not the first one to ask.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>My first step is to look for more or less obvious sub-problems which I can solve more or less independently - hoping that the solutions to the sub-problems later can be integrated into a solution for the overall problem. Each sub-problem again will be represented by a function responsible for some partial behavior.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>I’m using the good old „stepwise refinement“ approach, you could say. I’m recursively descending a problem tree.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>And why not? Just because it’s an old approach doesn’t mean it’s not fit for the modern world.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>But I’m using it with a twist! And that’s quite important for the clean code goal. My function hierarchies are free of functional dependencies. I’m not distributing logic vertically all over the hierarchy, but lump it together in the leaf functions, called <em>operations</em> according to the IOSP (Integration Operation Segregation Principle). That’s making a huge difference for understandability and testability!</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Here’s what I came up with as a design for the Diamond kata:</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:image {"id":2670, "align": "center"} --></p>
<div class="wp-block-image">
<figure class="aligncenter"><figure class="wp-image-2670"><img loading="lazy"  src="https://ralfw.de/media/posts/133/DraggedImage-2-2.png" sizes="(max-width: 48em) 100vw, 768px" srcset="https://ralfw.de/media/posts/133/responsive/DraggedImage-2-2-xs.png 300w ,https://ralfw.de/media/posts/133/responsive/DraggedImage-2-2-sm.png 480w ,https://ralfw.de/media/posts/133/responsive/DraggedImage-2-2-md.png 768w ,https://ralfw.de/media/posts/133/responsive/DraggedImage-2-2-lg.png 1024w ,https://ralfw.de/media/posts/133/responsive/DraggedImage-2-2-xl.png 1360w ,https://ralfw.de/media/posts/133/responsive/DraggedImage-2-2-2xl.png 1600w"  alt="" width="750" height="254"></figure></figure>
</div>
<p><!-- /wp:image --></p>
<p><!-- wp:paragraph --></p>
<p>It’s more precisely documenting my understanding of the problem and delivering a <em>model</em> for the implementation.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>The model consists of yet more functions, but in addition to that also relations between those functions.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:list {"ordered":false} --></p>
<ul>
<li>There is a hierarchical relation: The original user facing function, the root function of the function tree depends on the other functions.</li>
<li>There are before-after or sequence relations: The partial functions will need to be called in a certain order.</li>
<li>There is an implicit aggregation relation: All functions will belong to the same module (class).</li>
</ul>
<p><!-- /wp:list --></p>
<p><!-- wp:paragraph --></p>
<p>Noteworthy of this kind of design is the absence of loops! To declarative and on a high level of abstraction a model needs to be free of imperative loops. Looping will occur in the end, but in the model it’s hidden.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>This design process maybe takes me 10 minutes. The most effort goes into actually writing the results down for the purpose of this article.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Why should I not invest this short time up-front for design? It’s easy, and it delivers starting points for further tests. I don’t need to drive the implementation through the root function. That, to me, would feel artificial, and not simpler. And I would have to refactor more.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>My design will produce clean code, I’m confident. Because the implementation will follow the IOSP.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Growing logic by applying tests primarily to the root function (and later refactor) is like <a href="https://de.wikipedia.org/wiki/Williams_Christ" target="_blank" rel="noopener noreferrer">growing a Bartlett inside a bottle</a>. I call that <em>pear programming</em>.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:image {"id":2669, "align": "center"} --></p>
<div class="wp-block-image">
<figure class="aligncenter"><figure class="wp-image-2669"><img loading="lazy"  src="https://ralfw.de/media/posts/133/DraggedImage-1.tiff" alt=""></figure><figure class="alignnone size-medium wp-image-2684"><img loading="lazy"  src="https://ralfw.de/media/posts/133/Williams_Christ_Obstbrand-172x300.jpg" sizes="(max-width: 48em) 100vw, 768px" srcset="https://ralfw.de/media/posts/133/responsive/Williams_Christ_Obstbrand-172x300-xs.jpg 300w ,https://ralfw.de/media/posts/133/responsive/Williams_Christ_Obstbrand-172x300-sm.jpg 480w ,https://ralfw.de/media/posts/133/responsive/Williams_Christ_Obstbrand-172x300-md.jpg 768w ,https://ralfw.de/media/posts/133/responsive/Williams_Christ_Obstbrand-172x300-lg.jpg 1024w ,https://ralfw.de/media/posts/133/responsive/Williams_Christ_Obstbrand-172x300-xl.jpg 1360w ,https://ralfw.de/media/posts/133/responsive/Williams_Christ_Obstbrand-172x300-2xl.jpg 1600w"  alt="" width="172" height="300"></figure></figure>
</div>
<p><!-- /wp:image --></p>
<p><!-- wp:paragraph --></p>
<p>Source: <a href="https://de.wikipedia.org/wiki/Williams_Christ" target="_blank" rel="noopener">Wikipedia</a></p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>It can be done. It’s a piece of art, maybe. But I find that hard. The harder the more logic this way should be developed. Because that way it’s impossible to target pieces of logic with tests. All logic is always under test - unless you swap it out with <a href="https://martinfowler.com/articles/mocksArentStubs.html" target="_blank" rel="noopener">substitutes</a>.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Substitutes, though, to me are additional complexity I want to avoid! I’m not saying they should not be used. But to base a programming approach on them is not my cup of tea.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:heading {"level":3} --></p>
<h3>A KISS for design</h3>
<p><!-- /wp:heading --></p>
<p><!-- wp:paragraph --></p>
<p>One argument against my approach, I hear, is that I’m not doing the simplest thing possible. Starting with a trivial test (even a degenerate test case) and then answering that with maybe only a singe line of production code would be much, much simpler. And it would immediately deliver a (small) value. And it would guarantee that no production code gets written without being covered by a test.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>By now you can imagine: I beg to differ.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>In fact I think my kind of design is the simplest thing you can do. I’m following the KISS principle to the letter.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Why? Because I don’t even implement a single line of code (at first). What’s simpler than writing code? Not writing code! That’s faster, that does not produce waste which later needs to be refactored.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Designing by stepwise refinement, by dissecting large problems into smaller ones is so simple because it „assumes“ that certain „services“ will be available. It does not care how they are going to be implemented. That’s details to wreck your brain about some other time.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>The above list of functions is a wish list. I’m wishing for help: „How nice it would be to have a function that does X…“ or „What a relieve it would be to not worry about problem Y anymore because a function is taking care of that…“</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>If I cannot simplify a big problem by at least coming up with two partial problems which are smaller I guess I don’t really have a clue about what’s going on in the first place. Either I can solve a problem by writing the logic – or I can solve it by dissecting it into smaller, complementary problems.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>With regard to the Diamond kata wishing for help could run like this:</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:list {"ordered":false} --></p>
<ul>
<li>„Oh, there is a single input letter, but the diamond consists of multiple letters up until the input letter. I wish there was a function taking care of getting me this list. The rest then can be accomplished by another function.</li>
<li>„Hm… given a list of letters I need to generate the layers of the diamond. Half of them are unique. It would be nice to have a function doing that. Another one could then take care of building a full diamond from them.“</li>
<li>„Now that I have a list of letters the hard part is to generate a single layer with the right spacing. I wish there was a function for that. Generating layers for all letters then is simple based on that.“</li>
<li>„The most difficult thing about a layer is to get the number of leading spaces and separating spaces right. There should be a function calculating that for each layer. Arranging the letter in a layer based on that info then would be easy.“</li>
</ul>
<p><!-- /wp:list --></p>
<p><!-- wp:paragraph --></p>
<p>I find this most simple. And if it’s not then I need to double down on thinking the problem through or maybe go back to analysis. Not being able to come up with a „functional design“ to me is the first sign of cluelessness. I would not recommend to touch production code in such a state of mind.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:heading {"level":2} --></p>
<h2>3. Implementation</h2>
<p><!-- /wp:heading --></p>
<p><!-- wp:paragraph --></p>
<p>After design all’s prepared. At least that’s true in this simple case. I know all the functions that will be needed. I’ve a good feeling about this. If the problem was larger I would not have refined the whole function tree down to the last operation. Remember: I’m all for iterative and incremental progress. TBC with ADC is not about a resurrection of the waterfall.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Backed by the acceptance tests I now implement the functions I „uncovered“ during design in any order. I could start with the seemingly simplest or simply with the first one. It pretty much does not matter.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:heading {"level":3} --></p>
<h3>Determine the layers</h3>
<p><!-- /wp:heading --></p>
<p><!-- wp:paragraph --></p>
<p>The partial problem of determining the number of layers with their respective letters (layer names) I attack using… incremental tests. Inside my approach I’m using pretty much Chicago style TDD. You see why I’m calling it eclectic?</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>I come up with two tests growing in difficulty and implement the production code by going red-green-red-green.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:image {"id":2668, "align": "center"} --></p>
<div class="wp-block-image">
<figure class="aligncenter"><figure class="wp-image-2668"><img loading="lazy"  src="https://ralfw.de/media/posts/133/DraggedImage-3-2.png" sizes="(max-width: 48em) 100vw, 768px" srcset="https://ralfw.de/media/posts/133/responsive/DraggedImage-3-2-xs.png 300w ,https://ralfw.de/media/posts/133/responsive/DraggedImage-3-2-sm.png 480w ,https://ralfw.de/media/posts/133/responsive/DraggedImage-3-2-md.png 768w ,https://ralfw.de/media/posts/133/responsive/DraggedImage-3-2-lg.png 1024w ,https://ralfw.de/media/posts/133/responsive/DraggedImage-3-2-xl.png 1360w ,https://ralfw.de/media/posts/133/responsive/DraggedImage-3-2-2xl.png 1600w"  alt="" width="815" height="274"></figure></figure>
</div>
<p><!-- /wp:image --></p>
<p><!-- wp:paragraph --></p>
<p>There is nothing to refactor after the first test and not even after the second test. The function is so focused, so small.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>You might find that the code to get the second red test to green does not seem simple. If so I say: To hell with simplicity! At that point I had a clear idea of how to solve the problem once and for all. Why not just write it down?</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>I could have used another test to drive out some pattern and refactor… but with this kind of small problem that seemed too much effort.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Or if you find the implementation lacking with regard to null boundary checks let me say: To hell with defensive programming! It’s not the responsibility of this function to check if the seed is in a certain range. If so, it just fails. There is not even a requirement to behave in a certain way in such a case. Why should I implement a solution to a non-existing requirement?</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Defensive programming, I have to say, often is a form of procrastination. It’s applied to postpone solving the hard problems. It’s applied to ward off „friendly fire“ from code other team members might write. It thus is a substitute for the right thing to do: Doing real thinking about the real problem and drawing explicit trust boundaries during joint design sessions with other team members.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:heading {"level":3} --></p>
<h3>Calculate layer whitespaces</h3>
<p><!-- /wp:heading --></p>
<p><!-- wp:paragraph --></p>
<p>My approach again changes with the second function I implement: I go for a „one shot kill“: first a red test on an acceptance test level (for a partial problem), then all the necessary production code.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:image {"id":2672, "align": "center"} --></p>
<div class="wp-block-image">
<figure class="aligncenter"><figure class="wp-image-2672"><img loading="lazy"  src="https://ralfw.de/media/posts/133/DraggedImage-4-2.png" sizes="(max-width: 48em) 100vw, 768px" srcset="https://ralfw.de/media/posts/133/responsive/DraggedImage-4-2-xs.png 300w ,https://ralfw.de/media/posts/133/responsive/DraggedImage-4-2-sm.png 480w ,https://ralfw.de/media/posts/133/responsive/DraggedImage-4-2-md.png 768w ,https://ralfw.de/media/posts/133/responsive/DraggedImage-4-2-lg.png 1024w ,https://ralfw.de/media/posts/133/responsive/DraggedImage-4-2-xl.png 1360w ,https://ralfw.de/media/posts/133/responsive/DraggedImage-4-2-2xl.png 1600w"  alt="" width="797" height="215"></figure></figure>
</div>
<p><!-- /wp:image --></p>
<p><!-- wp:paragraph --></p>
<p>I’m not trying to crawl my way to a full solution with incremental tests because the solution is sitting right in front of me in the design. I’ve done „my math“ in the design document already; it was part of understanding the problem. Why shouldn’t I use that now?</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>And again: the operation is so small. The loop is following a pattern, the calculations are trivial. If the one test would fail it would be easy to detect the cause.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Of course the production code is benefiting from language features like <code>yield return</code>. No need to allocate a data structure to compile the results in. Also no need to define a data structure to carry both values for each layer. C# tuples as „ad hoc records“ are perfect for that.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Please note how only the number of layers is passed to the function. No need to let it know about the layer letters. That’s decoupling in the small. It’s made easier by designing the functions before implementation. Refactoring to this kind of decoupling later on would be harder.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:heading {"level":3} --></p>
<h3>Generate the unique diamond layers</h3>
<p><!-- /wp:heading --></p>
<p><!-- wp:paragraph --></p>
<p>The third partial problem again is different from the previous ones. I now realize it’s too difficult to solve right away or with incremental tests. So I revert to stepwise refinement once again.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>The overall problem of generating the unique layers consists of the partial problem generating of generating just a single layer - and a remaining problem of doing that for all layer letters.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>It’s a typical „N:1 problem“. Or you could call it a mapping problem: the same thing is done for each item in a collection. However here it’s two collections of the same length. The layer letters have to be „merged“ with the layer whitespace calculations.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>What I do in this case I use a bottom up approach: first I implement the nested function for generating a single layer. I do that again with two incremental tests, red-green-red-green.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:image {"id":2674, "align": "center"} --></p>
<div class="wp-block-image">
<figure class="aligncenter"><figure class="wp-image-2674"><img loading="lazy"  src="https://ralfw.de/media/posts/133/DraggedImage-5-2.png" sizes="(max-width: 48em) 100vw, 768px" srcset="https://ralfw.de/media/posts/133/responsive/DraggedImage-5-2-xs.png 300w ,https://ralfw.de/media/posts/133/responsive/DraggedImage-5-2-sm.png 480w ,https://ralfw.de/media/posts/133/responsive/DraggedImage-5-2-md.png 768w ,https://ralfw.de/media/posts/133/responsive/DraggedImage-5-2-lg.png 1024w ,https://ralfw.de/media/posts/133/responsive/DraggedImage-5-2-xl.png 1360w ,https://ralfw.de/media/posts/133/responsive/DraggedImage-5-2-2xl.png 1600w"  alt="" width="1034" height="245"></figure></figure>
</div>
<p><!-- /wp:image --></p>
<p><!-- wp:paragraph --></p>
<p>The first version of the production code might seem not really according to KISS. Why include the <code>if</code>? For the first test this condition was not necessary.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Well… I guess my attention slipped a bit. I indulged in some look ahead. I knew a second test was coming which would need the conditional statement.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>(While I was writing it I actually stopped for a second and mused about it… but I did not draw the right conclusion: not necessary right now, throw away.)</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Please note the strange letter passed into the function: Why a <code>*</code> which is not a valid layer letter? This is my way of making obvious that this function does not care about „correct“ diamond characters. It’s focused on the layout of whatever it gets.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>After I got the generation of a single layer working I move a one level up the function hierarchy. Doing one layer is integrated by a function for generating all unique layers:</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:image {"id":2678, "align": "center"} --></p>
<div class="wp-block-image">
<figure class="aligncenter"><figure class="wp-image-2678"><img loading="lazy"  src="https://ralfw.de/media/posts/133/DraggedImage-6-2.png" sizes="(max-width: 48em) 100vw, 768px" srcset="https://ralfw.de/media/posts/133/responsive/DraggedImage-6-2-xs.png 300w ,https://ralfw.de/media/posts/133/responsive/DraggedImage-6-2-sm.png 480w ,https://ralfw.de/media/posts/133/responsive/DraggedImage-6-2-md.png 768w ,https://ralfw.de/media/posts/133/responsive/DraggedImage-6-2-lg.png 1024w ,https://ralfw.de/media/posts/133/responsive/DraggedImage-6-2-xl.png 1360w ,https://ralfw.de/media/posts/133/responsive/DraggedImage-6-2-2xl.png 1600w"  alt="" width="1059" height="178"></figure></figure>
</div>
<p><!-- /wp:image --></p>
<p><!-- wp:paragraph --></p>
<p>This one again is so easy, I just use a single test to drive its production code. I dare to do that because C# is offering powerful abstractions like Linq; there are no more loops to get right.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:heading {"level":3} --></p>
<h3>Build diamond</h3>
<p><!-- /wp:heading --></p>
<p><!-- wp:paragraph --></p>
<p>Finally I get to the function building the diamond from the layers. This again is so simple I just need one test:</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:image {"id":2675, "align": "center"} --></p>
<div class="wp-block-image">
<figure class="aligncenter"><figure class="wp-image-2675"><img loading="lazy"  src="https://ralfw.de/media/posts/133/DraggedImage-7-2.png" sizes="(max-width: 48em) 100vw, 768px" srcset="https://ralfw.de/media/posts/133/responsive/DraggedImage-7-2-xs.png 300w ,https://ralfw.de/media/posts/133/responsive/DraggedImage-7-2-sm.png 480w ,https://ralfw.de/media/posts/133/responsive/DraggedImage-7-2-md.png 768w ,https://ralfw.de/media/posts/133/responsive/DraggedImage-7-2-lg.png 1024w ,https://ralfw.de/media/posts/133/responsive/DraggedImage-7-2-xl.png 1360w ,https://ralfw.de/media/posts/133/responsive/DraggedImage-7-2-2xl.png 1600w"  alt="" width="882" height="129"></figure></figure>
</div>
<p><!-- /wp:image --></p>
<p><!-- wp:paragraph --></p>
<p>As you can see the function consists of two parts. The levels of abstraction of its logic are not even: line 50 is slightly more abstract than line 51f. I need a bit more mental effort to understand what 51+52 are doing than what 50 does.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>But in the end it’s such a small function I don’t think more structure is needed. Or maybe this is a case where comments would help?</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:image {"id":2680, "align": "center"} --></p>
<div class="wp-block-image">
<figure class="aligncenter"><figure class="wp-image-2680"><img loading="lazy"  src="https://ralfw.de/media/posts/133/DraggedImage-8-2.png" sizes="(max-width: 48em) 100vw, 768px" srcset="https://ralfw.de/media/posts/133/responsive/DraggedImage-8-2-xs.png 300w ,https://ralfw.de/media/posts/133/responsive/DraggedImage-8-2-sm.png 480w ,https://ralfw.de/media/posts/133/responsive/DraggedImage-8-2-md.png 768w ,https://ralfw.de/media/posts/133/responsive/DraggedImage-8-2-lg.png 1024w ,https://ralfw.de/media/posts/133/responsive/DraggedImage-8-2-xl.png 1360w ,https://ralfw.de/media/posts/133/responsive/DraggedImage-8-2-2xl.png 1600w"  alt="" width="398" height="167"></figure></figure>
</div>
<p><!-- /wp:image --></p>
<p><!-- wp:heading {"level":3} --></p>
<h3>Crossing the finish line</h3>
<p><!-- /wp:heading --></p>
<p><!-- wp:paragraph --></p>
<p>That’s it. All functions from the design have been implemented. They are doing their partial jobs. That means all „musicians“ are ready, the instruments are tuned. It’s time for them to come together as a band and play a concert.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>I do this by calling the partial functions from the root function:</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:image {"id":2666, "align": "center"} --></p>
<div class="wp-block-image">
<figure class="aligncenter"><figure class="wp-image-2666"><img loading="lazy"  src="https://ralfw.de/media/posts/133/DraggedImage-9-2.png" sizes="(max-width: 48em) 100vw, 768px" srcset="https://ralfw.de/media/posts/133/responsive/DraggedImage-9-2-xs.png 300w ,https://ralfw.de/media/posts/133/responsive/DraggedImage-9-2-sm.png 480w ,https://ralfw.de/media/posts/133/responsive/DraggedImage-9-2-md.png 768w ,https://ralfw.de/media/posts/133/responsive/DraggedImage-9-2-lg.png 1024w ,https://ralfw.de/media/posts/133/responsive/DraggedImage-9-2-xl.png 1360w ,https://ralfw.de/media/posts/133/responsive/DraggedImage-9-2-2xl.png 1600w"  alt="" width="550" height="133"></figure></figure>
</div>
<p><!-- /wp:image --></p>
<p><!-- wp:paragraph --></p>
<p>Calling functions is the root function’s only responsibility. I call that <em>integration</em> (or composition) as opposed to <em>operation</em>. Operation is what the other functions are doing. They contain logic, they are the real workhorses of the solution.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>(With the exception of <code>GenerateUniqueLayers</code> which I also view as an integration due to its shortness and usage of Linq, even though it’s not just calling another function but wrapping that.)</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Coding the integration is easy by definition. It’s so easy in fact, that intermediate integrations in an IOSP-based function hierarchy hardly need testing at all. It’s the same as if you extracted a method during refactoring: you don’t put that under test immediately.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>With the root function, the function which the user/customer is interested in, filled out I check the acceptance test cases from the beginning… And lo and behold they are both green!</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>I’m done with solving the original problem.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:heading {"level":3} --></p>
<h3>Refactoring</h3>
<p><!-- /wp:heading --></p>
<p><!-- wp:paragraph --></p>
<p>So far no refactoring seemed necessary. Due to TBC the code already is very clean, I’d say: all functions are small, the integration gives a good overview of how the problem is solved, the SRP reigns.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Now that I’m finished, though, I step back and try to imagine how a future reader of the code (possibly myself) would experience it.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>The first thing I notice is that <code>Print</code> still is kind of fraught with details. I decide to extract another function:</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:image {"id":2677, "align": "center"} --></p>
<div class="wp-block-image">
<figure class="aligncenter"><figure class="wp-image-2677"><img loading="lazy"  src="https://ralfw.de/media/posts/133/DraggedImage-10-2.png" sizes="(max-width: 48em) 100vw, 768px" srcset="https://ralfw.de/media/posts/133/responsive/DraggedImage-10-2-xs.png 300w ,https://ralfw.de/media/posts/133/responsive/DraggedImage-10-2-sm.png 480w ,https://ralfw.de/media/posts/133/responsive/DraggedImage-10-2-md.png 768w ,https://ralfw.de/media/posts/133/responsive/DraggedImage-10-2-lg.png 1024w ,https://ralfw.de/media/posts/133/responsive/DraggedImage-10-2-xl.png 1360w ,https://ralfw.de/media/posts/133/responsive/DraggedImage-10-2-2xl.png 1600w"  alt="" width="648" height="256"></figure></figure>
</div>
<p><!-- /wp:image --></p>
<p><!-- wp:paragraph --></p>
<p>Now <code>Print</code> tells the story what a diamond production looks like in three easy „sentences“: <em>First calculate the size of the diamond by determining the layers it should consist of. Then actually generate those layers, but only the unique ones. Finally build the diamond from the layers.</em></p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>While reading this story no details of the processing steps are necessary to know. At first that’s what some developers cannot really accept; they tend to read the code depth-first. However, my approach favors breadth-first reasoning.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>And <code>GenerateUniqueLayers</code> is yet another integration which is focused on layer generation. It’s hiding the details of that so <code>Print</code> can be shorter and more conforming to the SLA principle.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Although IOSP-based code is easy to understand due to many small methods and clearly visible processes, code sometimes cannot tell the full story. Why are things how they are, what do certain terms mean?</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Even with this small example I felt that was the case. So I also added an introductory comment:</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:image {"id":2671, "align": "center"} --></p>
<div class="wp-block-image">
<figure class="aligncenter"><figure class="wp-image-2671"><img loading="lazy"  src="https://ralfw.de/media/posts/133/DraggedImage-11-2.png" sizes="(max-width: 48em) 100vw, 768px" srcset="https://ralfw.de/media/posts/133/responsive/DraggedImage-11-2-xs.png 300w ,https://ralfw.de/media/posts/133/responsive/DraggedImage-11-2-sm.png 480w ,https://ralfw.de/media/posts/133/responsive/DraggedImage-11-2-md.png 768w ,https://ralfw.de/media/posts/133/responsive/DraggedImage-11-2-lg.png 1024w ,https://ralfw.de/media/posts/133/responsive/DraggedImage-11-2-xl.png 1360w ,https://ralfw.de/media/posts/133/responsive/DraggedImage-11-2-2xl.png 1600w"  alt="" width="695" height="399"></figure></figure>
</div>
<p><!-- /wp:image --></p>
<p><!-- wp:paragraph --></p>
<p>To me comments are not a code small per se. It’s what the comments are used for that is important. Background information, documentation of decisions, some kind of glossary… all that and more can be valuable in code.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:heading {"level":3} --></p>
<h3>Deleting tests</h3>
<p><!-- /wp:heading --></p>
<p><!-- wp:paragraph --></p>
<p>Finally, now that I’m satisfied with my solution, a fundamental act of refactoring. It’s almost unheard of, I’d say, but I’m doing it on a regular basis as part of my approach: I delete tests.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Yes, that’s true. I delete tests which would make future refactorings harder.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>To see which tests are of no longterm use I simply set the accessibility of all methods to <code>private</code> which haven’t explicitly been ordered by the customer. Methods not used in acceptance tests are obviously not used and should be hidden as structural details.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>All methods of the single class of my solution except for <code>Print</code> thus go <code>private</code>. And all tests exercising these methods go red and are deleted. That’s seven test functions.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>The only remaining, stable, long term tests are the <em>acceptance tests</em>. Or more generally tests of methods which need to remain public on other classes I might have designed (or which were created during refactoring). Tests of methods on such classes which also haven’t been requested by the customer and might vanish at any time I call <em>module tests</em>.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>And the tests which just got deleted to me are <em>scaffolding tests</em>. Like a scaffold on a building they were useful while building up the logic. But once the logic is complete they are torn down like a scaffold on a building. Otherwise they would impede future changes of the overall structure.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>But isn’t it a waste of time to write those tests in the first place if they get thrown away? I don’t think so. They were of great help to develop logic function by function. They were like finely honed probes measuring some quality of my code at precise points. Also they can guide later decisions with regard to modularity: If I very much hesitate to delete a scaffolding test that might be a signal to extract a module on which the function under test is <code>public</code>.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>I would not have been able to drive my logic test-first at such detail and in such isolation only with tests going through the root function. „Pear programming“ to me is too inflexible, too cumbersome. I like fine grained control over my logic and tests. I like to build my ship outside the bottle before I shove it in and erect the masts.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:image {"id":2676, "align": "center"} --></p>
<div class="wp-block-image">
<figure class="aligncenter"><figure class="wp-image-2676"><img loading="lazy"  src="https://ralfw.de/media/posts/133/DraggedImage-12-1.png" sizes="(max-width: 48em) 100vw, 768px" srcset="https://ralfw.de/media/posts/133/responsive/DraggedImage-12-1-xs.png 300w ,https://ralfw.de/media/posts/133/responsive/DraggedImage-12-1-sm.png 480w ,https://ralfw.de/media/posts/133/responsive/DraggedImage-12-1-md.png 768w ,https://ralfw.de/media/posts/133/responsive/DraggedImage-12-1-lg.png 1024w ,https://ralfw.de/media/posts/133/responsive/DraggedImage-12-1-xl.png 1360w ,https://ralfw.de/media/posts/133/responsive/DraggedImage-12-1-2xl.png 1600w"  alt="" width="389" height="259"></figure></figure>
</div>
<p><!-- /wp:image --></p>
<p><!-- wp:paragraph --></p>
<p>Source: <a href="https://www.wikihow.com/Build-a-Ship-in-a-Bottle" target="_blank" rel="noopener">wikiHow: How to Build a Ship in a Bottle</a></p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>What I hear from developers trying one of the other TDD styles often is they feel trapped by all their tests. Refactoring becomes impossible without turning many tests red which then requires them to correct them.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>I’m suffering much less from such effects. Because I keep less tests around.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>The most important and long living tests are the acceptance tests. They exercise the logic in a solid way.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Module tests complement acceptance tests; they knit the safety net more finely. But if they turn red due to refactoring I’m very willing to throw them away instead of repairing them.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:heading {"level":2} --></p>
<h2>Summary</h2>
<p><!-- /wp:heading --></p>
<p><!-- wp:paragraph --></p>
<p>Hamburg style TDD is about thinking before coding, the absence of functional dependencies (substitutes are comparatively rarely used), and also about the „art of letting go“. Don’t attach yourself too much to your tests.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>It’s an outside-in approach to problem solving and programming.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<hr>
<p>PS: You might be wondering if all this leads to overengineering. So many functions… isn’t that much overhead?</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Well… this is the alternative: The same logic sitting in just a single function.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:image {"id":2673, "align": "center"} --></p>
<div class="wp-block-image">
<figure class="aligncenter"><figure class="wp-image-2673"><img loading="lazy"  src="https://ralfw.de/media/posts/133/DraggedImage-13-1.png" sizes="(max-width: 48em) 100vw, 768px" srcset="https://ralfw.de/media/posts/133/responsive/DraggedImage-13-1-xs.png 300w ,https://ralfw.de/media/posts/133/responsive/DraggedImage-13-1-sm.png 480w ,https://ralfw.de/media/posts/133/responsive/DraggedImage-13-1-md.png 768w ,https://ralfw.de/media/posts/133/responsive/DraggedImage-13-1-lg.png 1024w ,https://ralfw.de/media/posts/133/responsive/DraggedImage-13-1-xl.png 1360w ,https://ralfw.de/media/posts/133/responsive/DraggedImage-13-1-2xl.png 1600w"  alt="" width="605" height="349"></figure></figure>
</div>
<p><!-- /wp:image --></p>
<p><!-- wp:paragraph --></p>
<p>Is that, what you like to see when asked to fix a bug? Multiply the number of lines by 2, 5, 10, 50 because that’s how long functions in „real code bases“ usually are; even methods with 5000 lines of code and more are not unheard of.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Functions not following the IOSP tend to grow indefinitely. There are no boundaries to growth. And the general recommendation „keep your functions small“ is pretty fuzzy. What does „small“ exactly mean? And where to stop, what else to do?</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>The IOSP is a great guideline towards codebases with all small functions.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>But the above function still is small. Why have more than one function? Reason no. 1: Because this is an exercise. Reason no. 2: Even small functions can contain logic that is hard to get right. Wouldn’t you want to be able to check that easily?</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>But the above function is not what a classic TDD approach – aka „pear programming“ – would have led to. Fewer functions would have been extracted from the growing logic in the single function under test.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>That’s true. But firstly refactoring is hard and easy to avoid. Secondly the result probably would have been a root function not conforming to the SLA: there would be a mixture of logic and function calls in it. That would not be easy to understand.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Finally I find code refactored from functions with functional dependencies and driven by TDD often not easy to read because it’s hard to extract responsibilities cleanly once they were entwined. Sure, not to refactor is no solution. But not having to refactor due to a clean design before coding leads to better results in my experience.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p> </p>
<p>PPS: It’s never over! Today’s clean code is tomorrows dirty code.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Cleanliness of code is subjective and relative to your understanding/knowledge. If you gain new insights clean code you wrote yesterday will turn into somewhat dirty code.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>A case in point the <code>BuildDiamond</code> function. I expressed some concern regarding it and even suggested comments to improve it. But just know I had another idea:</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:image {"id":2681, "align": "center"} --></p>
<div class="wp-block-image">
<figure class="aligncenter"><figure class="wp-image-2681"><img loading="lazy"  src="https://ralfw.de/media/posts/133/DraggedImage-14-1.png" sizes="(max-width: 48em) 100vw, 768px" srcset="https://ralfw.de/media/posts/133/responsive/DraggedImage-14-1-xs.png 300w ,https://ralfw.de/media/posts/133/responsive/DraggedImage-14-1-sm.png 480w ,https://ralfw.de/media/posts/133/responsive/DraggedImage-14-1-md.png 768w ,https://ralfw.de/media/posts/133/responsive/DraggedImage-14-1-lg.png 1024w ,https://ralfw.de/media/posts/133/responsive/DraggedImage-14-1-xl.png 1360w ,https://ralfw.de/media/posts/133/responsive/DraggedImage-14-1-2xl.png 1600w"  alt="" width="425" height="111"></figure></figure>
</div>
<p><!-- /wp:image --></p>
<p><!-- wp:paragraph --></p>
<p>This to me is cleaner. It’s the same functionality, hence I call it a refactoring. But instead of extracting structures I redesign the approach to solving this partial problem and implemented it using more of the power of Linq. Now the function shows better SLA; no comments are needed.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>I changed the logic even without the scaffolding tests being present anymore. I was confident the acceptance tests would catch any regression.</p>
<p><!-- /wp:paragraph --></p>
            ]]>
        </content>
    </entry>
    <entry>
        <title>Hamburg Style TDD</title>
        <author>
            <name>Ralf Westphal</name>
        </author>
        <link href="https://ralfw.de/hamburg-style-tdd/"/>
        <id>https://ralfw.de/hamburg-style-tdd/</id>
            <category term="TDD"/>

        <updated>2021-01-28T19:42:05+08:00</updated>
            <summary>
                <![CDATA[
                    There are a number of „TDD styles“ (or even „schools of TDD“): And I cannot identify myself with any of them. Not 100% at least. Recently I attended a talk by Marco Emrich who showed the above styles next to each other - and I&hellip;
                ]]>
            </summary>
        <content type="html">
            <![CDATA[
                <p><!-- wp:paragraph --></p>
<p>There are a number of „TDD styles“ (or even „schools of TDD“):</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:list {"ordered":false} --></p>
<ul>
<li><a href="https://8thlight.com/blog/georgina-mcfadyen/2016/06/27/inside-out-tdd-vs-outside-in.html" target="_blank" rel="noopener">Chicago style</a></li>
<li><a href="https://8thlight.com/blog/georgina-mcfadyen/2016/06/27/inside-out-tdd-vs-outside-in.html" target="_blank" rel="noopener">London style</a></li>
<li><a href="https://de.slideshare.net/davidvoelkel/fake-it-outsidein-tdd-xp2017" target="_blank" rel="noopener">Munich style</a></li>
</ul>
<p><!-- /wp:list --></p>
<p><!-- wp:paragraph --></p>
<p>And I cannot identify myself with any of them. Not 100% at least.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Recently I attended a talk by <a href="https://twitter.com/marcoemrich" target="_blank" rel="noopener">Marco Emrich</a> who showed the above styles next to each other - and I kept shaking my head. There was some usefulness to all of them, but none really convinced me.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Then I saw a tweet by <a href="https://twitter.com/davidvoelkel" target="_blank" rel="noopener">David Völkel</a> in which he mentioned doing the Diamond kata „Munich style“. That triggered me to do it, too - and also Marco’s example from his talk, the Bank kata.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:heading {"level":2} --></p>
<h2>Styleguide</h2>
<p><!-- /wp:heading --></p>
<p><!-- wp:paragraph --></p>
<p>But what am I doing differently? Am I doing some kind of TDD at all? What’s TDD in the first place?</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:heading {"level":3} --></p>
<h3>My understanding of TDD</h3>
<p><!-- /wp:heading --></p>
<p><!-- wp:paragraph --></p>
<p>TDD is mainly characterized by a simple process with three steps:</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:list {"ordered":true} --></p>
<ol>
<li>Red</li>
<li>Green</li>
<li>Refactor</li>
</ol>
<p><!-- /wp:list --></p>
<p><!-- wp:paragraph --></p>
<p>That means it’s a test-first approach to programming: first write a not passing test (red), then write production code to make the test pass (green).</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>What takes it beyond test-first, though, is the refactoring step. By that TDD acknowledges that production code should not only pass tests, i.e. show some runtime behavior, but also be of a certain form (which is not relevant to its behavior).</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Also TDD clearly states its process should be run through multiple times. TDD explicitly is an iterative approach to programming.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>And then TDD urges you to let test cases increase in their difficulty from iteration to iteration. With each iteration a bit more value is added to the production code. TDD thus also an explicitly incremental approach to programming.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>There is little said, however, about how each step should be performed. But getting a test to green should only involve the simplest possible addition to the production code (application of KISS principle). And refactoring should eliminate duplication.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Since Kent Beck is the „inventor“ of TDD it’s no small wonder that also his „<a href="https://martinfowler.com/bliki/BeckDesignRules.html" target="_blank" rel="noopener">for elements of simple design</a>“ are of relevance:</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:list {"ordered":false} --></p>
<ul>
<li>Passes the tests</li>
<li>Reveals intention</li>
<li>No duplication</li>
<li>Fewest elements</li>
</ul>
<p><!-- /wp:list --></p>
<p><!-- wp:paragraph --></p>
<p>That’s pretty much it, I guess. That’s TDD. Easily stated - but difficult to implement. The problems start, I think, when applying all this blindly. Rules seem to ask for obedience. And so developers are trying to obey - with very mixed results and quite some frustration.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>No small wonder, different „schools of TDD“ emerged.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>The matter is and the problems are too complex for a single set of rules and a single approach. On top of that there is probably an unknown amount of loss in communicating TDD: Kent Beck surely is the master of TDD - but does he (or even can he) convey everything he does/think/know in a book or several blog posts? I don’t think so.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>When communicating one’s own „being“ much cannot be said explicitly. Much is falling through the cracks when preparing a descriptive document. Being can only fully be experienced by watching someone in a not prepared situation.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>What happens when a lossy communication is taken for something lossless? Confusion ensues. Applying the lossy content will not lead to the same results as for the originator. This leads to frustration, conflicts, lots of discussion, or worse.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>This has happened for Agility in general and also for TDD as part of Agility, I think.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:heading {"level":3} --></p>
<h3>Only experience counts</h3>
<p><!-- /wp:heading --></p>
<p><!-- wp:paragraph --></p>
<p>From the inevitability of lossy communication (and before that reflection about one’s actions) follows that adherence to rules cannot be the goal.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p><strong>Rules are nothing! The only thing that counts is success. If you consistently experience success without following certain rules, whatever you do is superior to the rules.</strong></p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Rules thus are only suggestions for how to achieve results. Nothing more, nothing less. They are invitations - and can be declined.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Follow rules at your own peril.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Don’t follow rules at your own peril.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>To improve your results, your task is not to follow rules, but to evaluate your actions - and then adjust your approach if you find the results lacking some quality. You cannot offload responsibility for results to certain rules. The responsibility always is with you.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Kent Beck, Robert C. Martin, J.B. Rainsberger, David Völkel, or Ralf Westphal are only reporting (personal) experiences and their humble reflections on why they think there might be causal connections between doing something and getting certain results.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>If you feel inspired by that and try to reproduce their results, stay alert. Lots of things can go wrong. And not all that was going on when they made their experiences has been/could be reported.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Trying harder to follow whatever account you read to overcome some information loss thus is natural. Also it’s natural to adapt whatever you’ve heard to your situation. You’re entitled to your own experiences and reflections. Maybe they just deviate from what you’ve read, maybe they are in outright opposition.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Any result, any approach is ok. Just remember: reflect on it.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:heading {"level":3} --></p>
<h3>My reflections</h3>
<p><!-- /wp:heading --></p>
<p><!-- wp:paragraph --></p>
<p>That’s what I’ve done: I reflected on why I wasn’t satisfied with the results I got from applying TDD.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>To make a long story short, what I found was: TDD was playing dumb.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>TDD is a problem solving tool. The problem being: conversion of requirements into code. And to be more precise: into logic plus structure. Logic to create the desired behavior at runtime, structure to keep programmer productivity high over an indefinite period of time. TDD is about functional and clean code.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>That’s great! I’m all for this result.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>But I beg to differ with regard to the approach.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Where I agree:</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:list {"ordered":false} --></p>
<ul>
<li>I agree with the basic test-first approach of TDD.</li>
<li>I agree with the importance of refactoring.</li>
<li>I agree with revealing intentions.</li>
<li>I agree with avoiding duplication.</li>
<li>I agree with avoiding overengineering.</li>
<li>I agree with the importance of passing all tests.</li>
</ul>
<p><!-- /wp:list --></p>
<p><!-- wp:paragraph --></p>
<p>But there are a couple of points I don’t agree with:</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:list {"ordered":false} --></p>
<ul>
<li>Refactoring is great. But even better is to not need to refactor. If I can come up with (pretty) clean code right from the start, why should I refactor.</li>
<li>What to refactor to? TDD is barely making any statement about that, which is one of the reasons why many supposedly TDD based solutions I’ve seen are… not clean.</li>
<li>Overengineering sure is an evil to avoid. But something that might look like overengineering to the code author today might be a helpful structure to a code reader tomorrow. Where to draw the line? My feeling is, TDD users are carried away too often by the mentions of KISS and „fewest elements“. „Elegance“ is still in high esteem, even though it’s a twin of obscurity.</li>
</ul>
<p><!-- /wp:list --></p>
<p><!-- wp:paragraph --></p>
<p>And finally: What’s bugging me again and again when looking at TDD examples is the neglect of easily achievable insight. TDD proponents are dumbing themselves (and thus the process) down in a drive to… hm… to what? Maybe to avoid overengineering? Or to go faster while writing code?</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Yes, I guess it’s the will to be faster and to avoid BDUF. BDUF is costing time now and time later when it needs to get adapted to new information. BDUF is bad. We know that, right?</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Sure, BDUF is bad. By definition. It’s evil because of the B. <em>Big</em> design is deferring feedback.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>DUF, though, is not bad in my experience. Designing a solution before coding is even inevitable. At least I need to think before coding. I need to make a plan before I create structures and arrange logic. Sometimes the thinking takes 10 seconds, sometimes 10 minutes or 30 minutes.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>TBC (Thinking Before Coding) to me is essential. It’s a discipline of its own. It needs to be trained, it needs to be taught.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>But TBC has vanished from curricula and is not visible in popular TDD examples.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>I’m not saying TDD proponents are not thinking before coding. What I’m trying to get across is that such thinking is not made explicit. It has no form. It’s not expressed in code or in any other way.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>The incremental tests of TDD are no expression of such TBC in my view. Because test cases are only about understanding requirements, not designing a solution. Tests are no models.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Models, however, are badly needed, if coding is supposed to progress smoothly.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:heading {"level":2} --></p>
<h2>The perennial cycle of software development</h2>
<p><!-- /wp:heading --></p>
<p><!-- wp:paragraph --></p>
<p>I want to add another iterative process to TDD’s red-green-refactor (RGR). It’s simple, it’s natural, it’s even inevitable:</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:list {"ordered":false} --></p>
<ul>
<li>Analyze</li>
<li>Design</li>
<li>Code</li>
</ul>
<p><!-- /wp:list --></p>
<p><!-- wp:paragraph --></p>
<p>The ADC iterations are sometimes congruent with the RGR iterations, but sometimes not. RGR can happen inside of C.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>In any case I find it important to emphasize these three step process because I think it’s what software development is about, and not only software development if you replace „Code“ with some other implementation discipline like „Paint“ or „Cook“.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>ADC is to be cycled through many times on different levels of detail. It’s to be used iteratively and even incrementally if possible.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>And, yes, the D sits right before the C. So it’s design „upfront“, it’s thinking before coding. Like it’s listening and asking before designing.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>In my „school of TDD“ „students“ are asked to first analyze requirements. That means they need to build a solid understanding of the problem. And they need to express this understanding in an unambiguous form open to scrutiny.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Only once understanding is clear they move on to create a model for a solution to the problem. A model is the result of the design step. But of course a model is not „the real thing“, it’s not the solution yet. A model is a more or less abstract description of an approach to solve a problem. It’s declarative, whereas the solution, the logic is imperative.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>And finally they implement their model using the means of a programming language. Implementation is guided by the model and thus produces less waste. To me implementation mostly is boring and a comparatively mechanical task. Designing the model on the other hand is exciting and highly creative.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>My feeling is, design (and also analysis) are underrated steps in software development. And coding is an overrated step.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Making the ADC loop explicit is thus what I find important. It’s more important than doing TDD the Chicago style or London style. Hence I’d call my approach to TDD eclectic. It’s drawing from all styles if that’s what’s needed to further the cause of creating correct code plus clean code.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>However, there’s one main distinction which leads to a different stance regarding mocks and other substitutes: I believe that functional dependencies are to be avoided as much as possible. They make code hard to read and hard to test. What my design and then coding are striving for is adherence to the <a href="https://blog.ralfw.de/2013/01/beispielhafte-nichtbeachtung.html" target="_blank" rel="noopener">IOSP (Integration Operation Segregation Principle)</a> which I derived a couple of years ago from Alan Kay’s definition of object-orientation.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>But enough with all the theory. What does „Hamburg style TDD“ look like when applied? Check out the following articles for demonstrations:</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<ul>
<li><a href="https://ralfw.de/hamburg-style-tdd-diamond-kata/">Diamond kata</a></li>
<li><a href="https://ralfw.de/hamburg-style-tdd-bank-kata/">Bank kata</a></li>
</ul>
<p><!-- /wp:paragraph --></p>
            ]]>
        </content>
    </entry>
    <entry>
        <title>Command Query Notification Separation (CQNS)</title>
        <author>
            <name>Ralf Westphal</name>
        </author>
        <link href="https://ralfw.de/command-query-notification-separation-cqns/"/>
        <id>https://ralfw.de/command-query-notification-separation-cqns/</id>
            <category term="Event-Orientation"/>

        <updated>2021-01-28T19:44:16+08:00</updated>
            <summary>
                <![CDATA[
                        <img src="https://ralfw.de/media/posts/131/DraggedImage-11-1.png" alt="" />
                    CQS (Command Query Separation) is a well known principle for disentangling method responsibilities in OO software. I had known it for quite some time, but only recently actually have taken it to heart. And now I’m really loving it. I cannot imagine doing without it.
                ]]>
            </summary>
        <content type="html">
            <![CDATA[
                    <img src="https://ralfw.de/media/posts/131/DraggedImage-11-1.png" alt="" />
                <p><!-- wp:paragraph --></p>
<p><a href="https://en.wikipedia.org/wiki/Command%E2%80%93query_separation" target="_blank" rel="noopener">CQS (Command Query Separation)</a> is a well known principle for disentangling method responsibilities in OO software.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>I had known it for quite some time, but only recently actually have taken it to heart. And now I’m really loving it. I cannot imagine doing without it. It’s a great guidance when designing single classes or whole service processes.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>And then there is <a href="https://martinfowler.com/bliki/CQRS.html" target="_blank" rel="noopener">CQRS</a> which builds on CQS. I like that, too. It’s been a great inspiration.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>But <a href="https://ralfw.de/food-truck-architecture-its-all-about-events/">then I felt the need to move beyond it</a>: CQS does not cover the „message reality“ I’m encountering. And CQRS does deliver the flexibility I expected from giving up „the single model“.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:heading {"level":2} --></p>
<h2>Code structure guided by CQS</h2>
<p><!-- /wp:heading --></p>
<p><!-- wp:paragraph --></p>
<p>To distinguish between Commands and Queries is a great guidance for structuring code. It’s a form of outside-in design, I’d say: You’re looking at the interactions of users (or more generally: the environment) with a system by sending/receiving messages and from that derive a certain structure.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:image {"id":2656, "align": "center"} --></p>
<div class="wp-block-image">
<figure class="aligncenter"><figure class="wp-image-2656"><img loading="lazy"  src="https://ralfw.de/media/posts/131/DraggedImage-15.png" sizes="(max-width: 48em) 100vw, 768px" srcset="https://ralfw.de/media/posts/131/responsive/DraggedImage-15-xs.png 300w ,https://ralfw.de/media/posts/131/responsive/DraggedImage-15-sm.png 480w ,https://ralfw.de/media/posts/131/responsive/DraggedImage-15-md.png 768w ,https://ralfw.de/media/posts/131/responsive/DraggedImage-15-lg.png 1024w ,https://ralfw.de/media/posts/131/responsive/DraggedImage-15-xl.png 1360w ,https://ralfw.de/media/posts/131/responsive/DraggedImage-15-2xl.png 1600w"  alt="" width="528" height="222"></figure></figure>
</div>
<p><!-- /wp:image --></p>
<p><!-- wp:image {"id":2647, "align": "center"} --></p>
<div class="wp-block-image">
<figure class="aligncenter"><figure class="wp-image-2647"><img loading="lazy"  src="https://ralfw.de/media/posts/131/DraggedImage-1-1.png" sizes="(max-width: 48em) 100vw, 768px" srcset="https://ralfw.de/media/posts/131/responsive/DraggedImage-1-1-xs.png 300w ,https://ralfw.de/media/posts/131/responsive/DraggedImage-1-1-sm.png 480w ,https://ralfw.de/media/posts/131/responsive/DraggedImage-1-1-md.png 768w ,https://ralfw.de/media/posts/131/responsive/DraggedImage-1-1-lg.png 1024w ,https://ralfw.de/media/posts/131/responsive/DraggedImage-1-1-xl.png 1360w ,https://ralfw.de/media/posts/131/responsive/DraggedImage-1-1-2xl.png 1600w"  alt="" width="526" height="248"></figure></figure>
</div>
<p><!-- /wp:image --></p>
<p><!-- wp:paragraph --></p>
<p>Example: A player makes a move in a Tic Tac Toe game application.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Technically that means a user sends a message to the application with data about the move and receives back a message telling her the new game state.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Or more specifically this is a request for a certain behavior expressed in a response plus a change to some internal state.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:image {"id":2649, "align": "center"} --></p>
<div class="wp-block-image">
<figure class="aligncenter"><figure class="wp-image-2649"><img loading="lazy"  src="https://ralfw.de/media/posts/131/DraggedImage-2-1.png" sizes="(max-width: 48em) 100vw, 768px" srcset="https://ralfw.de/media/posts/131/responsive/DraggedImage-2-1-xs.png 300w ,https://ralfw.de/media/posts/131/responsive/DraggedImage-2-1-sm.png 480w ,https://ralfw.de/media/posts/131/responsive/DraggedImage-2-1-md.png 768w ,https://ralfw.de/media/posts/131/responsive/DraggedImage-2-1-lg.png 1024w ,https://ralfw.de/media/posts/131/responsive/DraggedImage-2-1-xl.png 1360w ,https://ralfw.de/media/posts/131/responsive/DraggedImage-2-1-2xl.png 1600w"  alt="" width="531" height="250"></figure></figure>
</div>
<p><!-- /wp:image --></p>
<p><!-- wp:paragraph --></p>
<p>The frontend first is used as an editor for the request message. A player certainly does not want to type in a JSON document but rather would like to just click on a cell on some visual game board.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>And then the frontend is used as a projector for the response message. A player certainly does not want to interpret a JSON document but rather would like to see the game state rendered as a visual game board.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:image {"id":2648, "align": "center"} --></p>
<div class="wp-block-image">
<figure class="aligncenter"><figure class="wp-image-2648"><img loading="lazy"  src="https://ralfw.de/media/posts/131/DraggedImage-3-1.png" sizes="(max-width: 48em) 100vw, 768px" srcset="https://ralfw.de/media/posts/131/responsive/DraggedImage-3-1-xs.png 300w ,https://ralfw.de/media/posts/131/responsive/DraggedImage-3-1-sm.png 480w ,https://ralfw.de/media/posts/131/responsive/DraggedImage-3-1-md.png 768w ,https://ralfw.de/media/posts/131/responsive/DraggedImage-3-1-lg.png 1024w ,https://ralfw.de/media/posts/131/responsive/DraggedImage-3-1-xl.png 1360w ,https://ralfw.de/media/posts/131/responsive/DraggedImage-3-1-2xl.png 1600w"  alt="" width="651" height="179"></figure></figure>
</div>
<p><!-- /wp:image --></p>
<p><!-- wp:paragraph --></p>
<p>The domain or game logic itself is encapsulated in the backend with which the frontend is conversing only through messages. <a href="https://ralfw.de/sleepy-hollow-architecture-no-application-should-be-without-it/">Frontend and backend don’t should share state, in my view</a>.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>So far so normal. A request is transformed into a state change plus a response. All the necessary logic is a big lump.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>However, when applying the CQS to this, the request-response message flow can be dissected into a command followed by a query:</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:list {"ordered":false} --></p>
<ul>
<li>First the command orders the backend to execute the move; the internal state of the backend is changed. This order of course is only carried out if the move is valid and the state’s consistency is not compromised.</li>
<li>Then the query asks the backend for a description of its internal state.</li>
</ul>
<p><!-- /wp:list --></p>
<p><!-- wp:image {"id":2651, "align": "center"} --></p>
<div class="wp-block-image">
<figure class="aligncenter"><figure class="wp-image-2651"><img loading="lazy"  src="https://ralfw.de/media/posts/131/DraggedImage-4-1.png" sizes="(max-width: 48em) 100vw, 768px" srcset="https://ralfw.de/media/posts/131/responsive/DraggedImage-4-1-xs.png 300w ,https://ralfw.de/media/posts/131/responsive/DraggedImage-4-1-sm.png 480w ,https://ralfw.de/media/posts/131/responsive/DraggedImage-4-1-md.png 768w ,https://ralfw.de/media/posts/131/responsive/DraggedImage-4-1-lg.png 1024w ,https://ralfw.de/media/posts/131/responsive/DraggedImage-4-1-xl.png 1360w ,https://ralfw.de/media/posts/131/responsive/DraggedImage-4-1-2xl.png 1600w"  alt="" width="652" height="273"></figure></figure>
</div>
<p><!-- /wp:image --></p>
<p><!-- wp:paragraph --></p>
<p>What has been a single lump of logic now is two smaller lumps of logic. How cool is that? And all this without much creativity. The user’s requirement guided the design. Software development just needs to listen.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>The tangible outcomes of a CQS-guided analysis are:</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:list {"ordered":false} --></p>
<ul>
<li>A command message (data structure)</li>
<li>A query result message (data structure)</li>
<li>A query message (data structure; maybe only for internal use)</li>
<li>A command status message (data structure; maybe only for internal use)</li>
<li>A command handler (function)</li>
<li>A query handler (function)</li>
<li>A request handler (function; optional for hiding the command and query handler from the frontend for less traffic between frontend and backend)</li>
</ul>
<p><!-- /wp:list --></p>
<p><!-- wp:paragraph --></p>
<p>I like this almost mechanically generated basic structure for my source code. It makes me focus more on the conversation with the user/customer because it’s from there I gain valuable first insights about the software design.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:heading {"level":2} --></p>
<h2>Message structure freed up by Event-Orientation</h2>
<p><!-- /wp:heading --></p>
<p><!-- wp:paragraph --></p>
<p>This is, what CQS does already. It’s a great help, but still leaves something to be desired.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>What I found quite difficult for a long time was „message design“. How should messages look like, what structure should they have? How should this structure look like compared to the internal domain model?</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>CQS does not have an answer to that. CQRS on the other hand suggested to take it easier: there could be two models, one for commands and another one for queries.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>But still I felt compelled to find the one model for handling commands, and the other one model for satisfying queries.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>It took me a while to let go of that restriction.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Today, with <a href="https://ralfw.de/food-truck-architecture-its-all-about-events/">Event-Orientation (EO)</a> I don’t feel any restriction anymore. And I don’t feel I need to get „it“ right anymore „once and for all“.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>The internal state of an application is not kept in a single (or two or three) data models anymore. I allow myself to program „model free“ or „schemaless“.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:quote --></p>
<blockquote class="wp-block-quote">
<p>The model is dead! Long live the model multitude!</p>
</blockquote>
<p><!-- /wp:quote --></p>
<p><!-- wp:paragraph --></p>
<p>Each and every message is handled individually and is supported by the best model I can think of for that single purpose. With EO I feel free to let message structures be preliminary. They can be honed for consumption by the frontend; the backend then is a true service by catering to the needs of its client. Or message structures can be more palatable for the backend; the frontend then is more of a „slave“ to the provider of the core application behavior, the backend.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>I remember how discussions about message structure took up quite some time during modelling sessions. Not anymore. Because there is no question anymore about how much a message model might couple frontend and backend.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>There simply is no domain model anymore in the backend. There cannot be any coupling. Whatever a message carries is a projection or something that needs projection. It’s not some form of copy or part of a domain model.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Message structures are freed up by EO to look how they want. The internal state of an EO-based backend is something completely different: a stream of events.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:image {"id":2652, "align": "center"} --></p>
<div class="wp-block-image">
<figure class="aligncenter"><figure class="wp-image-2652"><img loading="lazy"  src="https://ralfw.de/media/posts/131/DraggedImage-5-1.png" sizes="(max-width: 48em) 100vw, 768px" srcset="https://ralfw.de/media/posts/131/responsive/DraggedImage-5-1-xs.png 300w ,https://ralfw.de/media/posts/131/responsive/DraggedImage-5-1-sm.png 480w ,https://ralfw.de/media/posts/131/responsive/DraggedImage-5-1-md.png 768w ,https://ralfw.de/media/posts/131/responsive/DraggedImage-5-1-lg.png 1024w ,https://ralfw.de/media/posts/131/responsive/DraggedImage-5-1-xl.png 1360w ,https://ralfw.de/media/posts/131/responsive/DraggedImage-5-1-2xl.png 1600w"  alt="" width="441" height="463"></figure></figure>
</div>
<p><!-- /wp:image --></p>
<p><!-- wp:paragraph --></p>
<p>To change the state through a command it has to be translated into a collection of events.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>And to query the state the events in the stream have to be aggregated and projected into a result.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>The proposition of EO is that such translations and aggregations/projections are all separate. By default they don’t share anything. No coupling, no dependency between them - except for the one event stream.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:image {"id":2655, "align": "center"} --></p>
<div class="wp-block-image">
<figure class="aligncenter"><figure class="wp-image-2655"><img loading="lazy"  src="https://ralfw.de/media/posts/131/DraggedImage-6-1.png" sizes="(max-width: 48em) 100vw, 768px" srcset="https://ralfw.de/media/posts/131/responsive/DraggedImage-6-1-xs.png 300w ,https://ralfw.de/media/posts/131/responsive/DraggedImage-6-1-sm.png 480w ,https://ralfw.de/media/posts/131/responsive/DraggedImage-6-1-md.png 768w ,https://ralfw.de/media/posts/131/responsive/DraggedImage-6-1-lg.png 1024w ,https://ralfw.de/media/posts/131/responsive/DraggedImage-6-1-xl.png 1360w ,https://ralfw.de/media/posts/131/responsive/DraggedImage-6-1-2xl.png 1600w"  alt="" width="597" height="403"></figure></figure>
</div>
<p><!-- /wp:image --></p>
<p><!-- wp:paragraph --></p>
<p>That makes message processing in both directions cheap. And it allows for independent development. EO slices an application not only into services but into message processing pipelines each catering to just a single message.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Deciding today that the TicTacToe game state query result should look like this, and tomorrow changing the decision to let it look like that is comparatively easy. It has no impact on some comprehensive domain model relevant to many messages.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>The contract between message pipelines are just event data types. They are the core representation of the domain. <strong>Look at the events and you know what the domain is about. Events are telling a story about what is happening, what is deemed important, what the causal sequences are.</strong></p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>And this <a href="https://ralfw.de/event-sourcing-for-constructivist-software/">can be interpreted in a million ways</a>, or at least as many ways as there are incoming message types to handle.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:heading {"level":2} --></p>
<h2>Notifications as ambient messages</h2>
<p><!-- /wp:heading --></p>
<p><!-- wp:paragraph --></p>
<p>CQS primarily distinguishes two kinds of messages: commands and queries.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>That’s incoming messages. How about outgoing ones? I’d like to make explicit also two respective outgoing messages: command status and query result. Command status messages might be quite simple and generic (success vs failure), but query results surely are of very different form and need careful design.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>However, in my experience there is a fifth message type. It’s particular because it’s not a request. Commands and queries stand for bidirectional message flow: a client sends a request (command or query) and expects a response (command status or query result).</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Sometimes, though, messages are not produced with a certain expectation for a behavior of another (part of) a system. Sometimes messages are just „utterances“ of a system broadcast „to whom it may concern“.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>I call such messages <em>notifications</em>.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Usually the name for them is „event“ with a prefix or suffix (like „domain event“). But that clashes with the data stored in an event stream inside of a system. I don’t like such homonymes.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>„Notification“ is a term everyone is familiar with: we are notified about emails arriving in our inboxes or new messages in a Slack channel or of an overdue backup etc.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>A lot of applications are broadcasting notifications to inform us about something that has happened/changed. And we are free to subscribe to such notifications. Some we are interested in, some not.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>If we receive a notification we might react, eg. open the mail client to check our inbox. But the broadcasting application did not request such a reaction.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Notifications are one way messages. Software broadcasts them through some channel/medium as outgoing notifications. And other software might subscribe to a channel/medium to receive notifications from other software as incoming messages.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:image {"id":2653, "align": "center"} --></p>
<div class="wp-block-image">
<figure class="aligncenter"><figure class="wp-image-2653"><img loading="lazy"  src="https://ralfw.de/media/posts/131/DraggedImage-7-1.png" sizes="(max-width: 48em) 100vw, 768px" srcset="https://ralfw.de/media/posts/131/responsive/DraggedImage-7-1-xs.png 300w ,https://ralfw.de/media/posts/131/responsive/DraggedImage-7-1-sm.png 480w ,https://ralfw.de/media/posts/131/responsive/DraggedImage-7-1-md.png 768w ,https://ralfw.de/media/posts/131/responsive/DraggedImage-7-1-lg.png 1024w ,https://ralfw.de/media/posts/131/responsive/DraggedImage-7-1-xl.png 1360w ,https://ralfw.de/media/posts/131/responsive/DraggedImage-7-1-2xl.png 1600w"  alt="" width="498" height="263"></figure></figure>
</div>
<p><!-- /wp:image --></p>
<p><!-- wp:paragraph --></p>
<p>I call notifications <em>ambient messages</em> because they „float around in the environment“ and are not directed. They have a source, but no destination.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>From that follows there is no guarantee that a notification will be handled at all. Notifications thus cannot carry requests. Their purpose solely is to inform about something that happened. They make a statement about the originating system - for others to possibly care for.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Notifications might be more relevant in distributed systems. Nevertheless I think they are a very general concept and thus should be included in the CQS principle. Hence I propose to expand it to:</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:quote --></p>
<blockquote class="wp-block-quote">
<p>CQNS: Command Query Notification Separation principle</p>
</blockquote>
<p><!-- /wp:quote --></p>
<p><!-- wp:paragraph --></p>
<p>The form of notifications is considerably different (being one-way messages). And their processing is different, too, I think.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:list {"ordered":true} --></p>
<ol>
<li>Notifications do not query state, because there would be no receiver for a query result.</li>
<li>Notifications do not change state; that’s what commands are for.</li>
<li><strong>The single responsibility of incoming notifications is to cause commands to be executed inside a receiver.</strong> However the command status messages generated by the triggered commands are not delivered to the originator of the notification.</li>
</ol>
<p><!-- /wp:list --></p>
<p><!-- wp:paragraph --></p>
<p>So much for incoming notifications.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>But where do outgoing notifications come from?</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:list {"ordered":false} --></p>
<ul>
<li><strong>Outgoing notifications are generated during command processing.</strong> Only commands change state, and notifications are signalling state change.</li>
</ul>
<p><!-- /wp:list --></p>
<p><!-- wp:paragraph --></p>
<p>Notifications help to further structure code from the outside-in:</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:list {"ordered":false} --></p>
<ul>
<li>Handling incoming notifications requires logic to translate them into commands.</li>
<li>Command processing consists not only of
<ol>
<li>model generation,</li>
<li>command validation,</li>
<li>event generation,</li>
<li>but also of generating outgoing notifications.</li>
</ol>
</li>
</ul>
<p>That, to me, makes requirements analysis yet easier and delivers more input for further software design.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>In a gaming scenario there could be two services: one for playing a game like TicTacToe and one for keeping a score board.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Both services could be connected in a request/response manner, for example, for registering the score of a finished game: the TicTacToe service could send a command to the score board service to inform it of another finished game and who has won. But why couple the services so tightly? The TicTacToe service would now depend on another service, it could not do its job without the other.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Instead a notification can be used to more loosely couple both service. With a notification they would not even know of each other.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:list {"ordered":false} --></p>
<ul>
<li>The TicTacToe service would broadcast a notification when a game finishes, e.g. by writing it to a queue hosted by some infrastructure.</li>
<li>The score board service would subscribe to „game over“ notifications arriving in a queue hosted by some infrastructure.</li>
</ul>
<p><!-- /wp:list --></p>
<p><!-- wp:paragraph --></p>
<p>One service’s outgoing notification is another service’s incoming notification.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:image {"id":2657, "align": "center"} --></p>
<div class="wp-block-image">
<figure class="aligncenter"><figure class="wp-image-2657"><img loading="lazy"  src="https://ralfw.de/media/posts/131/DraggedImage-8-1.png" sizes="(max-width: 48em) 100vw, 768px" srcset="https://ralfw.de/media/posts/131/responsive/DraggedImage-8-1-xs.png 300w ,https://ralfw.de/media/posts/131/responsive/DraggedImage-8-1-sm.png 480w ,https://ralfw.de/media/posts/131/responsive/DraggedImage-8-1-md.png 768w ,https://ralfw.de/media/posts/131/responsive/DraggedImage-8-1-lg.png 1024w ,https://ralfw.de/media/posts/131/responsive/DraggedImage-8-1-xl.png 1360w ,https://ralfw.de/media/posts/131/responsive/DraggedImage-8-1-2xl.png 1600w"  alt="" width="618" height="390"></figure></figure>
</div>
<p><!-- /wp:image --></p>
<p><!-- wp:heading {"level":2} --></p>
<h2>Anatomy of a backend</h2>
<p><!-- /wp:heading --></p>
<p><!-- wp:paragraph --></p>
<p>To me the beauty of CQNS + EO is a very straightforward and generic basic software structure. And in that it’s easy to independently focus on (comparatively) small functional units.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:heading {"level":3} --></p>
<h3>Message-oriented requirements analysis</h3>
<p><!-- /wp:heading --></p>
<p><!-- wp:paragraph --></p>
<p>Designing software is helped by applying this pattern. But also analysis is helped because it’s guided by the message hierarchy:</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:list {"ordered":false} --></p>
<ul>
<li>Messages
<ul>
<li>Incoming/outgoing
<ul>
<li>Request (outgoing) -&gt; Response (incoming)
<ul>
<li>Command -&gt; Command Status</li>
<li>Query -&gt; Query Result</li>
</ul>
</li>
<li>Notification
<ul>
<li>Incoming: Notification -&gt; Commands</li>
<li>Outgoing</li>
</ul>
</li>
</ul>
</li>
<li>Event (internal)</li>
</ul>
</li>
</ul>
<p><!-- /wp:list --></p>
<p><!-- wp:paragraph --></p>
<p>My approach to software development is outside-in: I start at the surface of a software system and ask „How do users want to interact with the system?“ Requests with their responses are the primary answer to that.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Next I ask to what the software system should react in addition. Incoming notifications are the answer to that.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Then from command requests I derive the internal events to be stored in the event stream.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Next I try to balance the events found with what query requests might deem helpful to get from the event stream.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>(If you’re a fan of <a href="https://en.wikipedia.org/wiki/Event_storming" target="_blank" rel="noopener">Event Storming</a> you might prefer to start with events and work your way „up“ to incoming/outgoing messages. That’s fine for me, too. That’s serving the same goal. If you find it easier that way around, why not?)</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Finally I’m concerned with outgoing notifications generated by command request processing.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>What I’m not really interested in anymore, though, is „the one“ internal domain data structure. I’m not trying to figure out how the domain can be represented in a comprehensive data model.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>For a long, long that had been my primary concern. I was fixated on „the one“ domain data model. I wanted to represented „the world“ in software.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>But those days are gone now!</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:heading {"level":3} --></p>
<h3>Coloring the design blueprint mandala</h3>
<p><!-- /wp:heading --></p>
<p><!-- wp:paragraph --></p>
<p>Once I’ve gotten the messages down I can work on them one by one. It’s like eating a pizza slice by slice.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:image {"id":2646, "align": "center"} --></p>
<div class="wp-block-image">
<figure class="aligncenter"><figure class="wp-image-2646"><img loading="lazy"  src="https://ralfw.de/media/posts/131/DraggedImage-9-1.png" sizes="(max-width: 48em) 100vw, 768px" srcset="https://ralfw.de/media/posts/131/responsive/DraggedImage-9-1-xs.png 300w ,https://ralfw.de/media/posts/131/responsive/DraggedImage-9-1-sm.png 480w ,https://ralfw.de/media/posts/131/responsive/DraggedImage-9-1-md.png 768w ,https://ralfw.de/media/posts/131/responsive/DraggedImage-9-1-lg.png 1024w ,https://ralfw.de/media/posts/131/responsive/DraggedImage-9-1-xl.png 1360w ,https://ralfw.de/media/posts/131/responsive/DraggedImage-9-1-2xl.png 1600w"  alt="" width="577" height="414"></figure></figure>
</div>
<p><!-- /wp:image --></p>
<p><!-- wp:paragraph --></p>
<p>Each slice being a message handling pipeline. And the pizza crust being a tranceiver which receives incoming messages from the environment and sends/broadcasts outgoing messages to the environment.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>The structure of all the pipeline slices is the same; each consists of three segments (and is attached to the event store at the center):</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:image {"id":2654, "align": "center"} --></p>
<div class="wp-block-image">
<figure class="aligncenter"><figure class="wp-image-2654"><img loading="lazy"  src="https://ralfw.de/media/posts/131/DraggedImage-10-1.png" sizes="(max-width: 48em) 100vw, 768px" srcset="https://ralfw.de/media/posts/131/responsive/DraggedImage-10-1-xs.png 300w ,https://ralfw.de/media/posts/131/responsive/DraggedImage-10-1-sm.png 480w ,https://ralfw.de/media/posts/131/responsive/DraggedImage-10-1-md.png 768w ,https://ralfw.de/media/posts/131/responsive/DraggedImage-10-1-lg.png 1024w ,https://ralfw.de/media/posts/131/responsive/DraggedImage-10-1-xl.png 1360w ,https://ralfw.de/media/posts/131/responsive/DraggedImage-10-1-2xl.png 1600w"  alt="" width="477" height="292"></figure></figure>
</div>
<p><!-- /wp:image --></p>
<p><!-- wp:paragraph --></p>
<p>So for each message I can design the following step by step:</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:list {"ordered":true} --></p>
<ol>
<li>Define the message context, i.e. all the relevant events</li>
<li>Design the message context model</li>
<li>Design how the message context model should be loaded and queried before message processing</li>
<li>Design how the message should be processed in light of the message context model
<ul>
<li>Command
<ul>
<li>Design how to generate events from the message in light of the message context model</li>
<li>Design how to generate outgoing notifications from the message</li>
</ul>
</li>
<li>Query
<ul>
<li>Design how to generate the query result from the message context model in light of the message</li>
</ul>
</li>
<li>Notification
<ul>
<li>Design how to generate commands from the message in light of the message context model</li>
</ul>
</li>
</ul>
</li>
<li>Design how the message context model should be updated</li>
</ol>
<p><!-- /wp:list --></p>
<p><!-- wp:paragraph --></p>
<p>To me that feels very guided, almost like a meditative activity (if not a boring one). It’s like coloring a mandala area by area…</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:image {"id":2650, "align": "center"} --></p>
<div class="wp-block-image">
<figure class="aligncenter"><figure class="wp-image-2650"><img loading="lazy"  src="https://ralfw.de/media/posts/131/DraggedImage-11-1.png" sizes="(max-width: 48em) 100vw, 768px" srcset="https://ralfw.de/media/posts/131/responsive/DraggedImage-11-1-xs.png 300w ,https://ralfw.de/media/posts/131/responsive/DraggedImage-11-1-sm.png 480w ,https://ralfw.de/media/posts/131/responsive/DraggedImage-11-1-md.png 768w ,https://ralfw.de/media/posts/131/responsive/DraggedImage-11-1-lg.png 1024w ,https://ralfw.de/media/posts/131/responsive/DraggedImage-11-1-xl.png 1360w ,https://ralfw.de/media/posts/131/responsive/DraggedImage-11-1-2xl.png 1600w"  alt="" width="545" height="768"></figure></figure>
</div>
<p><!-- /wp:image --></p>
<p><!-- wp:heading {"level":2} --></p>
<h2>Summary</h2>
<p><!-- /wp:heading --></p>
<p><!-- wp:paragraph --></p>
<p>Refining the CQS to CQNS and being grounded in Event-Orientation really helps me progressing through software development in a very straightforward manner.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>Sure, there are still challenges to master. Sure, especially processing messages still can be tough.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>With CQNS + EO, however, I’m relieved of a lot of confusing stuff around that. I find it much, much easier to focus on the important things.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:list {"ordered":false} --></p>
<ul>
<li>I’m not wasting energy on asking myself „How to start development?“</li>
<li>I’m not wasting energy on „getting the one model right“.</li>
<li>I’m not wasting energy on designing structures which should not differ from software to software anyway.</li>
</ul>
<p><!-- /wp:list --></p>
<p><!-- wp:paragraph --></p>
<p>Yes, I believe there is a basic anatomy to all software. Like there is a basic anatomy to all animals. And that basic anatomy is more fine grained than the usual architectural pattern suggest. And it still leaves room and freedom for all the incredibly complicated stuff you have to implement, don’t worry.</p>
<p><!-- /wp:paragraph --></p>
<p><!-- wp:paragraph --></p>
<p>I’d even say: By giving software a basic anatomy we’re set free to focus on the really important things much more. CQNS and EO, to me, are part of that anatomical blueprint.</p>
<p><!-- /wp:paragraph --></p>
            ]]>
        </content>
    </entry>
</feed>
