<?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: Dillon Adams</title>
    <description>The latest articles on DEV Community by Dillon Adams (@dillonad).</description>
    <link>https://dev.to/dillonad</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%2F143255%2F0450b7dd-049e-4803-8ad1-93a869ca756f.jpeg</url>
      <title>DEV Community: Dillon Adams</title>
      <link>https://dev.to/dillonad</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/dillonad"/>
    <language>en</language>
    <item>
      <title>Unable to find Ruby class that definitely exists</title>
      <dc:creator>Dillon Adams</dc:creator>
      <pubDate>Sun, 12 Jan 2025 00:00:00 +0000</pubDate>
      <link>https://dev.to/dillonad/unable-to-find-ruby-class-that-definitely-exists-1g5i</link>
      <guid>https://dev.to/dillonad/unable-to-find-ruby-class-that-definitely-exists-1g5i</guid>
      <description>&lt;p&gt;Recently I have been learning Ruby on Rails! With that learning comes a lot of lessons, and this one was both fun and frustrating for me. While working in the Ruby on Rails project, I created a new class and RSpec tests for that class.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;/app/thing/thingy_doer.rb&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class Thing::ThingDoer
# ...
end

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;code&gt;/spec/thing/thing_doer_spec.rb&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;RSpec.describe Thing::ThingDoer do
# ...
end

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I ran the tests and got the following error:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;NameError:
  uninitialized constant Thing::ThingDoer

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Crazy right? I specified the class name in the test exactly as it is spelled in the class, but the RSpec tests can’t find the class. Why?!&lt;/p&gt;

&lt;p&gt;The issue is that Rails has a loading convention that matches the file name to the class name. Due to the mismatch between the name of the &lt;code&gt;thingy_doer.rb&lt;/code&gt; file and the &lt;code&gt;ThingDoer&lt;/code&gt; class, Rails can’t find the class.&lt;/p&gt;

&lt;p&gt;The solution is is correct the typo in the file name. Once the file is renamed from &lt;code&gt;thingy_doer.rb&lt;/code&gt; to &lt;code&gt;thing_doer.rb&lt;/code&gt;, everything now works as expected!&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;5 examples, 0 failures

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>rubyrailserrors</category>
      <category>ruby</category>
      <category>rails</category>
    </item>
    <item>
      <title>Git-ing Started</title>
      <dc:creator>Dillon Adams</dc:creator>
      <pubDate>Mon, 22 Jan 2024 00:00:00 +0000</pubDate>
      <link>https://dev.to/dillonad/git-ing-started-2che</link>
      <guid>https://dev.to/dillonad/git-ing-started-2che</guid>
      <description>&lt;p&gt;When starting to learn Git you will see a lot of people claiming that Git is complicated and hard to use. Mostly because Git is complicated and hard to use. You can do a &lt;em&gt;lot&lt;/em&gt; of wild and crazy things with Git, but to function on a day to day basis only a few commands are needed to do the basic Git workflow.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Basic Workflow
&lt;/h2&gt;

&lt;p&gt;First we need to clone the repository. This can be an existing repository or a new one that was just created. This will copy the repository code down to your computer, and set you up with the latest that is on the default branch (typically named &lt;code&gt;main&lt;/code&gt; or &lt;code&gt;master&lt;/code&gt;)&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git clone &amp;lt;RepositoryURL&amp;gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Most workflows won’t allow you to make changes directly to the default branch, so you will have to make your own branch. This is an area where you can make your changes.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git checkout -b &amp;lt;BranchName&amp;gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That command is shorthand for creating a branch and then switching to that branch. The long way around is these two commands.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git branch &amp;lt;BranchName&amp;gt;
git checkout &amp;lt;BranchName&amp;gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Once your changes are made, you will need to stage them to be committed/saved. You do this by adding the files directly, but I tend to just include everything. If you want to add specific directories or files, set the path to the file or directory instead of the &lt;code&gt;.&lt;/code&gt; in the command.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git add .

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Next we want to make our changes permanent. We do this by committing them with a hopefully meaningful commit message. If every commit message is the same generic message, it can create a terrible situation when you need to do more advanced things down the road.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git commit -m "&amp;lt;Message&amp;gt;"

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Last, but certainly not least, we want to persist our changes outside of our computer. We need to push them up to the server that we initially cloned them from. For new branches, we will need to specify the target branch on the server.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git push --set-upstream origin &amp;lt;BranchName&amp;gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If the branch has already been pushed, we can use a simple push.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git push

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Giving up
&lt;/h2&gt;

