<?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: Em De Barros</title>
    <description>The latest articles on Forem by Em De Barros (@emdebarros).</description>
    <link>https://forem.com/emdebarros</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%2F502173%2Fc5ac1b5f-c064-457b-b1d7-ae3560cb0111.jpg</url>
      <title>Forem: Em De Barros</title>
      <link>https://forem.com/emdebarros</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/emdebarros"/>
    <language>en</language>
    <item>
      <title>406, 404 or 400? Investigating the Fine Line Between API Status Codes.</title>
      <dc:creator>Em De Barros</dc:creator>
      <pubDate>Mon, 13 Mar 2023 15:47:34 +0000</pubDate>
      <link>https://forem.com/emdebarros/406-404-or-400-investigating-the-fine-line-between-api-status-codes-27ba</link>
      <guid>https://forem.com/emdebarros/406-404-or-400-investigating-the-fine-line-between-api-status-codes-27ba</guid>
      <description>&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;Hello, debuggers! I'm a junior developer who's just started my second year of engineering, and I'm currently working on building internal APIs with my team. As we all know, having a solid understanding of HTTP status codes and client-server communication is crucial when creating web services, no matter the scale. But, even experienced developers can face challenges when it comes to the nuances of these status codes and troubleshooting them.&lt;/p&gt;

&lt;p&gt;For my first debugging writeathon, I'm excited to share a particular challenge I faced recently: investigating the fine line between the 406, 404, and 400 status codes for invalid requests. Whether you're a programming wizard or a junior like me, I hope you’ll find some helpful insights and tips in this article. So, let's dive in and explore how I troubleshooted this issue!&lt;/p&gt;

&lt;p&gt;&lt;em&gt;💡 The code examples I'll give in this article are written in C#, on top of ASP.NET Core.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  The Problem
&lt;/h2&gt;

&lt;p&gt;I recently was assigned the task of investigating an unexpected issue that we encountered while testing one of our GET endpoints. We discovered that, whenever the id query parameter was of the incorrect data type (in this case, not a GUID), our API was returning a 406 status code to the client. This was concerning as we were expecting the response to be 400 - Bad Request, indicating a client error due to incorrect input.&lt;/p&gt;

&lt;p&gt;To better illustrate the problem, consider the following sample code snippet:&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="c1"&gt;// implementation details omitted for brevity&lt;/span&gt;

&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nf"&gt;HttpGet&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"{id:guid}/discovery"&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="k"&gt;nameof&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;GetResource&lt;/span&gt;&lt;span class="p"&gt;))]&lt;/span&gt;
&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="n"&gt;ActionResult&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;ResponseDto&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;GetResource&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Guid&lt;/span&gt; &lt;span class="n"&gt;id&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;new&lt;/span&gt; &lt;span class="nf"&gt;ResponseDto&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;So, to reiterate, when an invalid value type is passed in the path parameter of our &lt;code&gt;/GetResource&lt;/code&gt; endpoint, the client receives a misleading error code, i.e. &lt;code&gt;406 - Not Acceptable&lt;/code&gt;. Based on our technical requirements, we needed the response to be &lt;code&gt;400 - Bad Request&lt;/code&gt; with an appropriate error message.&lt;/p&gt;

&lt;p&gt;Can you spot that we have two problems? If not, it’s ok, I didn’t at first too! Let’s jump to the investigation to understand what’s going on.&lt;/p&gt;

&lt;h2&gt;
  
  
  Investigation and Diagnosis
&lt;/h2&gt;

&lt;p&gt;The first step I took to investigate the issue was to review the meaning of HTTP status codes in the 400 realm. I wanted to make sure that I fully understood the difference between a &lt;code&gt;400 - Bad Request&lt;/code&gt; status code and a &lt;code&gt;406 - Not Acceptable&lt;/code&gt; status code. After refreshing my knowledge on the meaning of these HTTP status codes, I suspected that the issue might be related to the way our API routes were defined (or constrained), so I immediately turned my attention to our use of route constraints, which is a concept from the .Net framework.&lt;/p&gt;

&lt;p&gt;After digging a little deeper, I discovered that the default .NET behaviour for this use case is to return a &lt;code&gt;404 - Not Found&lt;/code&gt; status code, not &lt;code&gt;406 - Not Acceptable&lt;/code&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Phase 1
&lt;/h3&gt;

