<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Herbert Breunung</title>
    <description>The latest articles on DEV Community by Herbert Breunung (@lichtkind).</description>
    <link>https://dev.to/lichtkind</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F978004%2F0f8ccf48-a06e-4d9d-9707-82a0922cab42.jpeg</url>
      <title>DEV Community: Herbert Breunung</title>
      <link>https://dev.to/lichtkind</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/lichtkind"/>
    <language>en</language>
    <item>
      <title>What is an object?</title>
      <dc:creator>Herbert Breunung</dc:creator>
      <pubDate>Fri, 28 Feb 2025 18:22:43 +0000</pubDate>
      <link>https://dev.to/lichtkind/what-is-an-object-1cii</link>
      <guid>https://dev.to/lichtkind/what-is-an-object-1cii</guid>
      <description>&lt;p&gt;This most bland sounding question is one important gate into proper software engineering. Answering it right unlocks a view that avoids bloat and enables understandable code - on a micro and macro level.&lt;/p&gt;

&lt;p&gt;We all know what objects are, right? They are the things we create from a class with &lt;strong&gt;attributes&lt;/strong&gt; and &lt;strong&gt;methods&lt;/strong&gt;. They are like cars, all built the same way in the factory, but now have different drivers (owners), who put different stuff (data) in the trunk and do different tasks. And in order to create a better car, we take (&lt;strong&gt;inherit&lt;/strong&gt;) the blueprint (class) and latch on some new functionality or change (overwrite) functionality (methods). The ladder is also called &lt;strong&gt;polymorphism&lt;/strong&gt;, because the new car can replace its  ancestor, but has a different form. The sad part of this rant - most students, professors and even working professionals would subscribe to that - although it's beside the point.  &lt;/p&gt;

&lt;p&gt;You can get objects without classes, which is called prototype based OO and very popular e.g. with Javascript. You can also go without inheritance and employ &lt;em&gt;reuse by composition&lt;/em&gt;, where attributes are instances of the class  you wanted to inherit from. And as a corollary, you certainly can do without polymorphism. So what is left? - Encapsulation and abstraction! And I would even replace the word abstraction with &lt;strong&gt;simplification&lt;/strong&gt;, because that is less confusing. Even if both concepts go hand in hand - let's start with : &lt;/p&gt;

&lt;h2&gt;
  
  
  Encapsulation
&lt;/h2&gt;

&lt;p&gt;A capsule is a shell, a package, which hides its content, protecting it from damage. In our case that means protected from user access. But every package and every function, in my language of choice even every block can have private variables. Why do we need objects? - For &lt;strong&gt;convenience&lt;/strong&gt;! In fact, one could put all the functionality of a class into one closure (function with permanent private variables). And instead of calling methods from an object reference, one could call this closure with our object ID and other needed arguments. The computer wouldn't mind. The result would be the same. But the code would look convoluted. Instead of calling &lt;em&gt;do_everything( pink_taxi, 'drive_to', 'munich');&lt;/em&gt; it is natural for humans to read &lt;em&gt;pink_taxi.drive_to('munich');&lt;/em&gt;. Even more importantly, the inside of the class is way better understandable if all functionality is packaged and sorted into neat little methods than if all is crammed into on function. So is it just about a bunch of functions sharing state (data)?&lt;/p&gt;

&lt;h2&gt;
  
  
  Simplification
&lt;/h2&gt;

&lt;p&gt;YES! - even if that upsets some academics who like to carry around big words like polymorphism and abstraction. They sound like Plato, dealing with otherworldly ideas, from which everything is made. In reality, software works more like nature. One cell or organism produces another one, which produces another one. The only abstract ideas might be in the head of the programmer. In the previous paragraph I called the purpose of an object simplification. Because this is the side effect of a correct usage of encapsulation. The methods (functions), which are visible from outside the capsule, are called &lt;strong&gt;interface&lt;/strong&gt; - or even shorter: API. They provide access to the functionality of the inner part of the class, but hide details. They should hide everything that burdens the user's mind and does not add meaningful degrees of freedom in his decision making. Crafting an API is an art form which includes using the right words, knowing what to leave as option and so forth (&lt;a href="https://dev.to/lichtkind/brain-memory-management-153o"&gt;more on that here&lt;/a&gt;). But in the end it's all about lowering the mental strain. I prefer to focus on this most important goal by calling it simplification, not abstraction. What good are 10 most smart abstraction levels, if they just add confusion?&lt;br&gt;
&lt;strong&gt;Making complexity manageable&lt;/strong&gt; is the main purpose of objects. And please note that detail hiding and the encapsulation are consequences from the same enclosure.&lt;/p&gt;

