Jekyll2023-03-27T12:22:02+02:00https://bernhardwenzel.com/feed.xmlBernhard Wenzel - Technical Decision MakingThis site explores the intersections of three subjects: decision making, learning and creation of value. Bernhard WenzelThinking In Lists2023-03-03T12:35:00+01:002023-03-03T12:35:00+01:00https://bernhardwenzel.com/2023/thinking-in-lists<p><img src="https://bernhardwenzel.com/images/posts/2023/list-making.jpg" alt="" /></p>
<p>Have you ever tried playing chess against yourself? Unless you are a chess purist or have a split personality, it is not much fun.</p>
<p>The pleasure of engaging in a game like chess comes from challenging another mind (human or otherwise). From not knowing what the other is planning and the uncertainty that comes with it. When two opponents share the same brain, there are no secrets or surprises.</p>
<p>Another player makes the game “real.” When you have found a weakness in the opposing position and hatch a plan to exploit it, your opponent will prove your plot right or wrong. The stronger the rival, the harder your ideas will be tested. Left alone, that “clash with reality” can’t occur. You can try hard to emulate both separate sides, but as the two are coming from the same mind, all you do is evaluate yourself, which has limited value.</p>
<p>We are in a similar predicament every time we are trying to understand something or come up with an explanation. Because we are the creator of our thoughts as well as their recipient, we are <strong>biting our own tails</strong> whenever we try to figure out if what we think is correct or not.</p>
<p>To overcome the lack of outside perspective, we intend to look at a problem from all angles. The trouble is that not only is seeing the forest from the trees difficult, but that <strong>thinking itself is flawed</strong>. The mind’s default operational mode is not rationality, and it has no incentive to spot inconsistencies. Instead, it happily paints over blind spots, leaving us unaware of our imperfections.</p>
<p>Why is this so? Wouldn’t it be beneficial to our species to ensure that our thinking is consistent and flawless? The short answer is no. <strong>The mind is not designed to think.</strong> <sup id="fnref:notdesigned" role="doc-noteref"><a href="#fn:notdesigned" class="footnote">1</a></sup> From an evolutionary point of view, it is more beneficial for our survival to automate thinking as much as possible. Active, hard pondering of problems consumes valuable energy that would be better spent on spotting danger or other life-preserving activities.</p>
<p>The brain is arguably the most wonderful thing in the universe (as far as we know, that is). It can do marvelous things like seeing, hearing, memorizing, control bodily functions, all at the same time and while giving birth to consciousness. But when it comes to learning and rational reasoning, the organ inside our skull is a broken tool, like a water bucket with holes.</p>
<p>Without a clear picture of what we actually think (rather than what we believe to think), efficient learning is difficult. It is essential to shine a bright light on the gaps in our reasoning and bring them out into the open. Learning is as much about gaining new insights as it is about getting rid of false beliefs.</p>
<p>What can we do?</p>
<p>Ideally, you’d have a few like-minded people at your disposal interested in your stuff who could challenge and inspire you (could this be an AI in the future? That would be tremendous).</p>
<p>Lacking such a sophisticated support group, the next best thing to do is to <strong>break the mind’s self-evaluation-loop</strong> by putting distance between the moment we generate an idea and the time we evaluate it.</p>
<p>Humanity has invented a tool for exactly that problem - pen and paper. Writing helps us capture our fuzzy thoughts and make them explicit and observable. The problem is, it can be a laborious word-wrangling exercise to express ourselves. Luckily, for our purposes we can skip most of the arduous parts of translating our intentions into sentences and simply transpose our raw thoughts onto paper. This can be done much easier and faster by <strong>making a list</strong>.</p>
<p>The difference between a list and “normal” writing is the intended audience. Usually, we write for others, which makes it so hard because the reader does not know anything about us. We need to give as much context and be exact as possible to avoid ambiguity. The list, on the other hand, is only meant to be read by the author. No need to explain where we are coming from, we can be as esoteric in our descriptions as we like.</p>
<p>There is one non-negotiable requirement, though: <strong>Everything on the list has to be written using our very own words.</strong> This is crucial to make the list fulfill its purpose.</p>
<p>Looking up answers and copying-pasting them into our list does not help at all - rather the opposite, it only strengthens the gaps in our understanding because it creates the illusion of knowledge. We may write down correct facts, but they are not coming from us.</p>
<p>This is one reason why highlighting passages in a book does very little to increase comprehension of a text. It looks like learning because the passages are important, but they are not our words, they are expressions of someone else’s thinking (underlining text passages can still be a useful activity, but the highlights are merely bookmarks, helping navigate a large amount of information).</p>
<p>Definitions, buzzwords, or concepts we don’t fully grasp don’t belong on the list. Unless we write down precisely this - that we don’t understand those terms (e.g., “Technology X is a distributed-self-contained management system - what the heck does that mean?”)</p>
<p>We list what we know (or believe to know) and what we don’t know or understand. This is a fast and fluent exercise. It does not require much thinking. Then, very soon, we will have exhausted what’s on our mind.</p>
<p><strong>I love making lists</strong>. Whenever I am stuck, I start listing my thoughts. This post here started as a list (as all others have) that I then successively transformed into full sentences. The moment I got stuck, I switched back into list mode, and so forth. I’m always shifting modes. From slow and exact writing, building up a single line of argument, to the immediate and quick jotting down of multiple strands of thoughts (there are other modes, but that’s a subject for another post).</p>
<p>When I begin a new task, I start with a list. To clarify my intentions and beliefs and to prepare myself for the work ahead by bringing into focus the things I’m sure about and those I’m not. This way, I prime my mind to find answers for the gaps I have and to look for confirmation of what I assume to be true.</p>
<p>Lists are helpful for any kind of mental task. They expand our short-term memory. They force us to think sequentially and turn vagueness into explicitness. And list-making is a fun activity, even relaxing, similar to meditation and its benefits, where we step back from being mindlessly captured by thoughts and instead gain control through observing our mental states.</p>
<div class="footnotes" role="doc-endnotes">
<ol>
<li id="fn:notdesigned" role="doc-endnote">
<p><a href="Daniel T. Willingham - Why Don't Students Like School?: Chapter 1 - The Mind is not designed for thinking">http://www.danielwillingham.com/books.html</a> <a href="#fnref:notdesigned" class="reversefootnote" role="doc-backlink">↩</a></p>
</li>
</ol>
</div>Bernhard WenzelVideo-Learn confidently with mental models2022-10-25T10:49:00+02:002022-10-25T10:49:00+02:00https://bernhardwenzel.com/2022/video-learn-confidently-with-mental-models<div class="embed-video-container"><iframe allowfullscreen="" allow="autoplay; encrypted-media" width="640" height="360" src="https://www.youtube.com/embed/Vx-6-3HRazI?color=white&theme=light"></iframe></div>BernhardKnowledge as design - does knowledge have a purpose?2022-09-08T11:58:00+02:002022-09-08T11:58:00+02:00https://bernhardwenzel.com/2022/knowledge-as-design-or-does-knowledge-have-a-purpose<p><img src="https://bernhardwenzel.com/images/posts/2022/knowledge-as-design.JPG" alt="" /></p>
<p>What do we value most in life? Health is an obvious choice, next to love and meaningful friendships. Money is certainly on the list too, but controversial, at least when pursued narrowly at the cost of everything else (though few would dispute that a good life depends on owning a sufficient amount of it).</p>
<p>Uncontroversial is the value of another item: knowledge. Our post-industrial society increasingly depends on the creation and transfer of know-how and technical expertise. We usually consider knowledgeable people as intelligent, which often correlates with higher social status and financial reward.</p>
<p>But what is knowledge? It is surprisingly hard to define. Does memorization of a lot of facts (e.g historical dates) count as knowledge? Then your internet-connected computer would be the most knowledgeable entity ever created. Facts are data points. Taken by themselves, they have limited value if we can’t explain their existence and are unable to predict future facts. In other words, we lack understanding.</p>
<p>Furthermore, the value of knowledge depends on its usefulness to solve a problem. In particular, to solve <em>my</em> problem. Ask “How much do you know about X?” and I would reply “to accomplish what?” (which is nicer than an engineer’s favorite retort of “it depends…”). I know that a combustion engine needs oil and gas to function and have a dim idea about gears. Enough knowledge for me to drive a car, understand the meaning of warning lights and abstain from shifting into reverse while the car is moving forward. If you ask me, I know all there is about cars. However, if tomorrow I wanted to start a new career as an auto mechanic, I would immediately find out that I know very little.</p>
<p>Figuring out the <strong>purpose</strong> of knowledge affects how we think about it and fundamentally changes how we teach and learn. By asking about the reason for knowledge we move from passive consumption of facts to an active inquiry about the why, how, how well, and so on.</p>
<p>How purpose and knowledge relate to each is the subject of the fascinating book called <strong>“Knowledge as Design” by D.N. Perkins</strong>.</p>
<p>As the title suggests, the author considers knowledge not something that is out there, given to be consumed without critical analysis (he calls this “truth mongering”) but something that has a purpose, or, in a broader sense, a design.</p>
<p>The first thing to note is that the word design may be misleading. If you, like me, haven’t thought much about design before you may equate it with style (fashion, brands, websites) or a blueprint to build something (design of a house). The author takes a wider look and defines design more accurately:</p>
<blockquote>
<p><strong>Design is the human endeavor of shaping objects to purposes</strong></p>
</blockquote>
<p>Almost everything is a design. A knife is an object adapted to the purpose of cutting things. Academic knowledge is also designed - Newton’s laws are a mathematical tool to explain the motion of bodies. So are processes, claims, and even historic dates as a part of a larger story (for example, the year 1492 marks a milestone in western civilization). There are only a few things that are not designs (like natural phenomena).</p>
<p>So how does thinking about design help us with acquiring knowledge? Knowing the purpose of a design is crucial, but purpose alone only explains the reason a design exists, it does not say anything about how it solves a problem.</p>
<h2 id="the-four-design-questions">The four design questions</h2>
<p>The author gives us a tool to examine designs by formulating <strong>four design questions</strong> that make up the heart of the book.</p>
<p>The questions to ask about a design are the following:</p>
<ol>
<li>What is its purpose?</li>
<li>What is its structure?</li>
<li>What are the model cases of it?</li>
<li>What are the arguments for and against its usefulness?</li>
</ol>
<p>“Purpose” we have already discussed. The <strong>structure</strong> of a design deals with the parts, components, materials, relations, and so forth of the object in question. A knife has a cutting edge attached to a handle.</p>
<p><strong>Model cases</strong> are examples of the object or knowledge (imagine photos of different types of knives). Model cases are in some sense mental models, but in a much narrower way (I come back to this later).</p>
<p><strong>Arguments</strong>, the last of the four questions, evaluate a design. How well does it do its job? Given the purpose, is the design well-thought-out or could it be better? While the former three questions could be answered without much context, here we depend on our subjective understanding of the object at hand. I can’t say anything about the effectiveness of a design if I don’t understand what it does or how it differs from other solutions.</p>
<p>The book discusses at length how the four questions can be applied to practically everything. It turns out that looking at the world through design glasses is tremendously useful. Be it how to write an essay, how to come up with new insights, or how to improve learning and teaching in general.</p>
<p>Since knowledge plays such an important role in our life, it is worth looking at how this new way of thinking about knowledge (as design) compares to our default way (as information).</p>
<table>
<thead>
<tr>
<th style="text-align: left">Knowledge as information</th>
<th style="text-align: left">Knowledge as design</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align: left">passive</td>
<td style="text-align: left">active</td>
</tr>
<tr>
<td style="text-align: left">something to store and retrieve</td>
<td style="text-align: left">something to apply</td>
</tr>
<tr>
<td style="text-align: left">out there to memorize</td>
<td style="text-align: left">result of human inquiry</td>
</tr>
<tr>
<td style="text-align: left">no purpose</td>
<td style="text-align: left">born out of purpose</td>
</tr>
<tr>
<td style="text-align: left">impersonal</td>
<td style="text-align: left">personal</td>
</tr>
</tbody>
</table>
<p>We shift from the left to the right, from the passive to the active, by connecting what we learn to each of the four design questions.</p>
<p>So how does all this help us with our mental models? Is one better than the other?</p>
<h2 id="how-do-software-mental-models-smm-compare-with-the-four-design-questions-4dq">How do software mental models (SMM) compare with the four design questions (4DQ)?</h2>
<p>The short answer is that 4DQs are a tool to evaluate the subject at hand that leads to a conclusion, while SMMs are a process that keeps evolving. There is overlap between the two but also significant differences. Let’s have a look at each of the four questions.</p>
<h3 id="model-cases">Model cases</h3>
<p>We start with likely the most confusing part. Aren’t mental models the same as model cases? Not really. Mental models, at least the way I use them, are internal representations of reality, that can differ significantly from the actual object. Model cases are examples (of object types, procedures, formulas, etc), whereas mental models are simplifications that are (hopefully) so useful that they can explain complex processes with a few elegant analogies. Coming back to the simple example of a knife, model cases would present all the different types of knives (we could, for example, present their evolution from the stone age until today), whereas the mental model of a knife depends on what goal I have. In my case, I mostly think about knives in the context of a kitchen, so I have mental models about how the sharp side of a blade works and what knife to use for certain materials (e.g. bread versus meat). A chef has vastly more complex internal representations of knives. She might think about angles, handles, all kinds of materials, cutting techniques, and so on.</p>
<h3 id="structure">Structure</h3>
<p>The structure of a design describes the elements and parts of the object or knowledge. Mental models include structure, too, but only those parts that are useful for achieving the goal. When learning something new, the structure of a model will be similar to a structure of a design. The more advanced the models get, the more abstract they become until they may have nothing in common anymore with the actual object.</p>
<h3 id="purpose">Purpose</h3>
<p>The purpose of a design is similar to what I consider the goal of a mental model. However, in the case of SMMs, the goal is deeply personal, whereas the purpose of a design is meant to be independent of the learner.</p>
<p>The goal of a mental model gives clarity about what is important and what I can leave out. The goal evolves. In a design, the purpose is fixed - the reason the design exist stems from the purpose.</p>
<p>In reality, the purpose of a design is still to some degree subjective, because it depends on the knowledge of the learner. A physics beginner in school will come up with a different, simpler purpose for Newton’s laws than a university graduate.</p>
<h3 id="arguments">Arguments</h3>
<p>Arguably, arguments are the most important of the four questions because they require the learner to conclude based entirely on their understanding and experience. Purpose, structure, and model cases lay the foundation that arguments are built upon.</p>
<p>SMMs don’t have arguments at all. If they are so important, how can this be?</p>
<p>The reason can be found in the fact that SMMs are a process. Arguments and purpose are two sides of a coin. The argument describes how well a design accomplishes its purpose with the outcome of an evaluation. SMMs don’t have a final step. Instead, we evaluate models during the test phase, where we figure out where the models are inaccurate. Instead of giving a judgment, we correct the model and make it better during the refinement phase (or replace it with a better model if necessary). The argument is ingrained in the process.</p>
<p>In summary, we could say that <strong>SMMs are the agile version of 4DQ</strong>.</p>
<table>
<thead>
<tr>
<th style="text-align: left">Knowledge as design</th>
<th style="text-align: left">Software Mental Models</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align: left">Purpose</td>
<td style="text-align: left">Goal of the mental model is personal and depends on the learner’s experience and aim.</td>
</tr>
<tr>
<td style="text-align: left">Structure</td>
<td style="text-align: left">The structure of SMMs may be similar to the real object but advanced models may not reflect reality at all.</td>
</tr>
<tr>
<td style="text-align: left">Model cases</td>
<td style="text-align: left">SMMs go beyond mere examples of designs. They can include model cases but don’t need to.</td>
</tr>
<tr>
<td style="text-align: left">Arguments</td>
<td style="text-align: left">The evaluation of a mental model happens during the test & refinement phase, always adapted to the goal of the learner.</td>
</tr>
</tbody>
</table>
<p><em>The 4DQs are a very useful tool to structure thinking, learning, and writing. The book can be repetitive at times as it goes through the many possible applications of the theory, but once the main ideas are understood it is easy to skip content and focus on the parts that interest you. They are certainly useful for developing SMMs.</em></p>
<h2 id="can-you-spot-the-4dq-in-this-post">Can you spot the 4DQ in this post?</h2>
<p>Writing an essay is among the use cases of the theory. Can you spot where in this post I have used the four questions?</p>
<p>Answer:</p>
<ul>
<li>The first half of this post explains the purpose and structure of the 4DQs. First I made claims about the importance of knowledge, and in particular, the value of looking at the purpose of knowledge</li>
<li>Then I described the structure of the 4DQs, describing each question.</li>
<li>I finished the first half by completing my description of the purpose of the 4DQ by demonstrating the value of moving from seeing knowledge as information to considering knowledge as design.</li>
<li>I use model cases of 4DQs throughout the post, most of the time using the example of a knife. And, to go fully recursive, this answer is another model case of the 4DQs.</li>
<li>In the second half I give arguments by comparing in detail the 4DQs with SMMs, with the conclusion that while there’s overlap between the two ideas, SMMs fundamentally differ from 4DQs by being an ongoing process instead of a final evaluation of an object or piece of knowledge.</li>
</ul>Bernhard WenzelThe Mental Model Of Docker Container Shipping2022-05-19T08:00:00+02:002022-05-19T08:00:00+02:00https://bernhardwenzel.com/2022/the-mental-model-of-docker-container-shipping<p><img src="https://bernhardwenzel.com/images/posts/2022/container-shipping-title.jpg" alt="" /></p>
<p>Programming is a marvellous activity. By typing on a keyboard and feeding code to a computer, a programmer can create entirely new (virtual) worlds out of nothing. There are few constraints on what a program could be - the only limitations are memory and a CPU’s processing power. Whatever you can think of, you could, in theory, bring into existence on a computer.</p>
<p>But since virtual worlds are created in the mind of a developer and not based on physical reality, it can be difficult to talk about what they are or how they work. There is no immediate language to refer to. To overcome this lack of terminology, engineers often use analogies from the real world to describe what software does.</p>
<p>Docker is no exception. At its centre stands the “container”, the main building block of what Docker calls a “standard of shipping software”. One can’t help but see container ships towing heavy loads over oceans. Even the logo depicts the main idea:</p>
<p><img src="https://bernhardwenzel.com/images/posts/2022/docker-logo.png" alt="" />
<em>Containers and shipping software</em></p>
<p>When we learn about new technology with strong ties to another technology, we immediately apply our existing knowledge of the substitute technology to fill gaps in our understanding. This “replacement reasoning” can be helpful or misleading, depending on how accurate the analogy turns out to be. Therefore, to avoid misconceptions, it is beneficial to evaluate existing mental models first, as they are the ground on which we build our individual models.</p>
<p>In the case of Docker, we want to know how helpful the idea of “container shipping” is and how far we can take the analogy.</p>
<p>It turns out that there are many parallels between real and virtual containers and that the properties of container shipping cover quite a lot of concepts of Docker.</p>
<h2 id="containers-those-made-from-steel">Containers (those made from steel)</h2>
<p><img src="https://bernhardwenzel.com/images/posts/2022/Container_01_KMJ.jpg" alt="" /></p>
<p>Shipping containers revolutionized international trade by making it possible to move freight between different modes of transport without the need to re-package goods. Due to standardization and a complex system of docking ports, the cost and time it takes to ship goods worldwide have been significantly reduced.</p>
<p>What makes containers so valuable is that they can be stacked neatly on top of each other, thanks to their standardized dimensions. They can also carry nearly any kind of goods and can be used interchangeably.</p>
<h2 id="docker-containers">Docker Containers</h2>
<p>Like shipping containers, Docker containers also increased efficiency. Most applications run on Webservers. In the past, it was not possible to execute more than one application per server. Not only was managing a fleet of invidual servers difficult, it also lead to a waste of resources, as applications can vary significantly in their requirements that change over time (servers needed to keep a capacity reserve).</p>
<p>Then a company called VMWare came along and invented the virtual machine. I mentioned in the intro that computers create virtual worlds. They can also create <em>worlds inside worlds</em>. A virtual machine is an emulation of hardware. Each emulated hardware is a new virtual computer (creating computers inside a computer), making it possible to run multiple applications side by side on the same server.</p>
<p><img src="https://bernhardwenzel.com/images/posts/2022/vms.jpg" alt="" /></p>
<p><em>One OS per VM (Source: “Docker Deep Dive” <sup id="fnref:ddd" role="doc-noteref"><a href="#fn:ddd" class="footnote">1</a></sup>)</em></p>
<p>This makes deploying applications much more efficient. Applications run inside their own virtual machine (VM), and hardware resources can be individually distributed to meet the requirements of each application.</p>
<p>But VMs are big. Virtualizing the hardware requires each virtual machine to include an entire operating system.</p>
<p>Docker takes a different approach. Instead of virtualizing the hardware, it aims higher and abstracts away the operating system. Docker containers share the same OS resources, making them more lightweight <sup id="fnref:sameos" role="doc-noteref"><a href="#fn:sameos" class="footnote">2</a></sup>.</p>
<p><img src="https://bernhardwenzel.com/images/posts/2022/docker-container.jpg" alt="" /></p>
<p><em>Docker containers are smaller (Source: Docker Deep Dive<sup id="fnref:ddd:1" role="doc-noteref"><a href="#fn:ddd" class="footnote">1</a></sup>)</em></p>
<p>We talked about why Docker exists, but we still haven’t said what a container actually is.</p>
<h2 id="how-do-docker-containers-compare-to-physical-containers">How do Docker containers compare to physical containers?</h2>
<p>The physical container is an enclosing made of steel that carries goods. Similarly, a Docker container provides applications with an isolated environment (the virtual equivalent of an enclosing).</p>
<p>Actual containers are filled with goods. A Docker container runs an application. To understand how the application ends up on a Docker container (and how that is done efficiently), we need to understand three basic concepts:</p>
<ul>
<li>Docker engine</li>
<li>Docker image</li>
<li>Containerizing an app</li>
</ul>
<h2 id="docker-engine">Docker Engine</h2>
<p>The word “Docker” can mean two things.</p>
<p>First, there is Docker, <em>the company</em>. They develop the tools and libraries required to run Docker and maintain the Docker hub, a central repository.</p>
<p>Then there is Docker, <em>the technology</em>. There are three main components<sup id="fnref:swarm" role="doc-noteref"><a href="#fn:swarm" class="footnote">3</a></sup>:</p>
<ul>
<li>The <em>runtime</em> provides low-level libraries and components to run containers.</li>
<li>The <em>engine (or Daemon)</em> provides higher-level functionality, most of all the interface for Docker commands.</li>
<li>A <em>Client</em> is an application that talks to the Docker Daemon (e.g. the <code class="language-plaintext highlighter-rouge">docker</code> or <code class="language-plaintext highlighter-rouge">docker-compose</code> commands)</li>
</ul>
<p>When someone learns Docker, they will spend most of their time understanding the interactions of a Docker client with the Docker daemon.</p>
<p>Actual containers are made out of steel. Similarly, the Docker engine + runtime are “the fabric of Docker containers”.</p>
<h2 id="docker-image">Docker image</h2>
<p>The Docker glossary describes containers as a “runtime instance of an image” <sup id="fnref:glossary" role="doc-noteref"><a href="#fn:glossary" class="footnote">4</a></sup>. An image is a collection of files that are executed when a container runs. They are, we could say, the “content” of a container - in other words, the application.</p>
<p>Images are constructed in layers, where each layer corresponds to a set of files of a container. More precisely, each layer is a set of file <em>changes</em>. When an image is built, layers are executed sequentially, possibly overriding files of a previous stage.</p>
<p><img src="https://bernhardwenzel.com/images/posts/2022/image-layers.jpg" alt="" /></p>
<p><em>Image layers, overriding changes (source: “Docker Deep Dive” <sup id="fnref:ddd:2" role="doc-noteref"><a href="#fn:ddd" class="footnote">1</a></sup>)</em></p>
<p>Layers can be cached. That makes building images efficient because every time an image changes, we only need to update those layers that have changed.</p>
<h2 id="containerizing-an-application">Containerizing an application</h2>
<p>The final piece of the Docker puzzle is the so-called process of “containerizing an application”. Or in other words, how do we turn an application into an image that we can then execute on a container?</p>
<p>This is done via a <em>Docker file</em>. In the container shipping model analogy, a Docker file is similar to a list of items that describe the content of a container. Except that it not only lists the files but also describes the order of their occurrence or modification.</p>
<h2 id="side-by-side-comparison-of-container-shipping-and-docker">Side-by-side comparison of container shipping and Docker</h2>
<p>Finally, we get to the fun part! How far can we take the analogy of container shipping to create a mental model of Docker?</p>
<p>Container shipping is straightforward to visualize - starting with containers loaded with goods to the cranes lifting them onto ships and so forth until they reach their destination. For every step in the journey of a container, we can find a similar action in the Docker world. Let’s compare them side-by-side.</p>
<table>
<thead>
<tr>
<th style="text-align: left">Concept</th>
<th style="text-align: left">Container Shipping</th>
<th style="text-align: left">Docker</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align: left">What is a container?</td>
<td style="text-align: left">Vessel for goods</td>
<td style="text-align: left">Vessel for applications</td>
</tr>
<tr>
<td style="text-align: left">What are containers made of?</td>
<td style="text-align: left">Out of steel that is strong enough to keep contents stable and safe but not so heavy that containers can’t be moved</td>
<td style="text-align: left">Docker containers are made possible through the Docker runtime and engine, which create isolated environments for applications that can run side-by-side on the same hardware.</td>
</tr>
<tr>
<td style="text-align: left">Why are containers interchangeable?</td>
<td style="text-align: left">They have the same size and material qualities</td>
<td style="text-align: left">Images always create the exact same application regardless of how often or when they are created, executed, stopped or removed</td>
</tr>
<tr>
<td style="text-align: left">What makes containers efficient?</td>
<td style="text-align: left">Containers can be neatly stacked on top of each other and moved quickly through standardized ports and between vehicles.</td>
<td style="text-align: left">Containers are more lightweight than VMs because they share the same OS resources. They allow running multiple apps on the same hardware, each container optimized to the application’s requirements.</td>
</tr>
<tr>
<td style="text-align: left">What are the items of a container?</td>
<td style="text-align: left">Arbitrary number of goods</td>
<td style="text-align: left">File system changes that make up the containerized application</td>
</tr>
<tr>
<td style="text-align: left">What is a single item?</td>
<td style="text-align: left">A single good</td>
<td style="text-align: left">A single file system change represented by an image layer</td>
</tr>
<tr>
<td style="text-align: left">What is the description of the container content?</td>
<td style="text-align: left">Container receipt</td>
<td style="text-align: left">Dockerfile</td>
</tr>
<tr>
<td style="text-align: left">What vehicles transport containers?</td>
<td style="text-align: left">Ship, train, truck</td>
<td style="text-align: left">Hardware + OS + Docker engine</td>
</tr>
<tr>
<td style="text-align: left">How are contents prepared?</td>
<td style="text-align: left">The container is filled with goods</td>
<td style="text-align: left">The image is built</td>
</tr>
<tr>
<td style="text-align: left">How can filling a container be optimized?</td>
<td style="text-align: left">Goods are produced near a port</td>
<td style="text-align: left">The image is uploaded to a repository</td>
</tr>
<tr>
<td style="text-align: left">How are containers prepared for shipping?</td>
<td style="text-align: left">A crane moves the container onto a ship/train/truck</td>
<td style="text-align: left">An image is downloaded, and the container is created</td>
</tr>
<tr>
<td style="text-align: left">How does the transport start?</td>
<td style="text-align: left">The ship/train/truck is started</td>
<td style="text-align: left">The container is started</td>
</tr>
<tr>
<td style="text-align: left">How is the actual shipping performed?</td>
<td style="text-align: left">The ship/train/truck carries the container</td>
<td style="text-align: left">The application runs in a container</td>
</tr>
<tr>
<td style="text-align: left">How are containers unloaded from transport?</td>
<td style="text-align: left">A crane is lifting the container from a ship/train/truck</td>
<td style="text-align: left">A container is stopped</td>
</tr>
<tr>
<td style="text-align: left">How are the items unloaded?</td>
<td style="text-align: left">Goods are moved out of a container</td>
<td style="text-align: left">The container is destroyed</td>
</tr>
<tr>
<td style="text-align: left">How are containers disposed of?</td>
<td style="text-align: left">A container is scrapped</td>
<td style="text-align: left">The image is removed</td>
</tr>
</tbody>
</table>
<p>We can even create a little diagram that compares both worlds:</p>
<p><img src="https://bernhardwenzel.com/images/posts/2022/container-shipping-docker.jpg" alt="" /></p>
<ul>
<li>Think of a Docker container as a vessel for applications.</li>
<li>The Docker engine (and runtime) provides the enclosing for goods, similar to steel used to fabricate a physical container.</li>
<li>The Dockerfile is like a description of the contents of a container.</li>
<li>The image provides the content of a container, each file (change) is like a single good.</li>
<li>Building and uploading an image prepares the content of a container.</li>
<li>Downloading an image and creating a container is like a crane lifting a container onto a ship.</li>
<li>Running the container can be compared to a ship transporting containers over the ocean.</li>
<li>Stopping a container, destroying it and deleting an image is similar to a crane lifting a container off a ship, taking out the goods and scraping the empty container.</li>
</ul>
<hr />
<div class="footnotes" role="doc-endnotes">
<ol>
<li id="fn:ddd" role="doc-endnote">
<p><a href="https://learning.oreilly.com/library/view/docker-deep-dive/9781800565135">Docker Deep Dive by Nigel Poulton - Safari Bookshelf</a> <a href="#fnref:ddd" class="reversefootnote" role="doc-backlink">↩</a> <a href="#fnref:ddd:1" class="reversefootnote" role="doc-backlink">↩<sup>2</sup></a> <a href="#fnref:ddd:2" class="reversefootnote" role="doc-backlink">↩<sup>3</sup></a></p>
</li>
<li id="fn:sameos" role="doc-endnote">
<p>The disadvantage of Docker is that all applications need to run on the same OS - but since Linux is the de-facto standard for most applications, this is usually not a problem. <a href="#fnref:sameos" class="reversefootnote" role="doc-backlink">↩</a></p>
</li>
<li id="fn:swarm" role="doc-endnote">
<p>A fourth component, <em>swarm</em>, is often mentioned as well, which coordinates multiple instances of containers. <a href="#fnref:swarm" class="reversefootnote" role="doc-backlink">↩</a></p>
</li>
<li id="fn:glossary" role="doc-endnote">
<p><a href="https://docs.docker.com/glossary/#container">Docker Glossary - a container “is a runtime instance of an image”</a> <a href="#fnref:glossary" class="reversefootnote" role="doc-backlink">↩</a></p>
</li>
</ol>
</div>Bernhard WenzelFirst Git Mental Model2021-11-07T11:00:00+01:002021-11-07T11:00:00+01:00https://bernhardwenzel.com/2021/first-git-mental-model<p><img src="https://bernhardwenzel.com/images/posts/2021/cutandpaste.png" alt="" /></p>
<p>We make sense of the world through models we create in our minds. How well we understand reality depends on the accuracy of those models. However, we are often not aware that our internal representation can be inaccurate or, worse, we may not even realise that we use mental models at all. By bringing our thought processes into the open, we can shed light on the gaps in our understanding and learn more efficiently.</p>
<p>I have written about the <a href="/2021/software-mental-models/">role of mental models in software engineering</a>. I recommend reading that first if you haven’t done so, as it explains the main idea. In this post (and more to follow), I take an existing tool, framework or subject and look at it through the lenses of mental models.</p>
<p>Today’s example is <strong>Git</strong>. It assumes little or no prior knowledge. If you are already well-versed in Git, I encourage you to keep reading nonetheless. The goal of this series is as much teaching a specific subject as it is about exploring how to construct good mental models in general. There is no shortcut to achieving accurate understanding. As good as an existing mental model may be, we still have to absorb and make it our own; we can’t just copy and paste it into our brains (unfortunately).</p>
<h2 id="what-is-git">What is Git?</h2>
<p>The official definition says this:</p>
<blockquote>
<p>Git is a distributed version control system.</p>
</blockquote>
<p>Does reading this sentence evoke any mental images for you? In my case, the word “distributed” brings to mind several computers running in distant locations. “Version control system” lets me see software that stores copies of documents in an orderly fashion.</p>
<p>This is rather vague. A better way to understand something is not to ask “what” it is, but “why” does it exist - what is its purpose?</p>
<h2 id="what-is-the-purpose-of-git">What is the purpose of Git?</h2>
<p>There are primarily two problems Git is trying to solve:</p>
<ol>
<li>How can multiple people work in parallel on the same documents without stepping on each other’s toes?</li>
<li>How can we provide a safe environment for making changes without worrying about losing previous work?</li>
</ol>
<p>2) is part of the solution for 1). However, it is also possible to only take advantage of 2) while ignoring 1) (if you use Git solely as a local version tracker, which is a legitimate use case).</p>
<h2 id="1---how-can-multiple-people-work-on-the-same-documents-at-the-same-time">1 - How can multiple people work on the same documents at the same time?</h2>
<p>Let’s think about 1) - there is a group of people who want to work on the same set of documents simultaneously. How can they do that? Pose that question to yourself, and your brain will immediately start generating possible answers.</p>
<p>Depending on how much experience you have with a given problem, the solution you come up with can be complex or straightforward. A natural way to find a solution to a problem is to search in our memory for a similar situation that we can apply to the new challenge. How do people typically collaborate?</p>
<p>I see an office where several people are sitting around a table, with paper documents spread out in front of them. They pass files around, discuss changes, use pencil and eraser (or scissors and tape) to make changes.</p>
<p>Something like this:</p>
<p><img src="https://bernhardwenzel.com/images/posts/2021/git-mm-table.png" alt="" /></p>
<p>Although this model describes collaboration, the participants can’t work in parallel, as they need to take turns to change a document. Let’s refine our model by having everyone work on copies instead of the original documents. To reflect that Git is a distributed system, we also let each worker have their own table.</p>
<p>Our new model looks like this:</p>
<p><img src="https://bernhardwenzel.com/images/posts/2021/git-mm-distributed-table.png" alt="" /></p>
<p>How would that work? The table in the middle (let’s call it the “origin” table) contains the original documents. If I want to work on them, I first make copies of the documents and then grab one of the tables and go about making changes as I please. Then comes the moment to update the originals. I go back to the origin table and replace the sources with my edited copies.</p>
<p>There’s just one problem: what if someone else has already changed the originals? If I swap the documents, their changes will get lost.</p>
<p>So instead of swapping out entire documents, I need to “merge” my changes with whatever is on the origin table. This works most of the time, except when my change and someone else’s change are in “conflict”. For example, in a design document, someone changed the color of a button from red to green, but I changed it from red to yellow. Who’s change should persist?</p>
<p>A conflict:</p>
<p><img src="https://bernhardwenzel.com/images/posts/2021/conflict.png" alt="" /></p>
<p>I want to keep my version, but what if I change my mind later (because it turns out my colleague was right)? That is the second problem Git solves: as long as we track changes and can revert back to a previous state, we are safe to make changes.</p>
<p>How does Git make that possible?</p>
<p>Assume I have no spontaneous idea. We are then at a typical state during the learning process. We have exhausted fleshing out our mental model (or don’t want to speculate anymore), and we encountered a few areas where we can’t satisfyingly figure out how things work in reality.</p>
<p>This is a good moment to do some research and consult a book or a manual.</p>
<h3 id="sidenote-why-start-with-the-mental-model">Sidenote: why start with the mental model?</h3>
<p>You may ask why we didn’t start reading the book before building our model. Aren’t we wasting our time trying to come up with an explanation of how things work without having done research first? I disagree. By having made our current knowledge visible, the subsequent research becomes more targeted. We can locate gaps more quickly, know what kind of information we need or don’t need, and have a map to place new information.</p>
<h2 id="2---keeping-a-log-of-changes">2 - Keeping a log of changes</h2>
<p>So how does Git keep a log of changes?</p>
<p>I use <a href="https://git-scm.com/book/en/v2">Pro Git</a> as reference documentation. A good chapter to start is <a href="https://git-scm.com/book/en/v2/Getting-Started-What-is-Git%3F">What is Git?</a>, you may want to read it now.</p>
<p>The main point from that chapter leads us to the answer to our question:</p>
<blockquote>
<p>Git maintains snapshots of changes, not diffs</p>
</blockquote>
<p>In other words, every change in Git is stored as a snapshot of all files. Note that the word “snapshot” is another mental construct. Like a camera that catches a scene at a specific moment, a snapshot in computing is a copy of an entire state of a system at a certain time. We can use that information to extend our mental model.</p>
<p>Besides working on our copies of the original documents,
we create additional copies of the copies and put them in boxes. Each box reflects a document change. To keep a log of changes, each box links to the previous box.</p>
<p>It looks like this:</p>
<p><img src="https://bernhardwenzel.com/images/posts/2021/git-mm-snapshots.png" alt="" /></p>
<p>Those boxes are uniquely labelled. As you may have read in the book, Git creates so-called hashes of documents (you’ll find hashes everywhere in Git). A hash is a string of symbols that is unique for any possible state of documents.</p>
<h3 id="sidenote-focus-on-information-to-fill-the-most-important-gaps-ignore-the-rest">Sidenote: focus on information to fill the most important gaps, ignore the rest</h3>
<p>You may want to dig deeper to understand how hashing works under the hood. Or not? That is another common stage of any learning process. The question is this: should I figure out the inner workings of hashes, or should I just accept that they work in some way and move on?</p>
<p>Your mental model can guide you here as well. At this point, knowing how hashes work won’t help you with your understanding of Git. It won’t increase the accuracy of your model at this stage (being a beginner). It is the wrong rabbit hole to go down. Instead, for the sake of simplicity, we accept this gap in our understanding.</p>
<p>Good mental models strive for simplicity by conveying just enough details that are required to reliably predict the behaviour of the thing you are investigating. Any additional information will slow down progress (more about this at the end).</p>
<h3 id="log-a-change---but-when">Log a change - but when?</h3>
<p>Back to Git. Another question remains: when do we take a snapshot? Could we store <em>every</em> change? That would create an insurmountable amount of data and not be feasible.</p>
<p>Instead, what seems practical is that the author decides when to store a snapshot. Only they know when changes have reached a meaningful state that should be preserved.</p>
<p>How does Git make that possible?</p>
<p>The <a href="https://git-scm.com/book/en/v2/Getting-Started-What-is-Git%3F">same Pro Git chapter mentioned above</a> answers that question. The relevant paragraph is called “the three states”.</p>
<h3 id="three-states">Three states</h3>
<p>A file in a Git repository can have three different states: it is either “untracked”, “staged”, or “committed”. Untracked files (or modifications) are not recorded yet. When files are “staged”, that’s the moment when we intend to take a snapshot (but we haven’t registered the change yet). Committing files is the final step of storing the snapshot.</p>
<p>The three states:</p>
<p><img src="https://bernhardwenzel.com/images/posts/2021/three-stages.png" alt="" /></p>
<p>Coming back to the question of when to take a snapshot, the answer is that it is up to the user to make that decision.</p>
<p>By the way, Git introduces three states, although two would have been sufficient (e.g. committed - or not committed). The intermediate staging step makes preparing a snapshot easier, as we can add or remove files and change our minds before creating the record.</p>
<h2 id="testing-our-model">Testing our model</h2>
<p>We have developed a set of mental models that cover the basics of Git. It is time to test the usefulness of those models by asking ourselves if they can sufficiently explain how things work for our purposes.</p>
<h3 id="branching">Branching</h3>
<p>What is a branch? The word is already evoking a mental model of a real tree, with its main trunk and branches diverging into new directions.</p>
<p>You can read in detail about Git branches <a href="https://git-scm.com/book/en/v2/Git-Branching-Branches-in-a-Nutshell">in Pro Git</a>, but we can already explain how branches work in principle. As discussed above, “how Git creates a log of changes”, a branch is nothing other than a series of snapshots that is different from the main development flow. Internally, Git uses pointers to make that work, but all we need to understand now is that changes are stored as snapshots and that each snapshot has a unique label (hash) attached to it. If you want to know if two branches are the same, all you have to do is compare the hashes.</p>
<h3 id="git-commands">Git commands</h3>
<p>We test our model by looking at basic Git commands that you will likely have encountered when you first learned about Git.</p>
<div class="language-plaintext highlighter-rouge"><div class="highlight"><pre class="highlight"><code>git clone
git add
git commit
git push
git pull
</code></pre></div></div>
<p>If you are new to Git, I recommend running <code class="language-plaintext highlighter-rouge">git COMMAND --help</code> and start reading through the first paragraphs to see if the explanation fits our mental models.</p>
<p><code class="language-plaintext highlighter-rouge">git clone --help</code> says</p>
<blockquote>
<p>Clones a repository into a newly-created directory, creates remote-tracking branches for each branch in the cloned repository (visible using git branch –remotes), and creates and checks out an initial branch that is forked from the cloned repository’s currently active branch.</p>
</blockquote>
<p>We may not fully understand every detail, but the overall idea fits our distributed tables model of making copies and branches.</p>
<p><code class="language-plaintext highlighter-rouge">git add --help</code></p>
<blockquote>
<p>This command updates the index using the current content found in the working tree, to prepare the content staged for the next commit.</p>
</blockquote>
<p>We don’t know yet what an index is but can explain most of what is said here with the three stages model. And we learn that <code class="language-plaintext highlighter-rouge">git add</code> moves changes from “untracked” to “staged”.</p>
<p><code class="language-plaintext highlighter-rouge">git commit --help</code></p>
<blockquote>
<p>Create a new commit containing the current contents of the index and the given log message describing the changes.</p>
</blockquote>
<p>Same here, and now we can conclude that the “index” tracks changes that have been “staged”.</p>
<p><code class="language-plaintext highlighter-rouge">git push --help</code></p>
<blockquote>
<p>Updates remote refs using local refs, while sending objects necessary to complete the given refs.</p>
</blockquote>
<p>We don’t know what a ref is but “sending objects” fits our model where we bring our documents to the “origin” table and merge our changes.</p>
<ul>
<li><code class="language-plaintext highlighter-rouge">git pull --help</code></li>
</ul>
<blockquote>
<p>Incorporates changes from a remote repository into the current branch. In its default mode, git pull is shorthand for Git fetch followed by Git merge FETCH_HEAD.</p>
</blockquote>
<p>This does not fit our mental model. So far, we said that when we are ready with our work, we bring our changes to the “origin” table. But in reality, we “pull” changes down to us. <em>We found a gap in our model</em>. Coming back to <a href="https://git-scm.com/book/en/v2/Getting-Started-What-is-Git%3F">Pro git - What is git?</a> we can now understand what is meant by <em>Nearly Every Operation Is Local</em>. If Git was new to you and you followed along with the steps of this article, I bet you have now a stronger understanding of what “everything is local” means compared to when you first time read about it.</p>
<h2 id="real-life-testing">“Real-life” testing</h2>
<p>The ultimate test occurs when we apply our knowledge to real-life situations. Whenever Git does not behave as expected, we find out where we need to improve the model.</p>
<h2 id="polish--refine">Polish & refine</h2>
<p>As mentioned in the <a href="/2021/software-mental-models/">introduction post</a>, building mental models is a four-step process:</p>
<ol>
<li><strong>Define</strong> your model. We all use some kind of model, whether we are aware of it or not.</li>
<li><strong>Test</strong> your model. Either by researching or in real-life situations.</li>
<li><strong>Improve</strong> your model. Take what you have learned in 2) and improve it. Then test again.</li>
<li><strong>Simplify or go deeper</strong>. There will come a moment when steps 2) and 3) won’t bring any further improvements or when the model does not go deep enough because you have advanced in your understanding and tackling bigger challenges. You may be at a point where you can significantly simplify the model or build a new one.</li>
</ol>
<p>We have not yet exhausted steps 2) and 3), but we can still simplify our model. The table metaphor has gaps and is not that useful (but it helped to develop the model of snapshots).</p>
<p>Instead, the model of snapshots and the three file states together seem to be a good first mental model of Git.</p>
<h3 id="the-final-git-mental-model">The final Git mental model</h3>
<p><em>Log of hashes & three states</em></p>
<p><img src="https://bernhardwenzel.com/images/posts/2021/git-final-models.png" alt="" /></p>
<ul>
<li><strong>Every committed change in Git is stored as a snapshot and referenced by a unique hash.</strong> A log of changes is represented by a log of hashes. To compare two branches, all we need to do is compare the hashes to know if they are the same or not.</li>
<li><strong>All files go through three possible states.</strong></li>
</ul>
<h2 id="summary">Summary</h2>
<p>While developing an understanding of how Git works, we have gone through the process of constructing mental models. The key takeaways are the following:</p>
<p><strong>Always build your mental model first</strong>. Before you start reading a book or tutorial, sit down and visualise how you believe that the thing you are interested in works. That will make your subsequent research a lot more efficient, as you have a base that guides your reading and a place where you can place new information and relate it to existing knowledge. Remember the last time you read a book without any preparation. You may have highlighted sentences and written some notes in the margins - but how much of that information could you actually remember?</p>
<p><strong>Test and refine your model</strong>. That step is easy to forget, especially when it comes to improving your mental model. When you hit a plateau in your learning effort, that is the moment where you need to go back to your model and work out where the gaps are.</p>
<p><strong>Just enough information</strong> Good mental models are simple, some even elegant, and they convey just enough information to be useful.</p>
<p><strong>The goal is not 100% correctness</strong>. A model is always an approximation and depends on your context and level of understanding. Don’t try to cram everything in it. Instead, figure out what are the most important facts of something. That exercise itself is very valuable to master a skill.</p>
<h2 id="next">Next</h2>
<p>With the model at hand, we can now go and apply it to our daily work.</p>
<p>A good idea might be to look at your <code class="language-plaintext highlighter-rouge">.git</code> folder and try to figure out what is going on there. That will give you a deeper understanding of the internals (the relevant chapter in Pro Git is <a href="https://git-scm.com/book/en/v2/Git-Internals-Plumbing-and-Porcelain">Git Internals Plumbing and Porcelain</a>).</p>
<p>Or even better, don’t do anything and just use Git and wait until you hit a bump. That is the beauty of learning with mental models. There is no fixed path that you have to follow - real-life situations will show you where you need to improve.</p>
<p>I will come back to Git in a follow-up post and apply the model to more advanced situations, showcasing examples of where our model is sufficient and where it is not.</p>Bernhard WenzelSoftware Mental Models2021-08-18T11:00:00+02:002021-08-18T11:00:00+02:00https://bernhardwenzel.com/2021/software-mental-models<p><img src="https://bernhardwenzel.com/images/posts/2021/model.jpg" alt="" /></p>
<p>Software engineering is a rapidly evolving industry, putting developers in a perpetual state of having to learn new things while doing their actual job. This is a daunting task, not only because a full-time job leaves little room for training and catching up on the latest changes in tech, but also for the reason that it is becoming increasingly more difficult to decide what and how to learn.</p>
<p>For example, when faced with an engineering problem, the following questions may pop up in a developer’s mind:</p>
<ul>
<li>Should I search the internet for a quick answer, hoping to find a copy-and-pasteable solution to my problem? This may or may not work. Often it leads to fruitless attempts and wasted hours.</li>
<li>Or should I better take out that textbook and try to understand the fundamental ideas? But books are long - where do I start? Maybe a shorter video is a better use of my time?</li>
<li>Or is it time to get more practical experience instead of indulging in theory and pick up a tutorial or work on a proof-of-concept?</li>
<li>Why do I seem to have hit a plateau of my understanding and what is required for me to move ahead?</li>
<li>Why do others appear to grasps things faster while I struggle to get my head around this problem?</li>
</ul>
<p>As we can all testify, the issue is not that there isn’t enough information to solve a problem. It is the opposite: how can I make sure I invest time in the right activity to learn as efficiently as possible?</p>
<p>I believe there is an answer to all those questions and that it is possible to be confident about what and how to learn. The answer can be found by paying close attention to how we learn.</p>
<p>What does it mean to understand something? Understanding is related to knowledge. The deeper my understanding goes, the more “complete” my knowledge. Gaps in knowledge, on the other hand, are causing a lack of understanding. So when is my understanding “complete”?</p>
<p>I offer the following definition:</p>
<blockquote>
<p><strong>My understanding is complete if my knowledge about something is sufficient enough so that I can reliably predict future behaviour</strong>.</p>
</blockquote>
<p>The ability to <em>reliably predict</em> the behaviour of the thing or process I’m interested in determines my level of understanding. The fewer surprises I encounter, the more I can explain behaviour, the deeper my understanding.</p>
<p>However, all this depends on the purpose of what I’m doing and how deep I need to look into something.</p>
<p>For example, I don’t need to understand how bits are moved on a chip to program a website that runs on a standard server. Knowing about hardware would not increase my ability to predict the behaviour of my code. However, move away from a traditional operating system to specialized hardware, and the situation changes. Now my knowledge is <em>not sufficient anymore</em> to reliably predict the result of my work.</p>
<p>If our goal is to continuously widen our understanding over time the accuracy of our prediction would look similar to the following graph:</p>
<p><img src="https://bernhardwenzel.com/images/posts/2021/prediction-time.png" alt="" /></p>
<p><em>Prediction accuracy over time</em>. Our understanding grows until we hit a plateau. To overcome this, we need to switch the context and go deeper into the subject. This might require extending our mental model or create a new one, which will, in the beginning, cause the accuracy of our predictions to decrease, but once the improved model gets more accurate our overall understanding is becoming wider.</p>
<p>To avoid any gaps, why don’t we learn everything there is about computers? Because we can’t. Grey matter memory is limited. We would never get past all there is to know about hardware before we could even start figuring out how to program something.</p>
<p>That is true for almost everything else. Reality is by far too complex for the human brain to absorb completely. Instead, the brain creates a <em>simplified inner model</em> of the outer world that we use to reason about reality. Models help us to reduce complexity so we can spend our “brain power” on other things. The more accurate our models are, the fewer unexpected events we encounter in our daily life.</p>
<p>Mental models can go far and explain complex processes. Take, for example, the model of “supply and demand” <sup id="fnref:supply" role="doc-noteref"><a href="#fn:supply" class="footnote">1</a></sup>, which in simple terms describes how the cost of goods changes over time. More demand with the same supply will increase the price; more supply with less or the same demand decreases the price. This mental model has become so natural to us that talking about it seems trivial, but if I wanted to describe the economics of, let’s say, hardware chips going from research to production to sales, I would need to dive into far more complex processes than mere supply and demand - yet the model is good enough to predict many use cases.</p>
<p>The first takeaway is the <strong>we use mental models for all of our thinking</strong>.</p>
<p>Unfortunately, models can be inaccurate or wrong. If we learn something new, our model is likely to be incorrect. That is fine as long as we continuously improve the model. The problem is that often we are not aware that we are using a model, even less so a wrong one. Having an inner image is so intrinsic that we don’t realize that this image exists and that it might be wrong.</p>
<p>The second takeaway is that <strong>often we are not aware that we use models at all, and worse, that we use wrong models</strong>.</p>
<h2 id="mental-models-are-a-power-tool-for-efficient-learning">Mental models are a “power” tool for efficient learning</h2>
<p>A mental model is a tool that enhances our ability to think. As a physical tool enhances the human body’s abilities (e.g. a bicycle amplifies the ability of my legs), mental tools extend brainpower.</p>
<p>What makes a good mental model? It is concise and ideally elegant so that it significantly simplifies the outer world without losing accuracy. The simpler the model, the easier it is for us to absorb it and make it our own.</p>
<p>The model enables us to make predictions. If I can simplify a model while the accuracy of my predictions stays the same, the simpler model is better.</p>
<p>But finding a good model is only the first step. When moving through the stages from beginner to expert, the changing purpose and context will make the best model inaccurate (“All models are wrong, but some are useful” <sup id="fnref:allmodels" role="doc-noteref"><a href="#fn:allmodels" class="footnote">2</a></sup>). What matters more than the model itself is the <em>ability to improve any model</em>.</p>
<p>Taking an existing good mental model alone won’t be sufficient. We can’t just “copy-and-paste” the image into our brain and hope to gain understanding immediately. We still have to find meaning and have to “make it our own” (what I mean by that exactly is subject to another post). I believe improving the model requires deliberate practice and that having an accurate model can make learning vastly more efficient.</p>
<p>How would such a “practice” look like? The steps are something like the following:</p>
<ol>
<li><strong>Define</strong>. Be aware that you are using a model and make it visible. That can happen through writing, drawing diagrams or teaching others. You have to express the model so you can actively measure and alter it.</li>
<li><strong>Test</strong>. Find out where your model is wrong or not detailed enough. Do you encounter behaviour that you can’t explain? Has something unexpected happened? Those are the places that need work.</li>
<li><strong>Improve</strong>. Increase the accuracy of the model. You have multiple options for doing that, depending on experience (are you a beginner or expert?), availability of resources, how good the model is - more about this below.</li>
<li><strong>Simplify or go deeper</strong>. Now that your model is primarily accurate, try to simplify it as much as possible. You can significantly increase leverage and deepen your understanding. Can you find a more elegant explanation? What parts of your model are essential, which are superfluous? If you have reached a point where you can’t make more gains, it is time to widen or go deeper. Switch the context.</li>
</ol>
<h2 id="how-to-learn-efficiently-and-with-confidence">How to learn efficiently and with confidence</h2>
<p>With this in mind, we can answer the questions from above and solve the dilemma of how to best make use of the little we have available for learning.</p>
<p>If your model is mostly off, copy-and-paste answers from the internet will do little to improve understanding and likely cause more problems along the way. Instead, it is time to sit down and do step 2) from above: express your model and make it visible. Then learn the fundamentals (grab a book, watch a video, do an online course) and improve your model until you get to a stage where you can broadly explain behaviour and make accurate predictions.</p>
<p>If you have done the above but still not advanced much in your understanding, the next step is to get practical experience. Most likely, you need both: theory and practice. During your phase of gathering theoretical knowledge, you build your model. During practice, you test it with real-life situations.</p>
<p>If your model seems about right but has minor gaps, then look for quick answers. You will have a map where you can place the answer and are able to tweak your model.</p>
<p>If you feel you have hit a plateau and don’t advance in your understanding, while others seem to have a deeper grasp of things, you need to change the context of your challenge and go deeper. You likely need to create a new, more sophisticated model or come up with several related ones. Think like a scientist. Observe reality, make assumptions (which means formulate a model) and then run experiments to prove or disprove your model. Rinse and repeat.</p>
<p>If your model seems accurate, but feel that you are generally slow and need to look up things often, then, and only then, is it time to memorize knowledge. This is the right time to, for example, learn the details of your Git CLI. Those commands that you keep forgetting. This requires practice. You may even use techniques like <a href="https://en.wikipedia.org/wiki/Spaced_repetition">spaced repition</a> with flash-cards (which can be helpful in any stage to deepen your internal models).</p>
<h2 id="mental-models-are-overlooked-in-software-engineering">Mental models are overlooked in software engineering</h2>
<p>In software engineering, we lack good mental models. I see the reason for that in the fact that programming is an inherently practical exercise. Feedback loops are usually short - this is what makes programming such a satisfying experience. However, it can lead to a “just try things out until it works”-mentality without having gained a deeper understanding of how things work under the hood.</p>
<p>Also, as mentioned before, there is so much to learn that we simply don’t have the time to look deeper. So we skip on understanding the fundamentals. But this behaviour is short-sighted because, in the long-term, we become much faster and productive once we have built a solid foundation of our knowledge.</p>
<p>The final takeaway is I’m convinced that <strong>having crisp mental models is by far the most significant leverage for becoming an efficient learner (and knowledge worker/software engineer)</strong>. It lets you know where the gaps in your understanding are and what you need to do next. You can see what is essential and what is not. You can look beyond details and see the big picture, relieving you from the need to “cram” knowledge and rely on short-term memory.</p>
<p>For this reason, I created <a href="https://engineeringknowledge.blog/">engineeringknowledge.blog</a> with the following two goals in mind:</p>
<ul>
<li>describe mental models about selected subjects in software engineering (and other relevant areas)</li>
<li>and, more importantly, explore and investigate how to develop and improve mental models in general</li>
</ul>
<p>I consider the second goal more valuable than the first (because knowing the model alone won’t get you far, but if you can develop and improve your own models, you don’t necessarily need an external model - though a good starting point can undoubtedly accelerate learning). Because of that, even though I mostly talk about mental models that occur in software engineering (because that is my day job), I do hope that anyone will benefit from this series.</p>
<p>Please subscribe if you want to keep up-to-date - or reach out if you’d like to share your thoughts.</p>
<hr />
<p><em>Photo by <a href="https://unsplash.com/@d_mccullough?utm_source=unsplash&utm_medium=referral&utm_content=creditCopyText">Daniel McCullough</a></em></p>
<div class="footnotes" role="doc-endnotes">
<ol>
<li id="fn:supply" role="doc-endnote">
<p><a href="https://fs.blog/2009/07/mental-model-supply-and-demand/">Mental model of Supply and Demand</a> <a href="#fnref:supply" class="reversefootnote" role="doc-backlink">↩</a></p>
</li>
<li id="fn:allmodels" role="doc-endnote">
<p><a href="https://en.wikipedia.org/wiki/All_models_are_wrong">All models are wrong</a> <a href="#fnref:allmodels" class="reversefootnote" role="doc-backlink">↩</a></p>
</li>
</ol>
</div>Bernhard WenzelBetting as Evidence Amplifier2020-10-14T07:05:00+02:002020-10-14T07:05:00+02:00https://bernhardwenzel.com/2020/betting-as-evidence-amplifier<p>In her book “The biggest bluff” the author Maria Konnikova describes betting as a <em>“corrective for many of the follies of human reason”</em>. This seems contradictory at first as betting is rarely considered a prudent activity. It is, however, important to distinguish betting (in poker) from gambling. A game like roulette, for example, is based purely on luck. Poker, on the other hand, is a complex game that requires a mix of skills to be successful. Luck plays a role here as well, but as every amateur player who participates in a tournament can confirm, in the long run, the most experienced and skilled players win.</p>
<p>Leaving aside the question of whether betting is a “virtuous” endeavour or not, the point is that introducing a direct cost into our decision making changes how we evaluate a situation. When we make a decision, we <a href="https://bernhardwenzel.com/2020/Search-Inference-Framework/">are searching for possibilities and evidence</a>. Are the things we believe actually true? The lower the stakes, the less we are inclined to make an effort to question our beliefs. If the costs are high, and in the case of betting in poker, if being wrong leads to an immediate loss, we are much more motivated to scrutinise our assumptions. “Would you bet your house on it?” changes what we claim to be true.</p>
<p>In other words: <strong>betting is an evidence amplifier</strong>.</p>
<p>We encounter a similar situation in software engineering. The cost of failure determines the stakes of developing software. Do we build a system for the space shuttle or an image sharing app? Will an error cost lives or cause a minor disturbance of a (freemium) user?</p>
<p>Shipping software into production is a bet. Knowing the stakes is a crucial ingredient when determining how much research, testing and rigour we want to invest. In other words, how much evidence we need to seek out before releasing software to the world. When we overestimate the stakes, we may unnecessarily hinder our velocity by over-thinking or over-engineering our solution instead of relying on a shorter release cycle that will lead to actual evidence that the feature works in production. The opposite, however, can be worse. Miscalculating the stakes can lead to underestimating the risk of how much damage shipping a faulty component can cause.</p>Bernhard WenzelIn her book “The biggest bluff” the author Maria Konnikova describes betting as a “corrective for many of the follies of human reason”. This seems contradictory at first as betting is rarely considered a prudent activity. It is, however, important to distinguish betting (in poker) from gambling. A game like roulette, for example, is based purely on luck. Poker, on the other hand, is a complex game that requires a mix of skills to be successful. Luck plays a role here as well, but as every amateur player who participates in a tournament can confirm, in the long run, the most experienced and skilled players win.The search-inference framework of thinking2020-09-19T16:00:00+02:002020-09-19T16:00:00+02:00https://bernhardwenzel.com/2020/Search-Inference-Framework<h4 id="the-half-life-of-a-tech-stack">The half-life of a tech-stack</h4>
<p>The skills of a software engineer can be split into two groups: those that belong to a tech-stack (A) and those that don’t (B).</p>
<p>Skills in group (A) are directly associated with the ability to use a certain tool, platform or programming language. Skills in group (B), on the other hand, are fuzzy and can’t be defined easily. They are often called soft- or meta-skills.</p>
<p>As a general career strategy, I believe that time invested in honing the skills of group (B) yields a higher return. An engineer needs to have sufficient knowledge of (A) to be useful, but as technology is perpetually changing at an increasing rate, knowledge in that group has a short half-life. In contrast, skills acquired in (B) tend to stay relevant and to grow in value over time. Once you master to communicate well, that skill remains relevant regardless of how the working environment changes.</p>
<p>The most fundamental of all meta-skills is the ability to think (well). As engineers and knowledge workers spend most of their time thinking, doing that as efficient as possible is undoubtedly beneficial. It is a skill that is highly transferable and maximizing it will make everything else better.</p>
<h4 id="thinking-is-search-and-inference">Thinking is search and inference</h4>
<p>But what does it mean to think well?</p>
<p>In his book “Thinking and Deciding”<sup id="fnref:tnd" role="doc-noteref"><a href="#fn:tnd" class="footnote">1</a></sup> the author Jonathan Baron answers that question by defining a framework that is very much in the wheelhouse of any developer. It is called the <strong>search-inference-framework</strong>.</p>
<p>We can summarize the framework in the following diagram:</p>
<p><img src="https://bernhardwenzel.com/images/posts/2019/searchframework.jpg" alt="Search-inference framework" /></p>
<p>We think when we need to resolve doubts or make a decision about what to do or not to do. We base our decisions on what we believe and what goals we have. To form a belief or build an opinion, we think about possibilities and try to find evidence to support our judgement. We <strong>search</strong> for answers. This search happens within ourselves (our memories or ideas) or outside (other people, books and so on).</p>
<p>Then, to make a decision or come to a conclusion we <strong>infer</strong> from our findings. We do so by considering our goals and weighing the options we have available.</p>
<p>The objects of thinking are:</p>
<ul>
<li><em>Possibilities</em> are potential answers to our question that started the search.</li>
<li><em>Goals</em> are criteria by which we evaluate possibilities. The word can be misleading. Usually, a goal is something that is either reached or not. Here, more often, a goal is something that can be gradually achieved on a scale.</li>
<li><em>Evidence</em> is any form of belief that helps determine if a possibility achieves a goal or not.</li>
</ul>
<p>Goals are not fixed and can change with new possibilities or evidence.</p>
<p>Good thinking is often synonymous with <em>rational thinking</em>. Baron defines it the following way:</p>
<blockquote>
<p>Rational thinking is thinking that is in our best interest. To think rationally means to think in ways that help us best to achieve our goals.</p>
</blockquote>
<p>What is counter-intuitive of this definition is that it does not dictate in any way how to think. When we imagine a rational thinker, we often mean someone who thinks logically and without emotions. This is not necessarily rational. If being emotional or illogical brings someone closer to their goal, then that kind of thinking is rational.</p>
<h4 id="better-thinking">Better thinking</h4>
<p>With the framework and the definition of rational thinking at hand, we can now answer the question of how to think better. There are two ways:</p>
<ul>
<li>improve search</li>
<li>improve inference</li>
</ul>
<p>so that we can reach our goals more efficiently.</p>
<p>There are many ways to get better at either search or inference. Proponents of rational thinking discuss mainly overcoming biases and our struggle to inherently grasp probabilities. But doing certain activities alone will already have a positive impact. For example, writing is a full work-out of the search-inference framework. It starts with a goal (or multiple goals) to explore a subject. Interesting writing requires an extensive search for possibilities that have not been conveyed before. To be convincing, an author has to discuss evidence to form a compelling argument.</p>
<div class="footnotes" role="doc-endnotes">
<ol>
<li id="fn:tnd" role="doc-endnote">
<p><a href="http://www.cambridge.org/us/catalogue/catalogue.asp?isbn=0521659728">Thinking and Deciding</a> <a href="#fnref:tnd" class="reversefootnote" role="doc-backlink">↩</a></p>
</li>
</ol>
</div>Bernhard WenzelThe half-life of a tech-stackFreewriting and how to generate ideas bottom-up2020-07-15T17:00:00+02:002020-07-15T17:00:00+02:00https://bernhardwenzel.com/2020/Freewriting-generating-ideas-bottom-up<p>One apparent difference between human and artificial intelligence is that an algorithm needs to be fed with adequate data to be able to do something useful. In contrast, the human brain can be quite happy without external input. Giving the mind nothing to work on or confronting it with nonsensical material can stimulate fresh thinking.</p>
<p>This is what an exercise called “freewriting”<sup id="fnref:freewriting" role="doc-noteref"><a href="#fn:freewriting" class="footnote">1</a></sup> takes advantage of. I find it one of the most effective tools to generate new ideas. The rules are simple: during a limited time (usually 10-20 mins) write about a subject without ever stopping to move your hand (or to type on your keyboard). The key is to <em>never stop writing</em>. When you are out of things to say, instead of interrupting the writing flow by searching your mind for new ideas, jot down nonsensical words (for example, repeat the last word on the page multiple times) or filler phrases. I like to literally translate my mind onto paper and often use sentences like “I don’t know what to say” or “what else am I thinking here” and so on. As long as you keep putting words on paper, it does not matter what they are or if what you write makes any sense at all.</p>
<p>When you do this, something happens.</p>
<p>The brain is a thought producing machine that continuously spits out opinions, worries, ideas, memories and so on. When you challenge your mind with useless repetition and boredom, it will jump out the rut to something else. Quite often, that leads to uncovering new places or hidden corners.</p>
<p>Being able to come up with a fresh set of ideas whenever stuck is tremendously valuable. There is something about this “writing flow” that is not available to other techniques.</p>
<p>Another advantage is that freewriting reliably delivers a sense of accomplishment. As there are almost no rules (just keep going), it is not difficult to reach the writing goal. What is required is a concentrated effort to keep the mind on paper. That is in some respect, similar to what happens during meditation but simpler to execute. The challenge of meditation is not to get distracted and keep the mind aware of what is happening. In freewriting, distractions are welcome, and all we have to do is to follow them with our pen or keyboard. I find that a couple of intense writing sessions can clear up the mind in a similarly satisfying way as meditation can.</p>
<p>Because leaving the path is allowed and encouraged, the likelihood to encounter something new is high - an idea, direction or novel connection between existing ideas. Freewriting helps to enrich our internal map by adding further details to it. Clarity comes from bringing previously unrelated strain of thoughts into alignment.</p>
<p>This “connection making” happens automatically. What we need to do is to “feed” our mind with explorations of concepts, thoughts and mental images and then let it do its work.</p>
<p>Another way to describe what is going on is to developing ideas bottom-up versus top-down. Classical brainstorming starts top-down. We have a question or subject and try to find as many related ideas as possible. A freewriting session initially starts top-down. But then we allow the mind to digress and explore new directions that might not have anything to do with the original question. We then move into a bottom-up approach where ideas emerge through making novel connections. Bottom-up requires less effort as it is more natural to how we think and our brain functions.</p>
<p>I just scratched the surface of this fascinating subject of creativity and human versus artificial intelligence. More to come soon.</p>
<div class="footnotes" role="doc-endnotes">
<ol>
<li id="fn:freewriting" role="doc-endnote">
<p><a href="https://en.wikipedia.org/wiki/Free_writing">Definition of freewriting</a> <a href="#fnref:freewriting" class="reversefootnote" role="doc-backlink">↩</a></p>
</li>
</ol>
</div>Bernhard WenzelOne apparent difference between human and artificial intelligence is that an algorithm needs to be fed with adequate data to be able to do something useful. In contrast, the human brain can be quite happy without external input. Giving the mind nothing to work on or confronting it with nonsensical material can stimulate fresh thinking.And then Covid happened - Resilience as a blogger2020-06-24T18:00:00+02:002020-06-24T18:00:00+02:00https://bernhardwenzel.com/2020/And-then-covid-happened<p>Mike Tyson knows a thing or two about the meaning of disruption when he says that “everyone has a plan until they get punched in the mouth”.</p>
<p>Something similar happened to this blog. I had planned to write consistently on a regular publishing schedule (writing after hours and weekends) and even accounting for a major (but happy) change of welcoming a new family member. I was ready. But the pandemic had turned everything upside-down. I was confronted with a sudden, unexpected disruption that my blogger persona was not prepared to deal with.</p>
<p>Strategic planning involves predicting the future. Unforeseen events are, by definition, excluded from any consideration. If those do happen, something else matters - the inherent ability to bounce back from a sudden change. This is called <em>resilience</em>.</p>
<p>In systems engineering, resilience is defined as</p>
<blockquote>
<p>… an ability of the system to withstand a major disruption within acceptable degradation parameters and to recover within an acceptable time <sup id="fnref:system" role="doc-noteref"><a href="#fn:system" class="footnote">1</a></sup></p>
</blockquote>
<p>Applying this definition to this blog, the service degradation (little to zero article output) and time to recover (months) were both not acceptable.</p>
<p>But like most people, I hold more than one role in life - I’m also an employee, parent, partner and so on. Since this blog doesn’t pay my bills, other services I provide were more important to maintain.</p>
<h5 id="fast-versus-slow-disruption">Fast versus slow disruption</h5>
<p>Most of the time, when we think about resilience, we are talking about dealing with a <em>sudden</em> disruption - a pandemic, hacker attack, a new competitor, key employees leaving a company and so on.</p>
<p>However, harder to handle is <em>gradual</em> change. Service degradation is a temporary measure to gain time for dealing with a problem. This won’t work if the underlying cause can not be fixed immediately and requires a long-term adjustment.</p>
<p>Skills that slowly become obsolete is a prevalent example. Companies can deal with a skill shortage by hiring workers with the right expertise. But there is a limitation to how quickly it is possible to find and integrate new employees.</p>
<p>Even more restricted are individuals. The worker that has been laid off and finds that their skills are not in demand anymore will need time to acquire new expertise.</p>
<p>A better strategy to deal with slow change is constant gradual adaptation. Companies can train their workers and implement a culture that encourages learning. Workers that keep updating their skills doing their day-to-day job stay employable.</p>
<p>That is not always easy to accomplish. The interest of companies is stability. If in-house technology is mastered and fulfils business needs, there is little incentive for stakeholders to change anything. No new investments will be made just for the sake of helping employees to update their skills.</p>
<p>Some companies understand this and allow employees to spend a certain amount of their time to pursue personal interests. This is a start but doesn’t help if no guidance is provided on how to spend the time wisely. Our education system does not prepare students for a world where constant learning is required. This problem is amplified when it is not clear what technologies will stay relevant.</p>
<p>It is therefore beneficial to invest time into acquiring skills that have a long half-life. The author of this post believes that blogging is such a skill. Writing regularly, and in front of an audience, is an exercise in thinking and clear communication. Those are true meta skills that are useful for most of current and future jobs.</p>
<div class="footnotes" role="doc-endnotes">
<ol>
<li id="fn:system" role="doc-endnote">
<p><a href="https://www.igi-global.com/dictionary/cyber-threats-to-critical-infrastructure-protection/51260">What is system resilience</a> <a href="#fnref:system" class="reversefootnote" role="doc-backlink">↩</a></p>
</li>
</ol>
</div>Bernhard WenzelMike Tyson knows a thing or two about the meaning of disruption when he says that “everyone has a plan until they get punched in the mouth”.