&lt;p&gt;Let’s clarify the meaning of each status code involved in the context and make sure that the 400 status code is really what we want our API to return.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;I’ve formatted in bold the relevant information for our use case.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;400 - Bad Request&lt;/code&gt; &lt;em&gt;(expected)&lt;/em&gt;&lt;br&gt;
The server cannot or will not process the request due to something that is &lt;strong&gt;perceived to be a client error&lt;/strong&gt; (e.g., malformed request syntax, invalid request message framing, or deceptive request routing).&lt;/p&gt;

&lt;p&gt;400 errors indicate an invalid request, which means either that mandatory parameters are missing, or that &lt;strong&gt;syntactically invalid parameter values have been detected (for example an expected URL being text only)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;404 - Not Found&lt;/code&gt; &lt;em&gt;(default .Net behaviour when using route constraints)&lt;/em&gt;&lt;br&gt;
The &lt;strong&gt;server cannot find the requested resource&lt;/strong&gt;. In the browser, this means the URL is not recognized. &lt;strong&gt;In an API, this can also mean that the endpoint is valid but the resource itself does not exist&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;code&gt;406 - Not Acceptable&lt;/code&gt; &lt;em&gt;(improper API response)&lt;/em&gt;&lt;br&gt;
This response is sent when the web server, &lt;strong&gt;after performing server-driven content negotiation, doesn't find any content that conforms to the criteria given by the user agent (calling service)&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;This status code is often bound to Accept/Content-Type Header use cases, e.g. if you set Accept-Header to text/plain for the client and the backend can only produce application/json Content-Type.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;These status code descriptions come from &lt;a href="https://developer.mozilla.org/en-US/docs/Web/HTTP/Status"&gt;MDN web docs&lt;/a&gt;, &lt;a href="https://www.ibm.com/docs/en/alm/1.3.0?topic=reference-api-http-status-codes"&gt;IBM API status codes reference&lt;/a&gt; and &lt;a href="https://github.com/jhipster/generator-jhipster/issues/3127"&gt;GitHub issue&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;At this point, here’s what we know for sure:&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The 406 status code is returned AFTER the server has performed content negotiation and is related to the user agent request header specifications. Currently, the server responds with a 406 status code if the id query parameter is of the incorrect data type, which is inaccurate.&lt;/li&gt;
&lt;li&gt;It should be clear to the client whether they have a typo (or an invalid type) in their request or whether the requested resource is missing. Based on the MDN web docs description, the 404 status code can be returned &lt;strong&gt;when the request is valid but the resource is missing&lt;/strong&gt; (which is how .Net treats this use case, by default). In our specific use case, however, the request would simply be invalid as the GUID data type is enforced at the controller level with validation.
\Hint: Here’s our second problem, and it appears to be the underlying cause of the first problem we encountered.*&lt;/li&gt;
&lt;li&gt;Based on the MDN documentation, the 400 Bad Request status code is indeed what should be returned for malformed request syntax.&lt;/li&gt;
&lt;li&gt;Whether the status code would be a &lt;code&gt;406&lt;/code&gt; or a &lt;code&gt;404&lt;/code&gt;, this is not the behaviour we want. This tells us that the issue is coming from how we validate the route parameter of our endpoint. Let's take a closer look and see how we can fix it!&lt;/li&gt;
&lt;/ol&gt;
&lt;h3&gt;
  
  
  Phase 2
&lt;/h3&gt;

&lt;p&gt;The second phase of my investigation aimed at digging deeper into the inner workings of the framework's route constraints mechanism.&lt;/p&gt;

&lt;p&gt;After reading more on the subject of enforcing types directly in route templates, I found this:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Don't use constraints for input validation. If constraints are used for input validation, invalid input results in a 404 Not Found response. Invalid input should produce a 400 Bad Request with an appropriate error message. Route constraints are used to disambiguate similar routes, not to validate the inputs for a particular route.&lt;br&gt;
Route constraints generally inspect the route value associated via the route template and make a true or false decision about whether the value is acceptable.&lt;br&gt;
&lt;em&gt;Source: &lt;a href="https://learn.microsoft.com/en-us/aspnet/core/fundamentals/routing?view=aspnetcore-7.0#route-constraints"&gt;official Microsoft documentation&lt;/a&gt;.&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;This validated my suspicion that our route parameter validation implementation was incorrect. Route constraints should only be used to differentiate between similar action methods/paths and NOT for input validation.&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;HttpGet&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"{id:guid}/discovery"&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="k"&gt;nameof&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;GetResource&lt;/span&gt;&lt;span class="p"&gt;))]&lt;/span&gt;

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

&lt;/div&gt;