&lt;p&gt;The tools of OO are just two old ideas:&lt;br&gt;
    1. Variables and functions hide together in a namespace&lt;br&gt;
    2. Instantiation (like you do with any variable)&lt;/p&gt;

&lt;p&gt;No wonder Bjarne Stroustrup calls objects in the classic "&lt;em&gt;Annotated C++ Reference Manual&lt;/em&gt;" custom data types. &lt;strong&gt;Alan Kay&lt;/strong&gt;, who coined the term object orientation and was co-inventor of &lt;em&gt;Smalltalk&lt;/em&gt;, the second OO language, said in talks that the core concepts are encapsulation, abstraction and message passing. With message passing he just meant calling methods with arguments. Reading him also brought me to my senses regarding this matter. &lt;/p&gt;

&lt;p&gt;One might argue that the very first OO language: &lt;em&gt;Simula&lt;/em&gt; had multiple inheritance and Alan left it out just for personal taste. Well the vision of Simula was to unify software design and programming which is a great idea  and unfortunately today unpopular. But it was after all an academic experiment and originally lacked even encapsulation.&lt;/p&gt;

</description>
      <category>oop</category>
      <category>softwareengineering</category>
      <category>softwaredesign</category>
    </item>
    <item>
      <title>Welcome Cellgraph</title>
      <dc:creator>Herbert Breunung</dc:creator>
      <pubDate>Fri, 21 Feb 2025 17:23:03 +0000</pubDate>
      <link>https://dev.to/lichtkind/welcome-cellgraph-5b7f</link>
      <guid>https://dev.to/lichtkind/welcome-cellgraph-5b7f</guid>
      <description>&lt;p&gt;I wrote &lt;a href="https://metacpan.org/pod/App::GUI::Cellgraph" rel="noopener noreferrer"&gt;a free app&lt;/a&gt; that draws tiled pictures with cellular automaton. They are a bit like the autogenerated avatar pictures on github. The picture above is for instance created by it. However, you can make them much more personalized, more beautiful and certainly more complex - once you understand the many parameters (knobs and buttons in the app). To help you with it I wrote this text. So let's start with the basic question: what are cellular automata?&lt;/p&gt;

&lt;p&gt;Each tile is one &lt;strong&gt;cell&lt;/strong&gt;. And that tile has a color, representing its state which is little more than just an one digit number. The cells are lined up in a row and you can define their starting state by hand, by clicking on them in the second tab (&lt;em&gt;Starting Row&lt;/em&gt;), since every start configuration can produce a very different pattern.&lt;/p&gt;

&lt;p&gt;The actual picture will be computed step by step by a rule - which you can also choose, since every rule draws the picture with a different pattern. The rule operates like a gigantic if statement. It just checks: what is the state of a cell and what is the state of its neighbors. For every combination of states in this neighborhood there is a fixed result, which will be the new state (color) of the cell. This way you get a new row of colored tiles. This process will be repeated until we get a square shaped picture.&lt;/p&gt;

