<?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>Forem: Andreas Barbesgaard</title>
    <description>The latest articles on Forem by Andreas Barbesgaard (@sprutnums).</description>
    <link>https://forem.com/sprutnums</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%2F2243364%2F4e17d697-9b22-4ee4-82f1-a318b132ca19.png</url>
      <title>Forem: Andreas Barbesgaard</title>
      <link>https://forem.com/sprutnums</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/sprutnums"/>
    <language>en</language>
    <item>
      <title>Learn to ride a bike before learning to ride a motorcycle</title>
      <dc:creator>Andreas Barbesgaard</dc:creator>
      <pubDate>Tue, 18 Mar 2025 08:07:06 +0000</pubDate>
      <link>https://forem.com/sprutnums/learn-to-ride-a-bike-before-learning-to-ride-a-motorcycle-57ko</link>
      <guid>https://forem.com/sprutnums/learn-to-ride-a-bike-before-learning-to-ride-a-motorcycle-57ko</guid>
      <description>&lt;p&gt;&lt;em&gt;Take everything with a gain of salt I'm a student leaning how to program&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;When I was 5 years old, I was learning how to ride a bike. A shiny day, the wind rustling through the leaves. My small body had to manage balance, the feel of the handlebars, and my father's encouraging cheers from the sidewalk. I turned my head to smile and &lt;strong&gt;bam&lt;/strong&gt; - faceplant.&lt;/p&gt;

&lt;p&gt;Now imagine if I had started on a motorcycle instead.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Dead before turning 6, I guess.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Why mention this? Because this analogy perfectly captures the relationship between learning to code and jumping straight to using Large Language Models (LLMs).&lt;/p&gt;

&lt;p&gt;Just as we respect the natural progression from bicycles to motorcycles, I should approach coding with the same reverence for the learning process. &lt;/p&gt;

&lt;p&gt;A child masters balance and basic controls on a bicycle before graduating to the power and complexity of a motorcycle. Similarly, I as a Developer, need to understand programming fundamentals before effectively harnessing LLMs.&lt;/p&gt;

&lt;p&gt;When I, without fundamental skills, rely entirely on LLMs to generate code I don't understand, I've essentially placed my self in the shoes of a child riding motorcycles—unaware of the dangers and unprepared for the consequences when things go wrong.&lt;/p&gt;

&lt;p&gt;The stakes have never been higher. Code is increasingly controlling critical systems in our world. Understanding what happens under the hood isn't just academic—it's essential for building safe, reliable software that won't endanger lives when it inevitably encounters edge cases and unexpected scenarios.&lt;/p&gt;

</description>
      <category>ai</category>
      <category>programming</category>
      <category>llm</category>
    </item>
    <item>
      <title>How to write dirty code</title>
      <dc:creator>Andreas Barbesgaard</dc:creator>
      <pubDate>Fri, 25 Oct 2024 04:42:55 +0000</pubDate>
      <link>https://forem.com/sprutnums/how-to-write-dirty-code-mpm</link>
      <guid>https://forem.com/sprutnums/how-to-write-dirty-code-mpm</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;Are you sick of hearing about "clean code"? &lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Do you long for the good ol' days of cryptic variables, magical numbers, and code that looks like it was written by a very ambitious raccoon? Look no further! &lt;/p&gt;

&lt;p&gt;Presenting: the ultimate guide to writing code that will make your colleagues cry and future you ask, “What in the world was I thinking?”&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Use Incomprehensible Variable Names
&lt;/h2&gt;

&lt;p&gt;Why settle for clear names like customerEmail or orderTotal when you can achieve peak confusion with x1 and totalStuff? The goal is simple: nobody (especially you) should be able to figure out what the variables mean in the future. Ambiguity is your friend.&lt;/p&gt;

&lt;p&gt;Example: Let temp hold… something important. Or maybe not. That’s for others to figure out!&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;y&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;x&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;x1&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="m"&gt;43&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="n"&gt;y2&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"_,,_"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;z3&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="n"&gt;List&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;4&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;5&lt;/span&gt; &lt;span class="p"&gt;};&lt;/span&gt;

        &lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;yb&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;x1&lt;/span&gt; &lt;span class="p"&gt;+&lt;/span&gt; &lt;span class="n"&gt;z3&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;  
        &lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;x12&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;ab&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;y2&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; 


        &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="p"&gt;&amp;lt;&lt;/span&gt; &lt;span class="n"&gt;yb&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;++)&lt;/span&gt;
        &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="nf"&gt;tb&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;x12&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  2. Avoid Comments Like the Plague
&lt;/h2&gt;

&lt;p&gt;Comments are for those who lack confidence in their code’s mystique. &lt;/p&gt;

&lt;p&gt;You wanna be dirty... and mysterious!&lt;/p&gt;

&lt;p&gt;If you insist on commenting, keep it ambiguous: something like &lt;/p&gt;

&lt;p&gt;//wtf &lt;br&gt;
or &lt;br&gt;
// ? &lt;/p&gt;

&lt;p&gt;Your code should be dirty!&lt;/p&gt;

&lt;p&gt;Bonus Tip: If you absolutely must add comments, make sure they’re misleading or redundant, like // fetch data here in a line where no data is fetched. You know, like the stuff you get back from LLM's.&lt;/p&gt;
&lt;h2&gt;
  
  
  3. Embrace the One-Million-Line Method
