<?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: Marcus Christensen</title>
    <description>The latest articles on DEV Community by Marcus Christensen (@munchyydl).</description>
    <link>https://dev.to/munchyydl</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%2F314706%2Fce6333c0-b924-46fc-b528-eeb3f7e6d80d.jpeg</url>
      <title>DEV Community: Marcus Christensen</title>
      <link>https://dev.to/munchyydl</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/munchyydl"/>
    <language>en</language>
    <item>
      <title>The state of a modern repo</title>
      <dc:creator>Marcus Christensen</dc:creator>
      <pubDate>Wed, 11 Aug 2021 14:01:03 +0000</pubDate>
      <link>https://dev.to/munchyydl/the-state-of-a-modern-repo-49lm</link>
      <guid>https://dev.to/munchyydl/the-state-of-a-modern-repo-49lm</guid>
      <description>&lt;h2&gt;
  
  
  Background
&lt;/h2&gt;

&lt;p&gt;During the years I have seen many tools and technologies both rise and fall, both good and bad attempts on solving different problems in and around development.&lt;/p&gt;

&lt;p&gt;In my early years source control wasn't even a thing, issues was tracked by pen and paper and a release was something that you as a developer created on your own machine. :P&lt;/p&gt;

&lt;p&gt;Much time has passed since then, and looking back at this, it's easy to see that we are in a much better place today, with modern tools and services like GitHub, that offers a complete package for what you need.&lt;/p&gt;

&lt;h2&gt;
  
  
  The problem
&lt;/h2&gt;

&lt;p&gt;With the advent of toolchains and build pipelines, among other things, we have had a need to save configuration for a lot of stuff along with the actual code in our repos.&lt;/p&gt;

&lt;p&gt;On the whole, I think this a good thing, as the possibility to discuss and change configuration, along with what tools to use is much more in the open nowadays.&lt;/p&gt;

&lt;p&gt;But, what I dislike is that the root of a repo is a free-for-all to save configuration files in.&lt;/p&gt;

&lt;p&gt;Just take a small peek into the &lt;a href="https://github.com/forem/forem"&gt;Forem repo&lt;/a&gt; for dev.to, to get a hint of what i mean.&lt;/p&gt;

&lt;p&gt;Along with the few folders of actual code, there are countless of files and folders needed for the different tools used for testing / building / deploying.&lt;/p&gt;

&lt;h3&gt;
  
  
  Disclaimer
&lt;/h3&gt;

&lt;p&gt;Take note! There is no blame sent in the direction of the &lt;br&gt;
Forem team, this problem is visible in almost all repos, in some sort or the other.&lt;/p&gt;

&lt;h2&gt;
  
  
  Question
&lt;/h2&gt;

&lt;p&gt;What if I happen to be a new coder, eager to test out opensource development for a project i really like?&lt;/p&gt;

&lt;p&gt;In my line of work as a professional developer, I often come back to the fact that we manage complexity, and try to present it a something simple.&lt;/p&gt;

&lt;p&gt;Not to hide the complexity away for everyone, but instead not to scare away the people that just want to get a grasp of what the system does, and be able to dive into the details when ready.&lt;/p&gt;

&lt;p&gt;I just feel that we could do better in some areas when it comes to all the configuration-files as well, can't we?&lt;/p&gt;

&lt;p&gt;Happy coding! :)&lt;/p&gt;

</description>
      <category>devops</category>
      <category>opensource</category>
      <category>architecture</category>
      <category>discuss</category>
    </item>
    <item>
      <title>Abstractions offers readability</title>
      <dc:creator>Marcus Christensen</dc:creator>
      <pubDate>Wed, 11 Aug 2021 13:35:47 +0000</pubDate>
      <link>https://dev.to/munchyydl/abstractions-offers-readability-22o4</link>
      <guid>https://dev.to/munchyydl/abstractions-offers-readability-22o4</guid>
      <description>&lt;h2&gt;
  
  
  The problem
&lt;/h2&gt;

&lt;p&gt;When you as an aspiring new programmer start your journey, there are a lot of things to learn, some of it is really easy to grasp while other things might be a bit tricker.&lt;/p&gt;

&lt;p&gt;One of those things are abstractions, which is a horrid word and it makes even me flinch sometimes, so I like to turn it around and look at it from a usage perspective.&lt;/p&gt;

&lt;h2&gt;
  
  
  Abstractions?
&lt;/h2&gt;

&lt;p&gt;Abstractions come in many forms, often it's used on a larger scale, like between parts of a large system.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--MdVuiKG5--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://computersciencewiki.org/images/thumb/e/e2/Abstract_heart.png/525px-Abstract_heart.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--MdVuiKG5--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://computersciencewiki.org/images/thumb/e/e2/Abstract_heart.png/525px-Abstract_heart.png" alt="Abstract-o-meter"&gt;&lt;/a&gt;&lt;br&gt;
&lt;a href="https://computersciencewiki.org/index.php/Abstraction"&gt;Abstraction&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So abstraction is used to let someone grasp the concept of something, without being exposed to the details, which is great, therefore I conclude:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Abstractions offers the reader readability.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h2&gt;
  
  
  Methods