&lt;p&gt;This was a very simplified, since I expanded the original concept greatly. The (last) colors tab alone has predefined color sets a huge color store, color functions to compute gradiants and complementary colors. Furthermore can each color changed on the RGB or HSL axis with their own randomizer buttons. And this was just one of 5 tabs of setting. If you want to know every detail, please read the &lt;a href="https://metacpan.org/pod/App::GUI::Cellgraph" rel="noopener noreferrer"&gt;manual&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;There are also activity rules that can hinder cell state changes for more broken patterns and also buttons that get you related rules. But the maybe most interesting and fruitful features are the following three: &lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Paint Direction&lt;/strong&gt;: Default is top down as described. But you can also let it draw from outside in (on all four sides) or inside out (also), which makes your image automatically mirror symmetric, twice.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Rule Mapping&lt;/strong&gt;: If the cell neighborhood has the size of 5 (2 neighbors on each side) and you selected 7 states they can build 7**5 (seven to the power of 5) = 16_807 different patterns. You will not manually choose the result of 16_807 sub-rules. But on other side having more states (colors) will make you drawings more interesting. So be cautious at first and select the strongest rule mapping called &lt;em&gt;summing&lt;/em&gt;. Now you have only 35 distinct sub-rules (2 pages full). Then hit the random button to get a starting point and change only those sub-rules that are bottlenecks (the have the largest counter values - they are applied most often).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Result Application&lt;/strong&gt;: If you're new, you might lack the logical intuition where the bottle necks are. Then you got drawing where nothing happens - even if you change some sub-rules. In that case you could choose not just insert the result of a sub-rule as the new cell state. You could also add or multiply them. If you stuck should take an operation that contains a rot or rotation in the names. Then there will be always added an additional value of one. This will make sure that the cell state changes from computation round to next and you will get interesting pictures fast.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;If you want to know more , please look &lt;a href="https://blogs.perl.org/users/lichtkind/2025/02/polishing-thr-t-urtle.html" rel="noopener noreferrer"&gt;here&lt;/a&gt; and &lt;a href="https://blogs.perl.org/users/lichtkind/2022/12/automatic-art.html" rel="noopener noreferrer"&gt;there&lt;/a&gt; and if you liked the program and have improvement suggestions please let me know. Thanks&lt;/p&gt;

</description>
      <category>graphics</category>
    </item>
    <item>
      <title>Recents</title>
      <dc:creator>Herbert Breunung</dc:creator>
      <pubDate>Sun, 09 Feb 2025 14:24:09 +0000</pubDate>
      <link>https://dev.to/lichtkind/recents-173p</link>
      <guid>https://dev.to/lichtkind/recents-173p</guid>
      <description>&lt;p&gt;Recently changed articles:&lt;/p&gt;

&lt;h2&gt;
  
  
  New
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://dev.to/lichtkind/what-is-an-object-1cii"&gt;What is an object?&lt;/a&gt; (28.Feb.2025)&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://dev.to/lichtkind/welcome-cellgraph-5b7f"&gt;Welcome Cellgraph&lt;/a&gt; (21.Feb.2025)&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://dev.to/lichtkind/a-tale-about-four-gangsters-29g6"&gt;A tale of four gangster&lt;/a&gt; (9.Feb.2025)&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Changed
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;a href="https://dev.to/lichtkind/what-is-an-object-1cii"&gt;What is an object?&lt;/a&gt; (3.,26.March.2025)&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://dev.to/lichtkind/brain-memory-management-153o"&gt;Brain Memory Management&lt;/a&gt; (1.March 2025)&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://dev.to/lichtkind/system-thinking-2fmp"&gt;System Thinking&lt;/a&gt; (9.Feb.2025)&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>changelog</category>
    </item>
    <item>
      <title>A tale about four gangsters</title>
      <dc:creator>Herbert Breunung</dc:creator>
      <pubDate>Sun, 09 Feb 2025 10:14:20 +0000</pubDate>
      <link>https://dev.to/lichtkind/a-tale-about-four-gangsters-29g6</link>
      <guid>https://dev.to/lichtkind/a-tale-about-four-gangsters-29g6</guid>
      <description>&lt;p&gt;In the programming sphere "&lt;strong&gt;Design Pattern&lt;/strong&gt;" by &lt;em&gt;Gamma&lt;/em&gt;, &lt;em&gt;Helm&lt;/em&gt;, &lt;em&gt;Johnson&lt;/em&gt; and &lt;em&gt;Vlissides&lt;/em&gt; is a true classic. The book from 1995 set a standard, shaped the language we use in the software engineering domain and is used in innumerable university courses. This article is my attempt to critique it on multiple levels while avoiding to sound like a know it all prick. Not an easy task, since the criticism will be harsh.&lt;/p&gt;

&lt;p&gt;But to start with the good: the &lt;strong&gt;main idea&lt;/strong&gt; is very powerful and uplifting. Yes, there are reoccurring patterns in class structures that aim to solve reoccurring challenges. And it is helpful to identify, name and analyze them in order to express concisely how our program is constructed and to know something beforehand about the up- and downsides of our design choices. Being a massive proponent of that made me write these lines. &lt;/p&gt;

