<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Jonathan Bispo on Medium]]></title>
        <description><![CDATA[Stories by Jonathan Bispo on Medium]]></description>
        <link>https://medium.com/@jfb0101?source=rss-9dffb3a24a29------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*6sHB6FCArFubHbzLnX2caQ.png</url>
            <title>Stories by Jonathan Bispo on Medium</title>
            <link>https://medium.com/@jfb0101?source=rss-9dffb3a24a29------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 24 Nov 2026 05:56:54 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@jfb0101/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[A Technique to Inspect Complex Code With Mind Maps]]></title>
            <link>https://medium.com/better-programming/a-technique-to-inspect-complex-code-with-mind-maps-2dc83bb4c3a9?source=rss-9dffb3a24a29------2</link>
            <guid isPermaLink="false">https://medium.com/p/2dc83bb4c3a9</guid>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[clean-code]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Jonathan Bispo]]></dc:creator>
            <pubDate>Tue, 13 Sep 2022 11:27:50 GMT</pubDate>
            <atom:updated>2022-09-18T11:45:50.495Z</atom:updated>
            <content:encoded><![CDATA[<h4>Through Freemind</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*FXO8ebwIP17Pgiy0" /><figcaption>Photo by <a href="https://unsplash.com/@natcon773?utm_source=medium&amp;utm_medium=referral">Natasha Connell</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Reading and understanding complex code is a very hard task. Not always the code has good variable names, concise and pure functions, tests, etc. Unfortunately rewriting the code is rarely an option.</p><p>In my day-to-day, I need to read and understand old code — written years ago, before the good practices in software development were created. Not only this type of code, but even recent code, written in new languages, can be very hard to understand at the first time.</p><p>I’ve tried to find a way to analyze this type of code with less effort and find out that by using mind maps, the code can be viewed in a better way. I always liked mind maps. Since 2008 I used it to organize a lot of information hierarchically. Mind maps are one of the best (or the best) ways to study and store information, in my opinion.</p><p>In this article, I will use the <a href="http://freemind.sourceforge.net/wiki/index.php/Main_Page">Freemind mind mapping tool</a>.</p><p>To explain the technique, I’ll use one example in Python. I am a computing professor and when I teach programming languages I always create with my students a Tic Tac Toe game. To detect if player 1 or player 2 wins in each round, run this algorithm:</p><p>Start a 3x3 matrix filled with zeroes.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/595/1*RZYGbAdB5D15uDiuZlUP_w.png" /></figure><p>When player 1 makes a move, I write 1 in the cell. When player 2 makes a move, I write 2 in the cell. So this is an example that player 1 wins in the main diagonal:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/591/1*9ulwPi_4B_p--cNbfTOzXA.png" /></figure><p>To detect that player 1 wins, do the product on the lines, columns, and diagonals. If the result is 1, player 1 wins; if the result is 8, player 2 wins; if the result is 0, 2 or 4, nobody wins in this line, column, or diagonal.</p><p>That’s it, simple.</p><p>This is the Python function with the algorithm implemented:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/c7688159f70f6b81262f5f0728c755bb/href">https://medium.com/media/c7688159f70f6b81262f5f0728c755bb/href</a></iframe><p>This function is written in a way that I consider adequate: the search in lines, columns, and diagonals is splitted into nested functions inside the main function, and it uses enums to describe players and winners. In addition, the early returns (that can be considered a bad thing) in this algorithm are not a problem — given that the main flow is simple to see and understand.</p><p>Even the technique described in this article is focused on complex algorithms, not well written like this. I chose this example because is more simple to explain and understand.</p><p>Now, with the code and Freemind opened I copy and paste the code, and voilà! The magic is done.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2WDZ84oRbaadrb3MkN_cyA.gif" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/980/1*CqUzF-bTnoTx3QVsQw8AVg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*OkOG-YT8NUA4kJnM6-jeyw.png" /></figure><p>Freemind recognize tabs as child nodes automatically, so the code without a tab is placed on the first node slice, with one tab on the second node slice, and so on.</p><p>With Python, as the indentation is part of the source code, it is even easier. But in languages like C#, for default the braces are placed in one line below the statement, the mind map can be difficult to read, with a lot of braces.</p><p>Tools like this <a href="https://formatter.org/csharp-formatter">https://formatter.org/csharp-formatter</a> with formatter set to Chromium and line width set to a high value, can help.</p><p>Another example: if the code has an unusual indentation (like in Visual FoxPro when an if statement is very long), it is common for developers to break the if condition, put semicolon, go to the line below add use tabs to put the code aligned with original if. In this situation, you need to adjust manually the nodes in a mind map.</p><p>As said before, this example is simple — with few functions, well-written code. But imagine a code with if inside else, inside for, inside while, inside try, and a lot of these statements, with the mutability of variables, etc.</p><p>Not always the outline of IDE can help to visualize the code. When you are reading the content of an if statement, you may forget in which structure this if statement was.</p><p>With the code placed in a mind map structure, you can visualize this more easily, and hierarchically, which is a natural way to read and write code.</p><p>Furthermore, Freemind offers a lot of tools: write notes, colorize, create links between the nodes, draw clouds around the nodes, etc. All of these can be used to help understand complex codes.</p><p>I hope this hint can help you to understand complex (and unfortunately a lot of times, bad) codes. Developers spend much more time reading than writing code. So improving readability is always a target in software development.</p><p>In an ideal world, this type of technique would not be necessary! Always try to write good code. If you need to use this technique, can be a clue that refactoring is necessary. Clean Code book from Robert Martin and understanding concepts of functional programming are good start points to writing better code.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2dc83bb4c3a9" width="1" height="1" alt=""><hr><p><a href="https://medium.com/better-programming/a-technique-to-inspect-complex-code-with-mind-maps-2dc83bb4c3a9">A Technique to Inspect Complex Code With Mind Maps</a> was originally published in <a href="https://betterprogramming.pub/">Better Programming</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>