&lt;/h2&gt;

&lt;p&gt;So today I'd like to talk to you about abstractions in the small, that is sorely underused in many codebases, more specifically: methods.&lt;/p&gt;

&lt;p&gt;We as programmers divide our programs into methods/functions to do certain things for us, we often do this based on possible reuse of logic.&lt;/p&gt;

&lt;p&gt;But we often miss the opportunity to also simplify the code for the readers, by breaking apart blocks of code further, even though it's not needed for reusability, only for readability &amp;amp; simplicity.&lt;/p&gt;

&lt;p&gt;So, (well-named) methods allows the reader of the code to grasp WHAT is happening instead of HOW that is done, and therefore offers simplicity in the form of hiding the details.&lt;/p&gt;
&lt;h2&gt;
  
  
  An example
&lt;/h2&gt;

&lt;p&gt;Say that you need to fix a formatting error in an email that is sent with a weekly report to your customers, as help in the ticket there is a mention of the SendReport() method.&lt;/p&gt;

&lt;p&gt;You search for the method, open the file and are faced with one 3500-line long method, that does everything...&lt;/p&gt;

&lt;p&gt;Due to the fact that multiple people has been involved in adding features and fixing hard-to-find bugs in this code the last couple of years, it's all intertwined.&lt;/p&gt;

&lt;p&gt;Were would you start looking?&lt;/p&gt;

&lt;p&gt;You really need to sit down and read all of the code to find what you are looking for, and to see how to change parts of it, hopefully without breaking something else, which has occurred multiple times in the past.&lt;/p&gt;

&lt;p&gt;If instead your SendReports() method looked like this, would you have an easier time finding what you're looking for?&lt;/p&gt;

&lt;p&gt;You didn't have to look at all the db-calls that needed to be done to calculate the report, neither the specifics of how the email was sent to the client.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;
&lt;span class="c1"&gt;/// Send weekly report to all customers&lt;/span&gt;
&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;SendReports&lt;/span&gt;&lt;span class="p"&gt;()&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="nx"&gt;every&lt;/span&gt; &lt;span class="nx"&gt;customer&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="nx"&gt;allCustomers&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;report&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;createReport&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;customer&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="nx"&gt;email&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;createEmail&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;customer&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;report&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="nx"&gt;sendEmail&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;email&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;p&gt;And then, even though your createEmail() function wasn't used from anywhere else in your system, it was further broken up into, let's say:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;
&lt;span class="c1"&gt;/// Creates a personalized email to the customer recipient,&lt;/span&gt;
&lt;span class="c1"&gt;/// and attaches the report.&lt;/span&gt;
&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;createEmail&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;customer&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;report&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
   &lt;span class="nx"&gt;email&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;Email&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
   &lt;span class="nx"&gt;email&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;headers&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;createEmailHeaders&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;customer&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
   &lt;span class="nx"&gt;email&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;body&lt;/span&gt;    &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;createEmailBody&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;customer&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
   &lt;span class="nx"&gt;email&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;attachments&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;report&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
   &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;email&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;It would be so much easier to find the relevant parts that you are interested in at the moment.&lt;/p&gt;

&lt;h2&gt;
  
  
  Oh no, this is my reality!
&lt;/h2&gt;

&lt;p&gt;If you find yourself looking at the above example and thinking about the countless of similar files in your own codebase, I feel sorry for you, but I can also tell you that you are far from alone.&lt;/p&gt;

&lt;p&gt;Many of us are working in older systems, which tend to have some amount of code like this.&lt;/p&gt;

&lt;h2&gt;
  
  
  How to fix it?
&lt;/h2&gt;

&lt;p&gt;If you don't know how to proceed, a good rule of thumb is to try to leave the code in a slightly better state than you found it it.&lt;/p&gt;

&lt;p&gt;So, when faced with an issue, try to break out just a tiny portion of the code, if possible, when fixing the issue, to make it easier the next time around.&lt;/p&gt;

&lt;p&gt;Tests do help a lot when doing this kind of work, but that is another topic for another day. :)&lt;/p&gt;

&lt;h2&gt;
  
  
  Where to stop?
&lt;/h2&gt;

&lt;p&gt;Well, it depends on your own decisions and what you find simple, but a good rule of thumb is that a function should do the least amount of work possible, and do it well.&lt;/p&gt;

&lt;p&gt;Think about the next person that needs to fix a bug in your codebase, keep it as simple as possible for them to find the correct place, it might as well be you!&lt;/p&gt;

&lt;p&gt;Happy coding! :)&lt;/p&gt;

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