&lt;p&gt;However, as stated in the foreword and chapter 6.3 of the conclusion part, this great idea came from &lt;strong&gt;Christopher Alexander&lt;/strong&gt;, an architect of buildings. He was mainly interested in architecture that supports human flourishing - something not mentioned in chapter 6.3. In order to serve the inhabitants, he expected also that design patterns were mixed and adapted freely. A stark contrast to the cooky cutter approach of our four suspects.&lt;/p&gt;

&lt;p&gt;Their &lt;strong&gt;primary goal&lt;/strong&gt;, as stated in the introduction, was to &lt;strong&gt;simplify&lt;/strong&gt; the &lt;strong&gt;design and reuse&lt;/strong&gt; of &lt;a href="https://dev.to/lichtkind/what-is-an-object-1cii"&gt;object oriented&lt;/a&gt; (OO) software. OO programming was just entering the main stream and our gang tried to facilitate that by using The main stream language for OO at the time (C++) in their examples. They did apply all the powerful OO features C++  had to offer, while ignoring the much simpler reuse by composition or argument (post about that is incoming). In short - they chose inheritance as their hammer and every problem became a nail. And as a result, some solutions are unnecessary complicated. Another big chunk of &lt;strong&gt;bloat&lt;/strong&gt; could be removed by using OO features popularized after the book was published. Although, that doesn't stop people to teach the original pattern even today. And this might be the biggest mistake - to perceive these patterns as sacrosanct. The gang members spread this attitude by teaching to replicate the pattern in our own code over and over. But the natural and sane tendency of programmers is to remove &lt;strong&gt;boiler plate&lt;/strong&gt; and to ensure that staples of daily life become part of the core language or at least the standard library, so that they can be accessed through an expressive syntax and with the least amount of typing. (I got that insight from Mark Jason Dominus.) These patterns should show up in the way a program functions, but not necessarily in its written form.&lt;/p&gt;

&lt;p&gt;In summary: I miss the intellectual rigour in this book. Some patterns mix several ideas, some are repeating previous ideas and some are not pattern at all, but mere examples tied to unnecessary specifics. This confusion can only result in overcomplicated class structures that drain life force out of the programmer who mentally lives in them. That form of gangsterism is the opposite of what Christopher Alexander longed for.&lt;/p&gt;

</description>
      <category>architecture</category>
      <category>oop</category>
    </item>
    <item>
      <title>Article Index</title>
      <dc:creator>Herbert Breunung</dc:creator>
      <pubDate>Fri, 31 Jan 2025 10:22:29 +0000</pubDate>
      <link>https://dev.to/lichtkind/index-41i3</link>
      <guid>https://dev.to/lichtkind/index-41i3</guid>
      <description>&lt;p&gt;All articles, grouped by topic. They are also interlinked and like wiki pages. Sometimes they get enhanced or rewritten (see in &lt;a href="https://dev.to/lichtkind/recents-173p"&gt;Recents&lt;/a&gt;).&lt;/p&gt;

&lt;h2&gt;
  
  
  Software Engineering
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://dev.to/lichtkind/system-thinking-2fmp"&gt;System Thinking&lt;/a&gt;&lt;br&gt;
&lt;a href="https://dev.to/lichtkind/a-tale-about-four-gangsters-29g6"&gt;A tale of four gangster&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Programming
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://dev.to/lichtkind/brain-memory-management-153o"&gt;Brain Memory Management&lt;/a&gt;&lt;br&gt;
&lt;a href="https://dev.to/lichtkind/good-file-structure-1p39"&gt;Good File Structure&lt;/a&gt;&lt;br&gt;
&lt;a href="https://dev.to/lichtkind/what-is-an-object-1cii"&gt;What is an object?&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  My Projects
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://dev.to/lichtkind/welcome-cellgraph-5b7f"&gt;Welcome Cellgraph&lt;/a&gt;&lt;/p&gt;