&lt;p&gt;Examples of similar routes that need route constraints for the routing middleware to map the request correctly:&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;HttpGet&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"{bookId}"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="n"&gt;ActionResult&lt;/span&gt; &lt;span class="nf"&gt;GetBookDetails&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;bookId&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;span class="nf"&gt;HttpGet&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"{bookTitle}"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="n"&gt;ActionResult&lt;/span&gt; &lt;span class="nf"&gt;GetBookDetails&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;bookTitle&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;In this sample code, the routing middleware gets confused and doesn't know what action method to invoke. The solution is to add route constraints:&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;HttpGet&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"{bookId:int}"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="n"&gt;ActionResult&lt;/span&gt; &lt;span class="nf"&gt;GetBookDetails&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;bookId&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;span class="nf"&gt;HttpGet&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"{bookTitle:string}"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="n"&gt;ActionResult&lt;/span&gt; &lt;span class="nf"&gt;GetBookDetails&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;bookTitle&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;Basic type validation is performed in the background by .Net, by validating the type against the type declaration from the method parameter definition, like so:&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="n"&gt;ActionResult&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;ResponseDto&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;GetResource&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Guid&lt;/span&gt; &lt;span class="n"&gt;id&lt;/span&gt;&lt;span class="p"&gt;){}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;em&gt;❗️ Note that this is only basic type validation. In this specific case, it does not check for empty (default) GUID value. Further validation should be performed at the DTO level with custom attributes.&lt;/em&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Solution
&lt;/h3&gt;

&lt;p&gt;With these clarifications out of the way, my first step toward fixing the problem was simply to remove the GUID route constraint. This action immediately resolved the issue.&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;HttpGet&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"{id}/discovery"&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="k"&gt;nameof&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;GetResource&lt;/span&gt;&lt;span class="p"&gt;))]&lt;/span&gt;
&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="n"&gt;ActionResult&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;ResponseDto&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;GetResource&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Guid&lt;/span&gt; &lt;span class="n"&gt;id&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;new&lt;/span&gt; &lt;span class="nf"&gt;ResponseDto&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;With this implementation, a &lt;code&gt;400 - Bad Request&lt;/code&gt; status code is now properly sent back to the client in the event of an incorrect type being passed in the &lt;code&gt;id&lt;/code&gt; path parameter.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;💡This endpoint was tested with thorough unit test cases.&lt;/em&gt;&lt;br&gt;
However, at this point, one issue remains: If we wanted to properly use route constraints to differentiate similar action methods, the client would still receive a &lt;code&gt;406 - Not Acceptable&lt;/code&gt; response if no match is found for a route. As we saw previously, the proper response for this use case should be the default .Net Core response of sending back a &lt;code&gt;404 - Not Found&lt;/code&gt; status code.&lt;/p&gt;

&lt;p&gt;Based on our technical requirements and priorities, I didn't get to continue the investigations as this next issue was out of scope. However, to ensure that it doesn't go unnoticed in the future, I took a proactive approach and added it to our technical debt list. While I did not have a definite answer on the root cause of the issue, I made an educated guess and documented it for future reference. It's crucial to understand that an API's behaviour is shaped by various factors, including the implementation and design choices of the project's dependencies, and there may be valid reasons in this case for overriding the default .Net behaviour and sending back a &lt;code&gt;406&lt;/code&gt; status code. It was important to me to make sure that we were all aware of this potential issue and have it documented so that we can address it together as a team if it comes up in the future.&lt;/p&gt;

&lt;h2&gt;
  
  
  Lessons Learned
&lt;/h2&gt;

&lt;p&gt;During this debugging experience, I encountered several roadblocks and learned many valuable lessons along the way.&lt;/p&gt;

&lt;p&gt;One of the most valuable lessons I learned was to not make assumptions and thoroughly investigate the problem before jumping to conclusions. This can also mean always questioning what you know first! In the case of the 406/400 issue, it would have been easy to assume that the bug was related to a typo or some other external factor, without taking the time to fully investigate the issue. So, even though I deal with status codes every day, my first thought was to review their meaning anyway to make sure I was not missing anything important in the definition subtleties. With this approach, I was able to discover the root cause of the issue and avoid wasting time and resources on unnecessary debugging or troubleshooting. This, I think, is an important lesson for any developer to learn, as it can help prevent a lot of frustrating and wasted effort down the road.&lt;/p&gt;