&lt;/h2&gt;

&lt;p&gt;Who needs small, readable functions? One method should handle everything: data fetching, processing, updating the UI, and maybe even making coffee. If a function is under 500 lines, it’s practically under 500 lines. &lt;br&gt;
Functions are like money a higher number is better!&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;ult&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
    &lt;span class="n"&gt;u&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;gtdb&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;  &lt;span class="c1"&gt;# "u" for usrp
&lt;/span&gt;
    &lt;span class="n"&gt;s&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;sorted&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;u&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;key&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="k"&gt;lambda&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;n&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;  
    &lt;span class="nf"&gt;svdb&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  &lt;span class="c1"&gt;# Save sorted stuff
&lt;/span&gt;    &lt;span class="nf"&gt;ui&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  &lt;span class="c1"&gt;# Update 
&lt;/span&gt;    &lt;span class="nf"&gt;eml&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;u&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  &lt;span class="c1"&gt;# Send emails to u &amp;lt;3
&lt;/span&gt;
    &lt;span class="n"&gt;t&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;
    &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;x&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;t&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="nf"&gt;scr&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;x&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  &lt;span class="c1"&gt;# Totally obvious!
&lt;/span&gt;
    &lt;span class="nf"&gt;sui&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; 

    &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;datetime&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;datetime&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;datetime&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;now&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="n"&gt;hour&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="mi"&gt;23&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="nf"&gt;nlm&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;  &lt;span class="c1"&gt;# Yes
&lt;/span&gt;&lt;span class="n"&gt;this&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="nf"&gt;l&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;u&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;s&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;t&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;  &lt;span class="c1"&gt;# Log 
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  4. Forget Reusability
&lt;/h2&gt;

&lt;p&gt;Reusability is for quitters. Copy that chunk of code everywhere it’s needed and tweak each one slightly, making future bug fixing an exercise in patience and detective work. Refactoring? That’s just a waste of time.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Pro Tip:&lt;/strong&gt; Reinventing the wheel each time you code something slightly different builds character and job security.&lt;/p&gt;

&lt;h2&gt;
  
  
  5. The Magic Number Mystery
&lt;/h2&gt;

&lt;p&gt;Constants are for the weak. &lt;/p&gt;

&lt;p&gt;You should Hard-code values everywhere.&lt;/p&gt;

&lt;h2&gt;
  
  
  6. Bug Fixing is for Amateurs
&lt;/h2&gt;

&lt;p&gt;If something doesn’t work, it’s probably user error. Don’t waste time "fixing" bugs. Leave them there to be discovered later when they’re much harder to diagnose. The trick is to bury them so deep, not even Sherlock Holmes could track them down.&lt;/p&gt;

&lt;p&gt;Bonus: If someone insists on a bug fix, sprinkle a few try-catch blocks around that silently ignore exceptions.&lt;/p&gt;

&lt;h2&gt;
  
  
  7. Tests are Overrated
&lt;/h2&gt;

&lt;p&gt;Testing code is for people who don’t trust their own genius. Who has time to check if things work? Why even ask this question? It works on you computer right?&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Pro Tip:&lt;/strong&gt; If anyone dares mention unit tests, nod, smile.&lt;/p&gt;

</description>
      <category>programming</category>
      <category>productivity</category>
      <category>learning</category>
    </item>
    <item>
      <title>THE M.O.I.S.T Principle</title>
      <dc:creator>Andreas Barbesgaard</dc:creator>
      <pubDate>Thu, 24 Oct 2024 07:59:13 +0000</pubDate>
      <link>https://forem.com/sprutnums/the-moist-principle-56b5</link>
      <guid>https://forem.com/sprutnums/the-moist-principle-56b5</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;TLDR&lt;br&gt;
The MOIST principles provide a balanced approach to writing code that prioritizes clarity, maintainability, and readability. While the DRY principle focuses on minimizing repetition, MOIST acknowledges the practical need for some redundancy to achieve these goals.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Before you dive into this incredible article, a quick word from our  sponsor: RAID: Shadow Legends! Yes, that game you've definitely heard about. Immerse yourself in its thrilling graphics and captivating gameplay. And, of course, don’t forget to use the code '/s' for absolutely no reward. &lt;/p&gt;

&lt;h2&gt;
  
  
  Meaningful
&lt;/h2&gt;

&lt;p&gt;Ensure that the code has purpose and context, even if it means some repetition to enhance clarity.&lt;/p&gt;

&lt;h2&gt;
  
  
  Organized
&lt;/h2&gt;

&lt;p&gt;Keep the code well-structured and easy to navigate, which might involve some necessary redundancy.&lt;/p&gt;

&lt;h2&gt;
  
  
  Intentional
&lt;/h2&gt;

&lt;p&gt;Be deliberate with repetitions, understanding when they serve a functional or communicative purpose.&lt;/p&gt;

&lt;h2&gt;
  
  
  Simplified
&lt;/h2&gt;

&lt;p&gt;Advocating for simplicity and clarity in code design and implementation.&lt;/p&gt;

&lt;h2&gt;
  
  
  Transparent
&lt;/h2&gt;

&lt;p&gt;Make the code’s intentions clear, even if this means duplicating logic to make it more understandable.&lt;/p&gt;

&lt;h1&gt;
  
  
  Meaningful
&lt;/h1&gt;