</description>
      <category>softwareengineering</category>
    </item>
    <item>
      <title>Good File Structure</title>
      <dc:creator>Herbert Breunung</dc:creator>
      <pubDate>Sat, 28 Dec 2024 20:42:42 +0000</pubDate>
      <link>https://dev.to/lichtkind/good-file-structure-1p39</link>
      <guid>https://dev.to/lichtkind/good-file-structure-1p39</guid>
      <description>&lt;p&gt;My &lt;a href="https://dev.to/lichtkind/brain-memory-management-153o"&gt;last post&lt;/a&gt; ended on the note, that code files need a dependable structure. Work becomes more productive and enjoyable if you know where is what, without having to read characters - just from scanning the contours. And you don't even have to memorize the order of sections, as long as the file structure adheres to one overarching rule: FROM THE GENERAL TO THE DETAIL. This rule is intuitive and helps you understand the code in one read. Let me explain.&lt;/p&gt;

&lt;p&gt;Even Japanese or Jews start to read a code file in the upper left corner. At that point they may or may not have some knowledge of the content. So it is better to get a broad picture of the content while starting to read. Later smaller and smaller details will be added as needed - FROM THE GENERAL TO THE DETAIL.&lt;/p&gt;

&lt;p&gt;The most general parts of a code file are the meta information are the most, like author, date and license. In my opinion the license is way too much text to be included in a code file. Just insert a reference to the file or put the file in an expected place, like the projects root directory, which is also legally binding. And keep the other meta info including its formatting to a minimum, since its rarely of interest. But put it on top or bottom so its easy to skip.&lt;/p&gt;

&lt;p&gt;Often you see one or more lines in the meta header, that summarize the content or purpose of the file. The ladder is much more important and should stand just above the name of the namespace / package / object, so they both build a unit that sets up your orientation and expectation. This part is crucial and worth spending time on. It helps the author to sharpen his understanding of what is to be achieved here, which can dramatically improve code clarity and thus quality. It also ensures that the namespace / package / object name is the explicit and concise summary of the summary. Finding such names is a good part of professional programming and this arrangement supports you in that. Because if feel some meaning is missing in the name, you have to add it in the summary. Just don't stop there, but think hard about what aspects of the summary can be deleted by choosing a better name. After you changed the name and shortened the summary, you may want to insert other information into the summary which were left out in order not to bloat. Then the cycle starts again until its good enough.&lt;br&gt;
This technique can also be applied to any other identifier like variables and method names.&lt;/p&gt;

&lt;p&gt;The next, less general information is the version number of this namespace and the used programming language. Subsequent are pragmas (optional language features) and library load commands. First the ones from the language core, then third party libs, then the internal ones. Global constants, enums and variables follow. If there are more than a few items, group them for better oversight. Now we have left only the routines, functions or methods. Visual separators are helpful to distinguish between the just described head section and the various types of methods. The following paragraphs will be just about methods, because if you only have functions, you can group them by topic without thinking too much about it. But you should also apply some of the principles that are best taught in an object oriented context.&lt;/p&gt;

&lt;p&gt;It is logical to start with the constructor. Not only because it's the first method you will use and probably the first a reader will seek. The constructor will tell you also about many of the arguments used in any method and more importantly about the internal data structure of the class. With that knowledge any subsequent method becomes far easier to grok. And - while we're on the topic of the life cycle of an object - the destructor method and even serialisation (if present) should be part of this section too. If only because the code that employs the same special knowledge should be pooled together to minimize searches and make code more self documenting.&lt;/p&gt;

&lt;p&gt;The only other methods that reach into parts of the internal data structure should be the getter- and setter- methods - also known as accessors. These are the content of the second block of methods. They are usually very small and give you a good and fast outline over the internal and external interface (API) and its data flow.&lt;/p&gt;

&lt;p&gt;Next are the methods that contain the most lines of code - let's call them workhorse methods. They should be few and well commented. &lt;/p&gt;

&lt;p&gt;The fourth section contains helper functions and methods, that are so specific to this class, that they should not be abstracted into an own namespace. Some might protest and call this bad practice and violation of the stated goal: being able to understand the class in one reading. &lt;br&gt;
They want to know the content of a method before it is called, to have a thorough understanding of what is happening. While I sympathize with this stance, I think it contains misunderstandings. First off, most constructors call others methods - so it is not a rule we can comply with while holding to the proposed order. Secondly, an implication of our stated main rule is the sub rule: from the public API on inward. This alone places the auxiliary methods last. But the best defense recalls the purpose of a method. It is a piece of abstraction. If you need to see the internals, you have created a flawed abstraction. Either the function name does not tell you what is going on, or the method is too  big (complex) or even worse: it has side effects.&lt;/p&gt;