&lt;p&gt;In the same train of thought, I learned when to ask for help and seek out resources when faced with so many possibilities to explore. It's easy to go down rabbit holes because, more often than not, one problem will uncover many other underlying problems you didn't even know existed in the first place. Presenting to your teammates your possible avenues of investigation and asking for some guidance early on and frequently is a great skill to leverage.&lt;/p&gt;

&lt;p&gt;Finally, this debugging experience has taught me the importance of recognizing when to stop and asking myself “Should I continue down this path?” As you progress in your career, you'll realize that the most effective programmers don't always have a one-size-fits-all magical answer for when to stop investigating a problem. Instead, they understand that the right moment to stop will vary depending on the situation. The key skill to develop here is the ability to question often whether it's worth investing more time and resources in something, based on the business and technical requirements. As demonstrated in the solution section, although I was unable to resolve every issue, I made a judgment call on when to stop and move on to other tasks.&lt;/p&gt;

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

&lt;p&gt;Every debugging challenge I face is an opportunity for me to improve my problem-solving skills and shape my problem-solving framework. Over time, this framework becomes more refined and easier to apply when tackling new problems. By repeatedly going through the steps of gathering information, being methodical and always questioning what I know first (even for seemingly simple issues), discussing the possible avenues of investigation with my team, and questioning often whether it's time to stop investigating, I have developed a reusable framework of important habits and steps to take when faced with a coding problem. Not only this framework helps me to solve problems more efficiently, but it also allows me to approach new problems with greater confidence.&lt;/p&gt;

&lt;p&gt;To sum up, debugging skills are an essential part of software development, and it's important to continue sharpening these skills to become a better problem-solver. I encourage all readers to share their own debugging stories and engage with the community to learn new strategies and approaches to solving coding problems. Every challenge can be an opportunity for growth and development, so just remember to always be curious, stay focused, and never give up when faced with a problem.&lt;/p&gt;

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

</description>
      <category>codenewbie</category>
      <category>webdev</category>
      <category>beginners</category>
      <category>programming</category>
    </item>
    <item>
      <title>Conquer Your Fear of Documenting in 9 Simple Steps</title>
      <dc:creator>Em De Barros</dc:creator>
      <pubDate>Sun, 13 Mar 2022 06:00:10 +0000</pubDate>
      <link>https://forem.com/emdebarros/conquer-your-fear-of-documenting-in-9-simple-steps-5eo0</link>
      <guid>https://forem.com/emdebarros/conquer-your-fear-of-documenting-in-9-simple-steps-5eo0</guid>
      <description>&lt;h1&gt;
  
  
  Conquer Your Fear of Documenting in 9 Simple Steps
&lt;/h1&gt;

&lt;p&gt;A team without strong communication skills is like a car without wheels. You won't get far, if at all, anywhere. You can walk, sure, but needless to say that it will take you longer to get to your destination.&lt;/p&gt;

&lt;p&gt;Accordingly, it is crucial for any organization to make sure that there are set and clear communication guidelines, platforms, and mediums to help teams achieve their goals faster and more efficiently. Even more so now that the sanitary crisis has completely changed the way we communicate by forcing countless organizations across the globe to work remotely.&lt;/p&gt;

&lt;p&gt;While many platforms like Zoom, Teams, and Slack ensure great verbal communication, it is important to not underestimate the power of written communication within your organization. Sure, this can be ensured with instant messages and e-mails, but there is an underestimated superpower that many teams overlook and that is documenting your work.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Documenting your work does much more than just helping your team getting $#!t done, and that's what we'll explore in this post.&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Why Should You Even Care?
&lt;/h2&gt;

&lt;p&gt;It is no secret that one of the most important and efficient strategy for getting through a technical interview is to THINK OUT LOUD.&lt;/p&gt;

&lt;p&gt;You need to share your thought process out loud with your interviewer/recruiter when trying to solve a given problem. Doing so, more often than not, is more significant than solving the actual problem, as it lets your recruiter evaluate your communication skills and your abilities to collaborate.&lt;/p&gt;

&lt;p&gt;Unfortunately, this is not your average college exam where you toss in the trash all your efforts after you hand in your paper to the teacher, and leave the classroom to go meet your buddies for a night out. If you passed the interview, that's great. Now, it's time to keep that job. Therefore, thinking out loud shouldn't be something that you leave behind after the interview. You should, unquestionably, continue to leverage and perfect that skill throughout your entire career. This is the skill that got you the job, after all.&lt;/p&gt;

&lt;h2&gt;
  
  
  Does That Mean More Meetings?!
&lt;/h2&gt;