&lt;p&gt;Ensure that the code serves a clear purpose and is provided with context, while avoiding unnecessary repetition that could obscure its intent.&lt;br&gt;
Meaningful code is characterized by well-chosen names for variables, functions, and classes, promoting readability and aiding other developers in understanding its purpose.&lt;/p&gt;

&lt;p&gt;Following Robert Martin’s Clean Code philosophy, emphasis is placed on self-explanatory code, enhancing clarity and purposefulness. By keeping related behavior localized, the code becomes easier to understand without requiring developers to jump across the codebase.&lt;/p&gt;

&lt;p&gt;// Example of meaningful code with clear purpose and context&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Rectangle&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
 &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;double&lt;/span&gt; &lt;span class="n"&gt;Length&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;get&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
 &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;double&lt;/span&gt; &lt;span class="n"&gt;Width&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;get&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="nf"&gt;Rectangle&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;double&lt;/span&gt; &lt;span class="n"&gt;length&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;double&lt;/span&gt; &lt;span class="n"&gt;width&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
 &lt;span class="p"&gt;{&lt;/span&gt;
 &lt;span class="n"&gt;Length&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;length&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
 &lt;span class="n"&gt;Width&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;width&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
 &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;double&lt;/span&gt; &lt;span class="nf"&gt;CalculateArea&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
 &lt;span class="p"&gt;{&lt;/span&gt;
 &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;Length&lt;/span&gt; &lt;span class="p"&gt;*&lt;/span&gt; &lt;span class="n"&gt;Width&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
 &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  Organized
&lt;/h1&gt;

&lt;p&gt;Maintain a well-structured codebase that is easy to navigate, minimizing redundancy where possible.&lt;/p&gt;

&lt;p&gt;Organized code follows a logical structure with distinct separations of concerns, reducing the need for duplicated setup or initialization code across different modules.&lt;/p&gt;

&lt;p&gt;Martin Fowler’s iterative approach suggests refining the code’s structure over time, starting with initial organization that may include redundancy, which is then fine-tuned during refactoring.&lt;/p&gt;

&lt;p&gt;By keeping related functions and data close together, the code becomes more understandable and easier to reason about.&lt;br&gt;
// Example of organized code with a clear structure&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Rectangle&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
 &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;double&lt;/span&gt; &lt;span class="n"&gt;Length&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;get&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
 &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;double&lt;/span&gt; &lt;span class="n"&gt;Width&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="k"&gt;get&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="nf"&gt;Rectangle&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;double&lt;/span&gt; &lt;span class="n"&gt;length&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;double&lt;/span&gt; &lt;span class="n"&gt;width&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
 &lt;span class="p"&gt;{&lt;/span&gt;
 &lt;span class="n"&gt;Length&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;length&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
 &lt;span class="n"&gt;Width&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;width&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
 &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;double&lt;/span&gt; &lt;span class="nf"&gt;CalculateArea&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
 &lt;span class="p"&gt;{&lt;/span&gt;
 &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;Length&lt;/span&gt; &lt;span class="p"&gt;*&lt;/span&gt; &lt;span class="n"&gt;Width&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
 &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  Intentional
&lt;/h1&gt;

&lt;p&gt;Be deliberate in the use of repetitions, understanding when they serve a functional or communicative purpose.&lt;/p&gt;

&lt;p&gt;Intentional repetition ensures that redundant code is included for a reason, such as enhancing readability or aiding future maintainers in understanding the code.&lt;/p&gt;

&lt;p&gt;While Clean Code advises against unnecessary repetition, it also emphasizes that readability should not be sacrificed solely to avoid redundancy. Intentional repetition aligns with this nuanced approach, allowing for initial clarity before refactoring to eliminate unnecessary duplications while preserving intent.&lt;/p&gt;

&lt;p&gt;By keeping related logic together, intentional repetition makes behavior more localized and easier to follow.&lt;br&gt;
// Example of intentional repetition for clarity&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Greeting&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
 &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;Greet&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
 &lt;span class="p"&gt;{&lt;/span&gt;
 &lt;span class="n"&gt;Console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;WriteLine&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;$"Hello, &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s"&gt;!"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
 &lt;span class="n"&gt;Console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;WriteLine&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;$"Welcome to our website, &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;name&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s"&gt;!"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
 &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  Simplified
&lt;/h1&gt;

&lt;p&gt;Maintain simplicity in the code structure, even if it occasionally results in redundant segments to enhance clarity and ease of maintenance.&lt;/p&gt;

&lt;p&gt;Simplified code prioritizes readability by reducing complexity and avoiding unnecessary abstractions.&lt;/p&gt;

&lt;p&gt;Robert Martin advocates for simplicity as a core principle of Clean Code, encouraging straightforward and understandable solutions.&lt;/p&gt;

&lt;p&gt;By minimizing cognitive overhead for developers, simplified code supports maintainability, making it easier to debug, refactor, and extend. Starting with straightforward implementations and refining them over time fosters a better understanding of the system’s behavior and facilitates collaboration among developers.&lt;br&gt;
// Example of simplified code with reduced complexity&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;PrimeChecker&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
 &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;bool&lt;/span&gt; &lt;span class="nf"&gt;IsPrime&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
 &lt;span class="p"&gt;{&lt;/span&gt;
 &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="p"&gt;&amp;amp;&lt;/span&gt;&lt;span class="n"&gt;lt&lt;/span&gt;&lt;span class="p"&gt;;=&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
 &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;false&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="m"&gt;2&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="p"&gt;&amp;amp;&lt;/span&gt;&lt;span class="n"&gt;lt&lt;/span&gt;&lt;span class="p"&gt;;=&lt;/span&gt; &lt;span class="n"&gt;Math&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Sqrt&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;++)&lt;/span&gt;
 &lt;span class="p"&gt;{&lt;/span&gt;
 &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;n&lt;/span&gt; &lt;span class="p"&gt;%&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="p"&gt;==&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
 &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;false&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
 &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="k"&gt;true&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
 &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  Transparrent
&lt;/h1&gt;

&lt;p&gt;Ensure clarity in the code structure and logic, even if it requires duplicating certain aspects to enhance understandability and ease of maintenance.&lt;/p&gt;

&lt;p&gt;Transparent code makes its purpose and behavior explicit, prioritizing understandability for anyone reading it. By reducing cognitive load, transparent code makes it easier to comprehend, debug, and modify.&lt;br&gt;
Supporting the principle of locality of behavior, transparent code keeps related logic together and ensures the purpose of each code segment is evident.&lt;/p&gt;

&lt;p&gt;By aligning with principles such as self-documenting code and expressive programming, transparent codebases are easier to maintain, understand, and extend over time.&lt;br&gt;
// Example of transparent code with clear logic and purpose&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;PriceCalculator&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
 &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;double&lt;/span&gt; &lt;span class="nf"&gt;CalculateTotalPrice&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;double&lt;/span&gt;&lt;span class="p"&gt;[]&lt;/span&gt; &lt;span class="n"&gt;prices&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt;&lt;span class="p"&gt;[]&lt;/span&gt; &lt;span class="n"&gt;quantities&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
 &lt;span class="p"&gt;{&lt;/span&gt;
 &lt;span class="kt"&gt;double&lt;/span&gt; &lt;span class="n"&gt;total&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
 &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="p"&gt;&amp;amp;&lt;/span&gt;&lt;span class="n"&gt;lt&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;prices&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Length&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;++)&lt;/span&gt;
 &lt;span class="p"&gt;{&lt;/span&gt;
 &lt;span class="n"&gt;total&lt;/span&gt; &lt;span class="p"&gt;+=&lt;/span&gt; &lt;span class="n"&gt;prices&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="p"&gt;*&lt;/span&gt; &lt;span class="n"&gt;quantities&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;];&lt;/span&gt;
 &lt;span class="p"&gt;}&lt;/span&gt;
 &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;total&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
 &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h1&gt;
  
  
  Conclusion
&lt;/h1&gt;

&lt;p&gt;Following the MOIST principles provides a balanced approach to writing code that prioritizes clarity, maintainability, and readability. While acknowledging the need for some redundancy, MOIST ensures that clarity and intentionality are maintained throughout the codebase. By adhering to MOIST principles, developers can create code that is both clear and maintainable, promoting collaboration and reducing the risk of errors.&lt;/p&gt;

&lt;p&gt;/s&lt;/p&gt;

&lt;h2&gt;
  
  
  Sources
&lt;/h2&gt;

&lt;p&gt;Clean code &lt;/p&gt;

&lt;p&gt;martin Flowers book on refactoring&lt;/p&gt;

&lt;p&gt;Locality of Behaviour&lt;/p&gt;

</description>
      <category>principles</category>
      <category>code</category>
      <category>dry</category>
      <category>programming</category>
    </item>
    <item>
      <title>Mine 14 dage med Cursor</title>
      <dc:creator>Andreas Barbesgaard</dc:creator>
      <pubDate>Thu, 24 Oct 2024 04:40:36 +0000</pubDate>
      <link>https://forem.com/sprutnums/mine-14-dage-med-cursor-1oh3</link>
      <guid>https://forem.com/sprutnums/mine-14-dage-med-cursor-1oh3</guid>
      <description>&lt;h2&gt;
  
  
  Introduktion
&lt;/h2&gt;

&lt;p&gt;Disclaimer! Jeg er i gang med datamatikeruddannelsen og er ikke endnu uddannet.&lt;/p&gt;

&lt;p&gt;Da jeg så, at Cursor IDE var det nyeste og mest hypede værktøj, besluttede jeg mig for at prøve det. Cursor præsenterer sig som en IDE med en fuldt integreret LLM, der skal gøre kodning hurtigere og smartere — i hvert fald ifølge deres løfter.&lt;/p&gt;

&lt;p&gt;Mit mål med at afprøve cursor var at finde ud af hvad der gør denne IDE så interessant i forhold til fx VS Code med Copilot plugin.&lt;br&gt;
Kort oprids af funktioner&lt;/p&gt;

&lt;h2&gt;
  
  
  Kode generering
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxfiio9dtdfras2xgavut.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxfiio9dtdfras2xgavut.png" alt="Kode generering" width="800" height="458"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;For mig minder dette om det man kan finde allerede hos Copliot. En slags intellisense på steoider.&lt;/p&gt;

&lt;h2&gt;
  
  
  Multi-line Ændringer
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flho78tcamzpcfogrc925.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flho78tcamzpcfogrc925.png" alt="Multiline ændringer" width="800" height="353"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Denne funktion har jeg ikke benyttet mig. Men der er da smart.&lt;/p&gt;

&lt;h2&gt;
  
  
  Smart Rewrites
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmv1wcbzbyv9imxff3xzd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmv1wcbzbyv9imxff3xzd.png" alt="Smart Rewrites" width="800" height="375"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Som en nybegynder er dette som sendt fra gud(eller Ai overlords), at se den rigtige syntax komme frem for øjnene af én er igen — smart.&lt;/p&gt;

&lt;h2&gt;
  
  
  CTRL+k
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flmfwrdeuov4n5x0bgm5r.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flmfwrdeuov4n5x0bgm5r.png" alt="CTRL+k" width="800" height="465"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Min mest brugte funktion var CTRL+k&lt;/p&gt;

&lt;p&gt;Denne gjorde det muligt for min nye Ai-ven at hurtigt redigere en markeret kode og rette den til med en prompt man smider ind lige over den kode man ønsker ændret — og så flyver robotten ellers ned gennem koden og ændrer alt det kode man ellers var så stolt af at have kommet frem til.&lt;/p&gt;

&lt;h2&gt;
  
  
  Stakkels Tab
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fihv5yfhs1an7s8shfxjh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fihv5yfhs1an7s8shfxjh.png" alt="Stakkels Tab" width="800" height="600"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Min erfaring med Cursor
&lt;/h2&gt;

&lt;p&gt;Når jeg arbejdede med Cursor, opdagede jeg, at det ikke handlede så meget om at skrive kode, men snarere om at læse den. Cursor præsenterer dig konstant for forslag og genereret kode, hvilket betyder, at min Tab-tast blev den mest brugte knap på mit tastatur.&lt;/p&gt;

&lt;p&gt;Men her er problemet: Når jeg bruger mere tid på at læse kode i stedet for at skrive den, mister jeg noget af mit fokus. Det er let at blive fanget i at godkende forslag uden nødvendigvis at forstå alle detaljerne.&lt;/p&gt;

&lt;p&gt;Når det er sagt, så er Cursor imponerende hurtigt til at tage dine idéer og omsætte dem til kode. Der er ikke langt fra tanke til udførsel — men det kræver, at du allerede har en god forståelse for kodningens grundprincipper. Hvis du er rutineret og har et solidt greb om best practices, kan Cursor være et fantastisk værktøj.&lt;/p&gt;

&lt;p&gt;For en som mig, der stadig er under uddannelse og ikke har mange års erfaring med programmering, kan Cursor dog være overvældende. De mange funktioner og automatiske rettelser gør det svært at følge med i, hvad der præcist sker i koden. I stedet for at lære ved at skrive, ender man med at lære ved at læse — hvilket kan føles som en hæmsko, når man stadig er i gang med at lære det grundlæggende.&lt;br&gt;
Opsummering&lt;/p&gt;

&lt;p&gt;Cursor er uden tvivl et kraftfuldt værktøj, især hvis du allerede er en erfaren udvikler. Den korter afstanden mellem idé og udførelse, og den integrerede LLM kan spare tid ved at generere kode og rette fejl. Men hvis du, som jeg, stadig er under uddannelse eller er ny inden for programmering, kan Cursor give mere hjælp, end du egentlig har brug for. Det kan få dig til at miste overblikket og fokusere for meget på maskinens forslag frem for din egen læring.&lt;/p&gt;

&lt;p&gt;Mit råd til andre studerende ville være at bruge Cursor med omtanke — og kun når du er klar til at forstå de forslag, du bliver præsenteret for.&lt;/p&gt;

</description>
      <category>cursor</category>
      <category>ide</category>
      <category>ai</category>
    </item>
    <item>
      <title>7 Principper for Microservices</title>
      <dc:creator>Andreas Barbesgaard</dc:creator>
      <pubDate>Thu, 24 Oct 2024 04:29:33 +0000</pubDate>
      <link>https://forem.com/sprutnums/7-principper-for-microservices-ca6</link>
      <guid>https://forem.com/sprutnums/7-principper-for-microservices-ca6</guid>
      <description>&lt;p&gt;&lt;a href="https://samnewman.io/" rel="noopener noreferrer"&gt;Sam Newman&lt;/a&gt;’s principper for &lt;strong&gt;microservices&lt;/strong&gt; fokuserer på at skabe en arkitektur, der er fleksibel, skalerbar og robust. Hans tilgang tager udgangspunkt i en række principper, som hjælper med at sikre, at systemer kan tilpasses forretningsbehov og udvikles på en effektiv måde.&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Modelleret ud fra &lt;code&gt;business domain&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Microservices&lt;/strong&gt; bør organiseres omkring forretningsdomæner snarere end tekniske krav. Ved at modellere services omkring forretningskapaciteter, kan teams fokusere på specifikke domæner som kunde-, ordre- eller produktstyring.&lt;/p&gt;

&lt;p&gt;Systemet bliver mere fleksibelt og let at vedligeholde, fordi hvert domæne kan udvikles og ændres uafhængigt. Denne tilgang fremmer også &lt;em&gt;domain-driven design&lt;/em&gt; (DDD), som hjælper med at sikre, at teknologien understøtter forretningsmålene direkte.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. En automatiseringskultur
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Automatisering&lt;/strong&gt; er afgørende i en &lt;strong&gt;microservices&lt;/strong&gt;-arkitektur, især når det kommer til test, deployment og overvågning. En stærk CI/CD-pipeline (Continuous Integration/Continuous Deployment) gør det muligt at implementere ændringer hurtigt og pålideligt.&lt;/p&gt;

&lt;p&gt;Risikoen for menneskelige fejl bliver reduceret og sikrer, at nye versioner af en service kan distribueres hyppigt. &lt;em&gt;Automatiseringen&lt;/em&gt; skal også inkludere overvågning, fejlhåndtering og skalering, så tjenester kan reagere automatisk på ændringer i belastningen eller fejl.&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Gem implementeringsdetaljerne
&lt;/h2&gt;

&lt;p&gt;Hver &lt;strong&gt;microservice&lt;/strong&gt; skal være isoleret, hvilket betyder, at de skjuler deres interne implementeringsdetaljer fra resten af systemet. Dette koncept kaldes også &lt;em&gt;encapsulation&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;Andre &lt;strong&gt;services&lt;/strong&gt; bør kun interagere med en given service gennem veldefinerede API’er. Ved at skjule implementeringen kan den interne logik ændres eller optimeres uden at påvirke andre dele af systemet.&lt;/p&gt;

&lt;p&gt;Det giver fleksibilitet i forhold til teknologi, da forskellige services kan bruge forskellige programmeringssprog, databaser eller andre teknologier, uden at det påvirker hele systemet.&lt;/p&gt;

&lt;h2&gt;
  
  
  4. Decentralisér alt
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Decentralisering&lt;/strong&gt; er kernen i &lt;strong&gt;microservices&lt;/strong&gt;-arkitekturen. I stedet for en centraliseret database eller governance, har hver &lt;strong&gt;service&lt;/strong&gt; kontrol over sine egne data og sin egen teknologi.&lt;/p&gt;

&lt;p&gt;Beslutninger træffes lokalt, hvilket øger fleksibiliteten og gør det muligt at vælge den bedste løsning for hver enkelt service. Samtidig kan forskellige teams arbejde selvstændigt, hvilket reducerer behovet for koordination og forbedrer udviklingshastigheden.&lt;/p&gt;

&lt;h2&gt;
  
  
  5. Deploy enkeltvis
&lt;/h2&gt;

&lt;p&gt;En af de største fordele ved &lt;strong&gt;microservices&lt;/strong&gt; er muligheden for at implementere hver service separat. Når en enkelt service skal opdateres eller skaleres, kan dette gøres uden at påvirke andre services i systemet.&lt;/p&gt;

&lt;p&gt;Denne uafhængighed muliggør hurtigere implementeringscyklusser, færre fejl ved deployment, og en generel højere grad af fleksibilitet. Det kræver dog, at infrastrukturen understøtter denne form for selvstændig implementering gennem automatiserede deployments, test og overvågning.&lt;/p&gt;

&lt;h2&gt;
  
  
  6. Isolér fejl
&lt;/h2&gt;

&lt;p&gt;Fejlisolering er et afgørende aspekt af en &lt;strong&gt;microservices&lt;/strong&gt;-arkitektur. Ved at sikre, at fejl i en &lt;strong&gt;service&lt;/strong&gt; ikke spreder sig til andre dele af systemet, forbedres systemets robusthed.&lt;/p&gt;

&lt;p&gt;Teknologier som &lt;em&gt;circuit breakers&lt;/em&gt; og &lt;em&gt;retries&lt;/em&gt; kan bruges til at beskytte mod kaskadefejl. Hvis en service fejler, bør systemet stadig kunne fungere delvist, måske med reduceret funktionalitet.&lt;/p&gt;

&lt;h2&gt;
  
  
  7. Observér alt
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Microservices&lt;/strong&gt;-arkitekturer kan være komplekse, og derfor er omfattende overvågning afgørende. Dette indebærer at have synlighed i hver enkelt &lt;strong&gt;service&lt;/strong&gt;, inklusive dens ydeevne, fejl, afhængigheder og brugerinteraktioner. Ved at observere alt kan teams hurtigt opdage problemer og reagere proaktivt.&lt;br&gt;
&lt;iframe width="710" height="399" src="https://www.youtube.com/embed/PFQnNFe27kU?start=2610"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

</description>
      <category>microservices</category>
    </item>
    <item>
      <title>Jeg forstår det simpelthen ikke</title>
      <dc:creator>Andreas Barbesgaard</dc:creator>
      <pubDate>Wed, 23 Oct 2024 12:11:25 +0000</pubDate>
      <link>https://forem.com/sprutnums/jeg-forstar-det-simpelthen-ikke-1850</link>
      <guid>https://forem.com/sprutnums/jeg-forstar-det-simpelthen-ikke-1850</guid>
      <description>&lt;p&gt;Op til eksamen på 1. år af datamatikeruddannelsen havde jeg tankerne kørende rundt i mit hoved, fordi jeg ikke havde nogen idé om, hvad der foregik i min kode, når jeg trykkede på start. Jeg vidste, at når jeg trykkede på knappen, så kørte programmet, og på magisk vis kunne min computer forstå den kode, jeg havde skrevet, og variablerne, jeg havde erklæret, samt ændre dem løbende. Men hvordan?&lt;/p&gt;

&lt;p&gt;Jeg havde brug for et program eller en løsning, der gjorde, at jeg kunne se den kode, jeg havde skrevet, aktiveret, når jeg interagerede med de forskellige elementer i mit system. Det var ikke nok for min forståelse at se bilen køre; jeg ville se, hvordan motoren så ud, når den startede, når jeg trykkede på bremsen, og når jeg accelererede.&lt;/p&gt;

&lt;p&gt;Jeg søgte på nettet efter en løsning og fandt ud af, at C# har en umiddelbart god løsning til dette formål:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Debug.WriteLine(); 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Jeg brugte denne metode flittigt i min kode.&lt;/p&gt;

&lt;p&gt;Når jeg startede en metode op så skrev jeg&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="n"&gt;Debug&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;WriteLine&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"MethodName"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Det fungerede fint. Men strukturen i de beskeder, jeg modtog, var ofte meget simpel og kunne se således ud:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Metode1 start
variable1 = 1
Metode1 Slut
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Og hvis du forestiller dig en ordentlig røvfuld metoder der sparker i gang, blev dette ikke lettere at læse.&lt;br&gt;
Jeg manglede struktur i mit kodes debug-output. Derfor valgte jeg, lige inden eksamen, hurtigt at sammensætte et bibliotek, der senere kom til at hedde &lt;strong&gt;Debugland&lt;/strong&gt; (mere om det senere).&lt;br&gt;
Dette gjordre at min debug log kom til at se sådan ud:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[Metode1]
  - Initiated
  - The Variable Sovs has been declared with a value of Hollandaise
[/Metode1]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;… og ved flere metoder, så koden sådan ud:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[Metode1]
  - Initiated
  - The Variable Sovs has been declared with a value of Hollandaise
  [Metode2]
    - Initiated
    - The Variable tilbehør has been declared with a value of fritter
  [/Metode2]
[/Metode1]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Denne struktur fungerede super godt for min forståelse af, hvad der skete, når jeg interagerede med mit system. Jeg fik svar på de spørgsmål, jeg havde til min kode, om hvad der præcist skete, når forskellige processer blev aktiveret under "kølerhjelmen" af systemet.&lt;br&gt;
Det eneste problem ved implementeringen af Debugland i ens kode er, at det kan fylde ret meget. Når det er sagt, har det været guld værd for min forståelse af, hvad der sker under runtime.&lt;/p&gt;
&lt;h2&gt;
  
  
  Debugland
&lt;/h2&gt;

&lt;p&gt;Som jeg lovede tidligere er her en lille præsentation af det bibliotek jeg lavede.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmexksxc2la1pt6z8dnwc.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fmexksxc2la1pt6z8dnwc.png" alt="Image description" width="800" height="231"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Udfordring
&lt;/h2&gt;

&lt;p&gt;Jeg manglede en stuktur i den måde jeg fik vist de beskeder som jeg fik tilbage fra systemet når jeg kørte programmet.&lt;/p&gt;
&lt;h2&gt;
  
  
  Løsning
&lt;/h2&gt;

&lt;p&gt;Lav en "wrapper" til C#'s Debug, som omslutter sprogets output i en mere struktureret form.&lt;/p&gt;
&lt;h2&gt;
  
  
  Kode kode kode
&lt;/h2&gt;

&lt;p&gt;Det hele starter med &lt;strong&gt;MethodInitiated&lt;/strong&gt; metoden fra biblioteket&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;   &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nf"&gt;Conditional&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"DEBUG"&lt;/span&gt;&lt;span class="p"&gt;)]&lt;/span&gt;
   &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;static&lt;/span&gt; &lt;span class="k"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;MethodInitiated&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="n"&gt;methodName&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
   &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="c1"&gt;// Store the initial Debug.IndentLevel&lt;/span&gt;
        &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;initialIndentLevel&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;Debug&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;IndentLevel&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

        &lt;span class="c1"&gt;// Writes the name of the method to the debug window for the initial level&lt;/span&gt;
        &lt;span class="n"&gt;Debug&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;WriteLine&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;$"[&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;methodName&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s"&gt;]"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

        &lt;span class="c1"&gt;// Enter the loop starting from 1 to initialIndentLevel (including 0)&lt;/span&gt;
        &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt; &lt;span class="p"&gt;&amp;lt;=&lt;/span&gt; &lt;span class="n"&gt;initialIndentLevel&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;++)&lt;/span&gt;
        &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="c1"&gt;// Adjusts the Debug.IndentLevel for each iteration&lt;/span&gt;
            &lt;span class="n"&gt;Debug&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;IndentLevel&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;i&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;

        &lt;span class="c1"&gt;// After the loop, reset Debug.IndentLevel to the initial value&lt;/span&gt;
        &lt;span class="n"&gt;Debug&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;IndentLevel&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;initialIndentLevel&lt;/span&gt; &lt;span class="p"&gt;+&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="n"&gt;Debug&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;WriteLine&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;$"&lt;/span&gt;&lt;span class="p"&gt;{(&lt;/span&gt;&lt;span class="kt"&gt;char&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;&lt;span class="m"&gt;26&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s"&gt; initiated"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
   &lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Denne sætter indenteringen for resten af koden og skriver at metoden, som man gerne vil vide mere om, er "initiated". &lt;br&gt;
Det er dog vigtigt her at man altid for afsluttet med &lt;strong&gt;MethodTerminated&lt;/strong&gt; metoden, da indenteringen ikke vil forløbe korrekt.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nf"&gt;Conditional&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"DEBUG"&lt;/span&gt;&lt;span class="p"&gt;)]&lt;/span&gt;
 &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;static&lt;/span&gt; &lt;span class="k"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;MethodTerminated&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="n"&gt;methodName&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
 &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="c1"&gt;// Gets the initial IndentLevel&lt;/span&gt;
        &lt;span class="n"&gt;Debug&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;IndentLevel&lt;/span&gt; &lt;span class="p"&gt;+=&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="c1"&gt;// unindents&lt;/span&gt;
        &lt;span class="n"&gt;Debug&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Unindent&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
        &lt;span class="c1"&gt;// Writes the name of the method to the debug window.&lt;/span&gt;
        &lt;span class="n"&gt;Debug&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;WriteLine&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;$"[/&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;methodName&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s"&gt;]\n"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Og for mig var dette hele hulmen for at kunne få fornemmelsen af hvilken metode der aktiverede i en anden metode, som ændrede en variabel der gjorde gud ved hvad. &lt;/p&gt;

&lt;p&gt;En Implementering af dette kunne for eksempel se sådan ud:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;Metode1&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;number&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="n"&gt;Debugger&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;MethodInitiated&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;nameof&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Metode1&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
  &lt;span class="n"&gt;Debugger&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;MethodParameter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;$"&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;number&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;a&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="n"&gt;Debugger&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Variable&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"a"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="s"&gt;$"&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;a&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

  &lt;span class="n"&gt;Debugger&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;MethodTerminated&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;nameof&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Metode1&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt; 
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Rigtig mange linjer skal til for at man får fornemmelsen af hvad der sker. Men dette gav mig syn for sagen og jeg bruger ikke nær så mangler linjer mere.&lt;/p&gt;

&lt;p&gt;Dette vil give følgende output, hvis vi siger at metoden aktiveres på følgende måde Metode1(1)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[Metode1]
  - Initiated
  - Parameter value was: 1
  - The Variable a declared with the value of 1
[/Metode1]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Dette har været et uundværlig redskab for mig i arbejdet med forståelsen af hvad der sker når kode aktiveres&lt;/p&gt;

&lt;h2&gt;
  
  
  Nyt i Debugland
&lt;/h2&gt;

&lt;p&gt;I den nyeste implementering er jeg gået til hvordan man får præsentereret fejl i C#. For mig er det nærmest latin.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Error reading the file. ---&amp;gt; System.IO.FileNotFoundException: Could not find file 'nonexistentfile.txt'.
   at System.IO.FileSystem.OpenFile(String path, FileMode mode, FileAccess access, FileShare share)
   at System.IO.File.ReadAllText(String path)
   at Program.Main(String[] args) in C:\path\to\your\file.cs:line 10
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;… altså, hvis jeg kigger efter kan jeg da godt forså det. Men det er jo det. Jeg skal se efter. Jeg vil bare gerne have en lyn hurtig besked om hvad fejlen er, hvor den er og hvordan den eventuelt kan løses.&lt;br&gt;
Jeg er kommet frem til følgende struktur:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;1 |   Exception Occurred in ---&amp;gt; [TestExceptionMethod]
2 |   Time Stamp: 10/21/2024 8:51:16 AM
3 |   
4 |   Message: Test exception occurred
5 |   Source: TestProject
6 |   Target Site: Void LogException_Should_Format_Exception_Details_Correctly()
9 |   Inner Exception:
- |   Message: Inner exception occurred
- |   Source: 
- |   Target Site: 
14|   Method: at TestProject.DebuggerTests.LogException_Should_Format_Exception_Details_Correctly()
15|   File Path: /home/andreas/Documents/Projects/Debugland/TestProject/DebuggerTests.cs
16|   Line Number: 45
17|      throw new Exception(exceptionMessage, new Exception(innerExceptionMessage));
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Dette er work in progress og er ikke langt op i repo endnu.&lt;/p&gt;




&lt;p&gt;Mit arbejde med Debugland har været en rejse mod bedre forståelse af, hvad der sker under overfladen, når kode udføres. Ved at implementere en struktureret tilgang til debug-output har jeg ikke blot opnået indsigt i mine metoder og variabler, men også fået mere tillid til min evne til at identificere og rette fejl.&lt;br&gt;
I takt med at jeg udvikler Debugland videre, håber jeg at kunne dele dette værktøj med andre, der står over for lignende udfordringer. En klar og struktureret måde at se, hvad der sker i koden, kan være afgørende for læring og fejlfinding, især for dem, der er tidligt i deres programmeringsrejse.&lt;/p&gt;

&lt;p&gt;Jeg ser frem til at fortsætte med at forbedre Debugland og gøre det til en endnu mere værdifuld ressource for både mig selv og mine medudviklere. Med dette værktøj kan jeg lettere navigere i kompleksiteten af programmering og få det fulde udbytte af mine kodeskrivningsfærdigheder.&lt;/p&gt;

&lt;p&gt;Tak fordi du læste med, og jeg håber, at mine erfaringer kan inspirere dig til at udforske og forbedre din egen tilgang til debugging og kodeforståelse.&lt;/p&gt;

&lt;p&gt;link til Debugland&lt;br&gt;
&lt;a href="https://abarbesgaard.github.io/Debugland/" rel="noopener noreferrer"&gt;https://abarbesgaard.github.io/Debugland/&lt;/a&gt;&lt;/p&gt;

</description>
      <category>csharp</category>
    </item>
  </channel>
</rss>