&lt;p&gt;Sure sticking to all this takes discipline at first (read: pain). But it pays off in the long run. Your code gets easier to read, maintain and extend (all what was promised by using OO). Even writing new classes becomes easier, since you no longer think about a lot of details. You are free to concentrate on the irreducible problems that your class solves. So have fun and fine tune the rules to your sensibilities and needs - but be consistent.&lt;/p&gt;

</description>
      <category>programming</category>
      <category>productivity</category>
    </item>
    <item>
      <title>Brain Memory Management</title>
      <dc:creator>Herbert Breunung</dc:creator>
      <pubDate>Wed, 13 Dec 2023 19:40:48 +0000</pubDate>
      <link>https://dev.to/lichtkind/brain-memory-management-153o</link>
      <guid>https://dev.to/lichtkind/brain-memory-management-153o</guid>
      <description>&lt;p&gt;In my &lt;a href="https://dev.to/lichtkind/system-thinking-2fmp"&gt;first post&lt;/a&gt; I cheered for system thinking and understanding even the mind as a system. That can be driven to any amount of complexity, but today lets just look on two very important components: the &lt;strong&gt;rational&lt;/strong&gt; &lt;strong&gt;and&lt;/strong&gt; &lt;strong&gt;intuitive&lt;/strong&gt; mind.&lt;/p&gt;

&lt;p&gt;To be a good programmer you need &lt;strong&gt;both&lt;/strong&gt;. Without an rational mind of course you can not construct an correct algorithm. This is the basis of any practical detail work. &lt;/p&gt;

&lt;p&gt;But it's often overlooked that programmers using the intuitive mind as well - actually all the time. Whenever you &lt;strong&gt;switch context&lt;/strong&gt; from lib to lib or even between routines (called sub in Perl), you metaphorically fold all detail knowledge you had about the previous piece of code into a general, felt notion and unzip another set of facts you know, just read or make up about the current sub. It can't be any other way, because experiments have shown, there is a single digit &lt;strong&gt;limit&lt;/strong&gt; of hard &lt;strong&gt;facts&lt;/strong&gt;, your rational mind can &lt;strong&gt;hold&lt;/strong&gt;. In some cases it can reach 20, 25 at max.&lt;/p&gt;

&lt;p&gt;That's why it matters to structure code in a way that: 1. you never deal with too much informations at once and 2. you prepare the reader for what is coming (the context switch) with some distinct command, identifier (name) or comment. This is what makes code intuitive. In other words: it is always a good to &lt;strong&gt;lower&lt;/strong&gt; the &lt;strong&gt;cognitive load&lt;/strong&gt; of code - But how we do that?&lt;/p&gt;

&lt;p&gt;Most important are understandable abstractions, that guide thinking and usage. But this topic is a way too big  for this little text and will get its own post later. Next in importance are identifiers - the names we give subs, variables, classes, packages ... Yes we heard they have to be clear, fitting, concise and if possible unique - so they lower the need for (visiting) comments and docs. But to help cognitive transitions they should also fit their surroundings. For instance an attribute named "mover" of a class named "car" should be renamed to for instance "wheel". That fits the context set by the class name, is more specific and sparks a stronger &lt;strong&gt;mental image&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Identifiers should invoke &lt;strong&gt;emotions&lt;/strong&gt;, because that makes them memorable. Or in more neurological terms - you can connect the invoked emotions to other impressions to create an intuitive map of the code.&lt;/p&gt;

&lt;p&gt;And you can reduce the &lt;strong&gt;cognitive friction&lt;/strong&gt; even more by making terms consistent. Even smaller projects should have a little &lt;strong&gt;glossary&lt;/strong&gt; file where used words are defined. And whenever this specific thing is referred too, no matter if in a variable, method or class name, it will be done only by this word. And if something is similar but not that specific thing - try hard to use another word. Especially when a method name uses 2 or 3 of these specified words - its name will work like documentation in most cases. This is why I like to start projects with writing documentation. Not only because fishing for ideas while coding is the cause of much suffering, but also because you have time to coin and define the most important terms before you start to use them. &lt;/p&gt;