&lt;p&gt;Hell, no.&lt;/p&gt;

&lt;p&gt;But it does mean more writing. Ugh, I know, yet another thing to add to your team's to-do list. However, it offers loads of advantages that make it well worth the time and effort, trust me.&lt;/p&gt;

&lt;p&gt;As you might have realized already, developing a whole service, a component or just a simple feature are all results of team members working together. In fact, one of the main purposes for PR's (Pull Requests) is to set the stage for open communication within a team. PRs not only prevent broken or bad code from getting into production environments, but they also help us improve our design and problem-solving skills, expose us to different point of views, and can even generate new ideas.&lt;/p&gt;

&lt;p&gt;Just like PR's, documenting your work encourages open communication between team members; it is the continuity of thinking out loud. That's why documenting your work goes way beyond just a simple formality. I like to think of this process as the extension of a PR.&lt;/p&gt;

&lt;p&gt;Communication and collaboration should be at the core of your team's values and so, by documenting your work, you are contributing to maintaining a strong and healthy team structure. This process also prevents your team to enter what I like to call the unintentional information hoarding hell, scary I know.&lt;/p&gt;

&lt;p&gt;As the author of the &lt;a href="https://google.github.io/styleguide/docguide/best_practices.html"&gt;Documentation Best Practices article&lt;/a&gt; best put it: "Your mission as a Code Health-conscious engineer is to write for humans first, computers second. Documentation is an important part of this skill". Your documentation is the story of your code. It's an open book for your thought process, where your team members and yourself can find helpful resources related to your project and what you are currently working on.&lt;/p&gt;

&lt;h2&gt;
  
  
  What Are the Benefits?
&lt;/h2&gt;

&lt;p&gt;Documenting your work has two categories of benefits. Those two categories are the immediate benefits and the long-term benefits.&lt;/p&gt;

&lt;h3&gt;
  
  
  Immediate benefits:
&lt;/h3&gt;

&lt;p&gt;Immediate benefits are benefits that you and your team immediately benefit from when documenting your work, duh. Here are a few examples:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;It sets the stage for open communication on every aspect of the building process, as you're letting everyone in on the ideas that lead to architectural and design decisions.&lt;/li&gt;
&lt;li&gt;It helps you and your teammates understand the scope of your project better as you get a more visual and concrete representation of your thought process.&lt;/li&gt;
&lt;li&gt;It helps your team members rapidly understand what you're working on; therefore better contribute to the PR reviews.&lt;/li&gt;
&lt;li&gt;Furthermore, it helps prevent future bugs down the road as writing down your ideas is helpful for spotting bottlenecks, weak architectural design, overkills, and bloated workflows in the early stages of the development process.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Long-Term benefits:
&lt;/h3&gt;

&lt;p&gt;Long-term benefits are benefits that you, your team and other colleagues will continue to benefit from, even long after a project is finished. Here are a few examples:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;If other team members need to step in on something, they are able to contribute to the project sooner and more easily, as they won't have to spend hours tracking down details and directions to start coding.&lt;/li&gt;
&lt;li&gt;The latter applies to yourself as well. If you go back to an old project of yours, you'll be able to pick up where you left from sooner and more confidently.&lt;/li&gt;
&lt;li&gt;It adds value and quality to your work by mirroring all the engagement behind every aspect of the building process and by educating the readers.&lt;/li&gt;
&lt;li&gt;As team members come and go, it's crucial that knowledge is not kept to one employee only, but rather shared within the team. It facilitates change inside the company, makes hiring and onboarding much easier, and prevents information hoarding.&lt;/li&gt;
&lt;li&gt;It creates consistency by ensuring that the same information, processes, and plans are being consumed by everyone in the team.&lt;/li&gt;
&lt;li&gt;Good documentation not only mirrors your thought process, but also collects all the necessary information about a task and/or a project in a centralized and organized place. This ensures that your teammates don't go down a rabbit hole trying to understand what you are doing, therefore cuts down on duplicative work. You already did the hard work, save them the googling.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;💡 Did you know that the average worker spends about &lt;a href="https://xenit.eu/do-workers-still-waste-time-searching-for-information/"&gt;two and a half hours per day&lt;/a&gt; searching for the information they need?&lt;/p&gt;

&lt;h2&gt;
  
  
  Tips &amp;amp; Tricks
&lt;/h2&gt;

&lt;p&gt;Hopefully, by now, I've convinced you that documenting your work should be an integral part of your daily workflow. In this section, I'll discuss some tips &amp;amp; tricks on how to get started. If documenting your work is already something you're familiar with, perhaps you'll still pickup something helpful. Keep reading!&lt;/p&gt;