&lt;p&gt;Every once in a while, you get to a point with a branch that you just want to reset everything back to where you started at the last commit. The specific motivations behind this are wide ranging, but each is valid and you deserve a solution.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;git checkout .
git clean -fdx

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;checkout&lt;/code&gt; command resets any existing files back to their original state. The &lt;code&gt;clean&lt;/code&gt; command deletes any newly created files (&lt;code&gt;f&lt;/code&gt;), directories (&lt;code&gt;d&lt;/code&gt;), and any files that Git is set to ignore (&lt;code&gt;x&lt;/code&gt;).&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;There are a lot more features in Git that people has literally written books about. Once you have mastered the basics, then I would recommend looking into the more advanced features. I have been using Git for almost about decade at this point and I rarely use the more advanced features of this tool so I highly recommend a focus on the things that you will actually use.&lt;/p&gt;

&lt;p&gt;If you end up in a situation where you are stuck, there is a website called &lt;a href="https://ohshitgit.com/"&gt;Oh Shit, Git!?!&lt;/a&gt; that is an excellent resource.&lt;/p&gt;

&lt;p&gt;Hopefully this helps you Git going!&lt;/p&gt;

</description>
      <category>gitworkflow</category>
      <category>git</category>
      <category>versioncontrol</category>
      <category>vcs</category>
    </item>
    <item>
      <title>Versions Are For Humans</title>
      <dc:creator>Dillon Adams</dc:creator>
      <pubDate>Fri, 07 Jul 2023 05:21:05 +0000</pubDate>
      <link>https://dev.to/dillonad/versions-are-for-humans-2456</link>
      <guid>https://dev.to/dillonad/versions-are-for-humans-2456</guid>
      <description>&lt;p&gt;What does it mean to version a piece of software? I believe that it applies a &lt;em&gt;meaningful&lt;/em&gt; label to indicate the capabilities of the software at that point in time. As software engineers, the most common method of doing this is &lt;a href="https://semver.org/"&gt;semantic versioning&lt;/a&gt;. Each number in a semantic version conveys a meaning for a human to understand and use as a basis their decisions. &lt;/p&gt;

&lt;p&gt;If these version numbers are meant for humans to derive meaning from, the incrementation of any part of the version should &lt;em&gt;not&lt;/em&gt; be automated. Automatically incrementing a version strips the version of it's meaning. Let's say that we increment the patch version of a softare package each time we merge to the &lt;code&gt;main&lt;/code&gt; branch. The issue is anyone consuming this software package has &lt;em&gt;no clue&lt;/em&gt; whether there are breaking changes, new features, or just bug fixes in the new version. &lt;/p&gt;

&lt;p&gt;Version numbers are meant for humans, and they should be set by humans. The engineers making changes to a software package should set the new version number as a part of their change. They are the ones that understand the change best and are the most suited to translate the effects of the change into a semantic version.&lt;/p&gt;

&lt;p&gt;Original Post: &lt;a href="https://codejanitor.dev/blog/2023/07/06/Versions-Are-For-Humans"&gt;https://codejanitor.dev/blog/2023/07/06/Versions-Are-For-Humans&lt;/a&gt;&lt;/p&gt;

</description>
      <category>deployment</category>
      <category>versioning</category>
      <category>version</category>
      <category>engineer</category>
    </item>
    <item>
      <title>How To Create A Memory Leak In Golang</title>
      <dc:creator>Dillon Adams</dc:creator>
      <pubDate>Wed, 05 Jan 2022 00:00:00 +0000</pubDate>
      <link>https://dev.to/dillonad/how-to-create-a-memory-leak-in-golang-16oj</link>
      <guid>https://dev.to/dillonad/how-to-create-a-memory-leak-in-golang-16oj</guid>
      <description>&lt;p&gt;A while ago I was monitoring a containerized application, and noticed an odd pattern in the graph for memory usage. The memory usage would climb steadily until reaching the memory limit set on the container and then precipitously drop to zero. This pattern would repeat as long as the application was running. I had a memory leak. &lt;em&gt;Cue ominous music&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;The cause of the memory leak was a fairly simple thing, but due to multiple changes over time in this area of code I had completely missed it. Here is the relevant code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package main