&lt;p&gt;Changing them later is tedious because its harder than just refactoring, since you have to go over many types of identifiers in many files. Normal refactoring tools would help you only partially with that, since their focus is much narrower. They rename only one variable or method name at a time. And only in one scope. You also want to have the same variable name for the same thing in different methods. Especially for arguments - which makes the API much simpler without even touching the logic.&lt;/p&gt;

&lt;p&gt;All these practices are mentally too demanding to be done while coding. You really can only do on thing right at a time. And because you try to avoid tedious refactoring they should be done in front. On the other hand you need in most cases at least some class structure to come up with some fitting names. This is why I like to set up during the early planning stage of a project some empty dummy classes and add only certain methods, variables or comments that are essential for understanding what should go where. If you develop it in parallel with the rough outline of the user documentation and make sure you use the same words for the same things and actions in both - that also massively reduces cognitive friction. It makes the documentation more helpful and code way better understandable.&lt;/p&gt;

&lt;p&gt;Another technique for finding good names is &lt;strong&gt;commenting&lt;/strong&gt;. Quite often I just used the first best variable name and commented what i actually meant by it. Again - I was busy to figure the algorithm. Later, when glancing at the class as a whole the right name just popped out and it was just one of the words I wrote down in the comment. Having that comment, made it actually easier to find it.&lt;/p&gt;

&lt;p&gt;If a variable has no special meaning like a counter, then  "i" or "cc" is acceptable and contrasts nicely with meaningful variables with actual words in the name.&lt;/p&gt;

&lt;p&gt;Organizing subs into parts (blocks) also helps greatly to quick scan and understand. The whole &lt;a href="https://dev.to/lichtkind/good-file-structure-1p39"&gt;file structure&lt;/a&gt; should be communicating meaning, but that's also a topic for another day.&lt;/p&gt;

</description>
      <category>productivity</category>
      <category>softwareengineering</category>
      <category>architecture</category>
    </item>
    <item>
      <title>System Thinking</title>
      <dc:creator>Herbert Breunung</dc:creator>
      <pubDate>Fri, 08 Dec 2023 11:28:05 +0000</pubDate>
      <link>https://dev.to/lichtkind/system-thinking-2fmp</link>
      <guid>https://dev.to/lichtkind/system-thinking-2fmp</guid>
      <description>&lt;p&gt;Most of us here know how good software looks like. It has a functioning distribution package, docs in order, meaningful abstractions, manageable user interface comments when needed and so forth. Naturally, if you want to uphold such a nice state you have to think a lot before doing anything, then going three steps backward and make a lot of other changes just to enable the changes you want to make and maybe even fixing stuff you discovered on the way.&lt;/p&gt;

&lt;p&gt;Yes real programming can be tedious if not broken down in small enough tasks (release often). And there is lots written about it, that loosely fits into the category of software engineering. But instead of memorizing lots of rules, I find it far more helpful to adopt system thinking.&lt;/p&gt;

&lt;p&gt;Programmer already (should) do that when writing tests. Then we step outside our role of an app/lib dev and try to think about all the ways the software could be broken. In similar fashion we can read our docs like someone who tries to get basic help. Yes that's not easy and also a bit silly task - just to pretend what we don't know what we know. But it is an acquired skill to blend out certain knowledge and having fun to play ignorant. In the end its way more effective than organize someone who is really an outsider and communicate with him - especially with the first 70-80% of the issues. Once you have quality docs with some issues, the game is different. Then it can be helpful to have another set of eyes, that bring up issues which have to be fixed by the author anyway.&lt;/p&gt;

&lt;p&gt;And if we understand software building as a system of interaction between the manager, developer, user and other people, we can access if things are good simply by taking the perspective of a role - after all these are humans too.&lt;/p&gt;

&lt;p&gt;We should see - the most important system in that of the  human awareness. Things like attention span, direction of focus, amount of data that fits into the rational mind or the intuitive mind (magnitudes more) and so forth are to seldom considered and taught. But if you know a bit about it (and my next posts will talk more about it) it will be less hard to simulate other perspectives. It will also help you to stick to processes, that have your own human limits as a developer in mind. This is the core of my cellular programing method, than i want to develope also in following posts.&lt;/p&gt;

</description>
      <category>programming</category>
      <category>productivity</category>
    </item>
  </channel>
</rss>