&lt;p&gt;Just like creating a mockup and a wireframe when you're designing a website, you should start documenting your work at the very beginning of your project. You can even document the thought process that led to the project idea in the first place! There are many ways to go about this and, as you get used to documenting your work regularly, you'll develop your own strategies. However, to make the most of your documentation efforts, there are (you guessed it), a few common guidelines that you can follow to structure your documentation.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Follow this structure: Intro (Opening Remarks, Build-Up) → Conclusion (Design architecture and decisions) → Thought Process (Explanation, Research) → Extra (User Cases, Resources)&lt;/li&gt;
&lt;li&gt;If the documentation is long, add a table of content at the beginning of your documentation&lt;/li&gt;
&lt;li&gt;Say what you mean simply and directly.&lt;/li&gt;
&lt;li&gt;Keep it short and useful. As written by the author of the &lt;a href="https://google.github.io/styleguide/docguide/best_practices.html"&gt;Documentation Best Practices article&lt;/a&gt;: "Docs work best when they are alive but frequently trimmed, like a bonsai tree".&lt;/li&gt;
&lt;li&gt;Get into the habit of updating your documentation frequently&lt;/li&gt;
&lt;li&gt;To avoid &lt;a href="https://en.wikipedia.org/wiki/Scope_creep"&gt;scope creep&lt;/a&gt;, try to keep your documentation linked to a single User Story&lt;/li&gt;
&lt;li&gt;Leverage the tools provided by your organization's writing platform to add visual resources, links, etc.&lt;/li&gt;
&lt;li&gt;Get into the habit of reviewing other documentation and contributing to them as well; this will help you get better at writing!&lt;/li&gt;
&lt;li&gt;Set an environment in your team's wiki platform for each project, and keep every doc under one main project directory. Break down that structure as necessary.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Don't worry about your documentation being perfect. News flash: docs are never perfect - they are messy and should be. The purpose of keeping a project wiki is to jot down your thought process, set the stage for open communication within your team, and encourage the process of building in public.&lt;br&gt;
Focus on keeping it clean and practical. You'll get better with time.&lt;/p&gt;

&lt;p&gt;During my internship, I had the chance to collaborate with the former system architect of my team, who generously and gladly shared with me all those tips &amp;amp; tricks to build strong and useful project documentations. These simple guidelines really helped me grow as a developer, and I hope that you can now benefit from them as well.&lt;/p&gt;

&lt;h2&gt;
  
  
  What Next?
&lt;/h2&gt;

&lt;p&gt;As projects grow, wikis grow. Sometimes, it's good to revisit old documentation and clean up a little. This habit ensures a good and healthy wiki environment for everyone in the team. A good way to go about this is to start by deleting what you are certain is wrong and, then, including your team members in the process.&lt;/p&gt;

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

&lt;p&gt;As stated in the beginning of this article, documenting your work goes way beyond just a simple formality. Prioritizing documentation within your organization means you and your team will build strong resources that you'll be able to rely on.&lt;/p&gt;

&lt;p&gt;From covering the unexpected absence of a team member to tackling an unfamiliar project, you and your team will be able to overcome these challenges more easily and confidently. The process of documenting your work will increase transparency within your team and encourage a more collaborative and strategic culture. You'll all be able to make smarter decisions as information won't be locked away in one person's head only, therefore avoiding the unintentional information hoarding hell.&lt;/p&gt;

&lt;p&gt;I really hope this post was useful for you and that you learned something. I encourage you to share the above advantages to your team members and find ways to incorporate this process in your day-to-day tasks.&lt;/p&gt;

&lt;p&gt;Thank you for reading!&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;P.S.: To thank you for reading this far, I've provided you with a free template to get your feet wet with documenting your work. Head over to the page below 👇🏻&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://edebarros.ca/my-blog/blog-posts-gallery/documenting-your-work/project-wiki-template"&gt;Project Wiki Template&lt;/a&gt;&lt;br&gt;
💡 Follow me on &lt;a href="https://medium.com/@edebarros"&gt;Medium&lt;/a&gt;, &lt;a href="https://twitter.com/emmadb1396"&gt;Twitter&lt;/a&gt;, and &lt;a href="https://www.linkedin.com/in/emma-de-barros/"&gt;LinkedIn&lt;/a&gt;!&lt;/p&gt;

</description>
    </item>
  </channel>
</rss>