func main() {
    running := true

    for running {
        defer func() {}()
    }
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;Warning: If you execute this code on your machine, it will max out your CPU and eventually your memory&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;I had deferred a function inside of a long running loop. Each time a function is deferred, it gets added to a stack or stack-like data structure (last in, first out). Once the function containing the &lt;code&gt;defer&lt;/code&gt; is completed the stack for that function is emptied one by one and executed. The issue here is that the loop completing an iteration does not trigger the execution of the deferred functions, nor does exiting the loop.&lt;/p&gt;

&lt;p&gt;In my case, deferred functions would continue to be added to the deferred functions stack until the memory footprint finally exceeded what was allowed by the container causing the container to crash. A way around this issue, would be to wrap the &lt;code&gt;defer&lt;/code&gt; statement in another function like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package main

func main() {
    running := true

    for running {
        func() {
            defer func() {}()
        }()
    }
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Wrapping the &lt;code&gt;defer&lt;/code&gt; in a function causes the secondary function’s deferred functions to be executed on every iteration instead of letting them accumulate indefinitely until the program finally finishes. That being said, the solution for my issue was to remove the deferred function from inside the loop.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;package main

func main() {
    defer func() {}()

    running := true

    for running {}
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



</description>
      <category>gogolangmemoryleak</category>
      <category>go</category>
      <category>memoryleak</category>
    </item>
    <item>
      <title>Making Comments Count</title>
      <dc:creator>Dillon Adams</dc:creator>
      <pubDate>Tue, 12 Oct 2021 00:00:00 +0000</pubDate>
      <link>https://dev.to/dillonad/making-comments-count-4gnn</link>
      <guid>https://dev.to/dillonad/making-comments-count-4gnn</guid>
      <description>&lt;p&gt;A generally accepted practice for writing software is leaving comments. These comments will hopefully be helpful to the next person that reads through the code. My overall goal when I comment code is to either describe the purpose of a method/class/file or the reasoning behind a decision that was made in the code.&lt;/p&gt;

&lt;p&gt;Some comments describe what the code is doing verbatim. These work really well in coding tutorials or when I’m learning a new language and I need to remind myself of the function of a particular operator. Outside of those scenario’s I haven’t found them as useful since they are telling me something I already know by reading the code.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Post-increment x and assign to y
var y = x++;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;An exception to my previous statement, is when I find myself using a more esoteric operator, but in that case it is also nice to leave an explanation why the task couldn’t be accomplished with a simpler approach.&lt;/p&gt;

&lt;p&gt;My preferred type of comments provide context to future contributors (including myself once I’ve forgotten everything about that piece of code in about a week). These are the comments that save time down the road by helping future contributors avoid pitfalls that have already been found and remedied.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// Using a loop instead of recursion due to intermittent StackOverflowExceptions
// when processing deeply nested objects
while(condition)
{
    // ...
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Happy commenting!&lt;/p&gt;

</description>
      <category>codestylecomments</category>
      <category>code</category>
      <category>style</category>
      <category>comments</category>
    </item>
    <item>
      <title>Testing GitHub Pages Locally </title>
      <dc:creator>Dillon Adams</dc:creator>
      <pubDate>Fri, 06 Dec 2019 03:22:18 +0000</pubDate>
      <link>https://dev.to/dillonad/testing-github-pages-locally-agf</link>
      <guid>https://dev.to/dillonad/testing-github-pages-locally-agf</guid>
      <description>&lt;p&gt;Something has always bothered me about deploying something that I haven't tested locally. A big manifestation of this is my blog. Since my blog is currently hosted on GitHub Pages, I needed &lt;a href="https://jekyllrb.com/"&gt;Jekyll&lt;/a&gt; and all of its dependencies. Since those aren't things I typically have installed, so I decided to use a piece of software I always install: Docker.&lt;/p&gt;

&lt;p&gt;The whole ordeal managed to come out to a single line:&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Linux&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;docker run &lt;span class="nt"&gt;--rm&lt;/span&gt; &lt;span class="nt"&gt;-it&lt;/span&gt; &lt;span class="nt"&gt;-v&lt;/span&gt; &lt;span class="si"&gt;$(&lt;/span&gt;&lt;span class="nb"&gt;pwd&lt;/span&gt;&lt;span class="si"&gt;)&lt;/span&gt;:/srv/jekyll &lt;span class="nt"&gt;-p&lt;/span&gt; 4000:4000 jekyll/jekyll jekyll serve &lt;span class="nt"&gt;--watch&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;&lt;em&gt;Windows&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight shell"&gt;&lt;code&gt;docker run &lt;span class="nt"&gt;--rm&lt;/span&gt; &lt;span class="nt"&gt;-it&lt;/span&gt; &lt;span class="nt"&gt;-v&lt;/span&gt; &lt;span class="s2"&gt;"%cd%"&lt;/span&gt;:/srv/jekyll &lt;span class="nt"&gt;-p&lt;/span&gt; 4000:4000 jekyll/jekyll jekyll serve &lt;span class="nt"&gt;--watch&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;&lt;em&gt;Note the double quotes since Windows paths can have spaces&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;This command should be run in the root of your GitHub Pages project. It will create a Jekyll container that is listening to the current directory for changes and is exposed via port &lt;code&gt;4000&lt;/code&gt;. This way as you edit either blog content or site styling the changes appear as quickly as the site refreshes in your browser.&lt;/p&gt;

</description>
      <category>testing</category>
      <category>local</category>
      <category>githubpages</category>
      <category>docker</category>
    </item>
    <item>
      <title>Build/Deploy from the Beginning</title>
      <dc:creator>Dillon Adams</dc:creator>
      <pubDate>Tue, 19 Nov 2019 14:08:25 +0000</pubDate>
      <link>https://dev.to/dillonad/build-deploy-from-the-beginning-1bjf</link>
      <guid>https://dev.to/dillonad/build-deploy-from-the-beginning-1bjf</guid>
      <description>&lt;p&gt;When I start a project, I like to follow a few steps to speed things along later. The first is to get the basic project compiling successfully and the next step is to set up the automated build and deployment infrastructure (bonus points if the build/release can be put into version control with the codebase). Some of the benefits of setting up the build/deploy infrastructure early on include automated feedback, easier deployment, and informed design choices.&lt;/p&gt;

&lt;h2&gt;
  
  
  Automated Feedback
&lt;/h2&gt;

&lt;p&gt;Setting up an automated build/deploy provides an early feedback mechanism for those working on the codebase. This feedback provides extraordinarily valuable feedback to those working on the codebase. This feedback includes if the merged code builds and if all of the new and existing tests are passing. While this all &lt;em&gt;should&lt;/em&gt; be confirmed locally, people make mistakes and sometimes things slip. &lt;/p&gt;

&lt;h2&gt;
  
  
  Easier Deployment
&lt;/h2&gt;

&lt;p&gt;Building on the &lt;em&gt;Automated Feedback&lt;/em&gt;, changes can be made to the codebase freely without impacting the ability to deliver the software. A symptom of spending excessive amounts of time developing code is a rough and lengthy process figuring out how to deploy that code. By allowing the build/deploy process to grow with the codebase, the necessary changes to build and deploy the product will be included as the codebase grows. This allows the person with the greatest understanding of the change to make the incremental changes to the build/release process.&lt;/p&gt;

&lt;h2&gt;
  
  
  Informed Design Choices
&lt;/h2&gt;

&lt;p&gt;As the product's codebase grows, more and more design choices are made and each of those choices involves trade offs, incurring &lt;a href="https://en.wikipedia.org/wiki/Opportunity_cost"&gt;opportunity cost&lt;/a&gt;. The earlier these choices are made, the greater the impact is to the whole system. Having build and deployment infrastructure from the beginning forces decisions involving deployment to be considered as the changes are being made. This way changes that incur an unacceptable amount of deployment pain can be either avoided, or reverted with much less pain since there aren't any dependent changes yet.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;In the end, the goal is to be able to produce and deliver excellent, quality software with as little pain as possible. Setting up build/deploy infrastructure early on can alleviate the pain of developing a product and then figuring out how to release it.&lt;/p&gt;

</description>
      <category>automation</category>
      <category>deployment</category>
      <category>build</category>
      <category>release</category>
    </item>
  </channel>
</rss>
