<?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: Maxime Thoonsen 🌳</title>
    <description>The latest articles on Forem by Maxime Thoonsen 🌳 (@maxthoon).</description>
    <link>https://forem.com/maxthoon</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%2F307719%2Fa03df8b5-3435-4b38-8e72-dee38be35007.jpg</url>
      <title>Forem: Maxime Thoonsen 🌳</title>
      <link>https://forem.com/maxthoon</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/maxthoon"/>
    <language>en</language>
    <item>
      <title>Manage your technical debt roadmap right from your code 🚀</title>
      <dc:creator>Maxime Thoonsen 🌳</dc:creator>
      <pubDate>Wed, 28 Oct 2020 08:24:13 +0000</pubDate>
      <link>https://forem.com/maxthoon/manage-your-technical-debt-roadmap-right-from-your-code-1odp</link>
      <guid>https://forem.com/maxthoon/manage-your-technical-debt-roadmap-right-from-your-code-1odp</guid>
      <description>&lt;p&gt;&lt;strong&gt;Exec summary:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Technical debt leads to bugs creation: the number of bugs and the number of design flaws (technical debt) are 0.92 correlated in a &lt;a href="https://www.usenix.org/system/files/conference/cset16/cset16-paper-nord.pdf" rel="noopener noreferrer"&gt;study from the
Software Engineering Institute&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Static analysis tools like SonarQube are massively used (100k+ users) to chase quality defects, but they can't replace human intelligence&lt;/li&gt;
&lt;li&gt;Bug tracking system are time-consuming and don't help developers while they code&lt;/li&gt;
&lt;li&gt;Our tool &lt;a href="https://github.com/theodo/tyrion" rel="noopener noreferrer"&gt;Tyrion&lt;/a&gt; fixes these problems and allows developers to see quality problems right in their IDE&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Quality is worth its investment
&lt;/h2&gt;

&lt;p&gt;Martin Fowler in his famous &lt;a href="https://martinfowler.com/articles/is-quality-worth-cost.html" rel="noopener noreferrer"&gt;article on quality&lt;/a&gt; explains&lt;br&gt;
why investing in software quality is cheaper than not investing in it.&lt;/p&gt;


  &lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fx2wylnug6kgqoi0cr40a.png" alt="Why quality in software is cheaper than no quality: Software with high internal quality gets a short initial slow down, but delivers more rapidly later"&gt;Why quality in software is cheaper than no quality
  


&lt;p&gt;This knowledge has also long been known for lean practitioners:&lt;br&gt;
"&lt;em&gt;If you focus on quality, you will deliver a high quality product on time.&lt;br&gt;
If you focus on delivery, you will deliver a low quality product late.&lt;/em&gt;"&lt;/p&gt;

&lt;p&gt;Why is that? If you focus on delivering things &lt;strong&gt;right the first time&lt;/strong&gt; you will have less rework to do and then save time in the long run. Teams that don't do that end up spending most of their time fixing bugs.&lt;/p&gt;


  &lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F2bs2c0mo8xmiipvnqknm.png" alt="Low quality leads to too many bugs and missed deadlines"&gt;Low quality leads to too many bugs and missed deadlines
  

&lt;h2&gt;
  
  
  Static analysis tools are mandatory but not enough to monitor quality
&lt;/h2&gt;

&lt;p&gt;Once you know you want to deliver quality on the long run, there are a lot of things to do: identifying best practices, tech trainings, problem solving, quality tooling, setting up all kind of monitoring, choosing quality KPIs ...&lt;/p&gt;

&lt;p&gt;If you are serious about keeping the quality of the codebase high, you need to proactively chase, monitor and resolve code quality defects.Even if you have set up all the best linters rules and have a highly trained team, in the long run you will have defects. Indeed, there are a lot of defects that linters can't detect: non homogeneous code and architecture, wrong patterns usage, naming not coherent with business...&lt;/p&gt;

&lt;p&gt;A widespread strategy is to monitor quality by static analysis tools like &lt;a href="https://www.sonarqube.org/" rel="noopener noreferrer"&gt;SonarQube&lt;/a&gt; or &lt;a href="https://codeclimate.com/" rel="noopener noreferrer"&gt;CodeClimate&lt;/a&gt;.&lt;br&gt;
These tools have some advantages:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;✔️You get a quality score without extra work from a developer (once the tool has been set up which can be quick)&lt;/li&gt;
&lt;li&gt;✔️Results are objective&lt;/li&gt;
&lt;li&gt;✔️They give you a list of piece of code you need to change and which good practices have not been followed&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You can have graphs like this one which give you the trend of your technical debt and show you if the situation is getting better or worse.&lt;/p&gt;


  &lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F36r0nve8tob053r3oqfn.png" alt="A SonarQube debt graph from a current project"&gt;A SonarQube debt graph from a current project
  


&lt;p&gt;When talking with tech leads and CTOs, many of them told me that SonarQube has been efficient to help their team keep the quality of their code high.&lt;/p&gt;

&lt;blockquote&gt;
&lt;cite&gt;
    Static Code Analysis Tools (SCAT) provide objective metrics and insights of the code quality and technical debt.
    However, these tools require a real integration effort. Such tools without a team adoption and training are of little value.
    On the opposite, used by trained developers, with a pragmatic understanding of the metrics and warnings, these tools offer a lot of clues on the next refactoring
    needed to reduce project entropy, on the security breaches still to address and on the potential bugs to review.
    SCAT warnings and suggestions must be used as starting points of developers' discussions around quality standards.
    SCAT must not be considered as referees stating good/bad quality points of a project or a team.
    &lt;/cite&gt;
    — Guillaume Michel, Theodo, VP Engineer
&lt;/blockquote&gt;

&lt;p&gt;It has also been proven to be effective in some studies like&lt;br&gt;
&lt;a href="https://arxiv.org/pdf/1910.12816.pdf" rel="noopener noreferrer"&gt;Oswal, Nikhil. "Technical Debt: Identify, Measure and Monitor." (2019)&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;However, those tools have also limitations:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;❌ they create quite a lot of false positive (labeling a piece of code as bad when it is good) and false negative (missing some bad piece of code) requiring times to sort everything.&lt;/li&gt;
&lt;li&gt;❌ they can't inspect all aspects of a project. For example some defects like a wrong or non homogeneous directories' organisation are never detected&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Academic research while confirming the positive impact of static analysis tools insist that they are not mature enough to only rely on them. For example, to assess if a defect will create a bug, Valentina Lenarduzz warns us in her 2019 study "&lt;a href="https://arxiv.org/pdf/1907.00376.pdf" rel="noopener noreferrer"&gt;Are SonarQube Rules Inducing Bugs?&lt;/a&gt;": "&lt;em&gt;SonarQube violation severity is not related to the fault-proneness and there-fore, developers should carefully consider the severity as decision factor for refactoring a violation.&lt;/em&gt;"&lt;/p&gt;

&lt;p&gt;This is exactly what Bill Clark explained very well in his article "&lt;a href="https://technology.riotgames.com/news/taxonomy-tech-debt" rel="noopener noreferrer"&gt;A TAXONOMY OF TECH DEBT&lt;/a&gt;",&lt;br&gt;
human can provide much more valuable information about a piece of code with technical debt like the &lt;strong&gt;contagious&lt;/strong&gt; aspect: "Is it likely this bad code practice could spread somewhere else by copy/paste?"&lt;/p&gt;
&lt;h2&gt;
  
  
  Performant quality monitoring requires human analysis
&lt;/h2&gt;

&lt;p&gt;As we just see, human analysis provides complementary information to static analysis tools:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;✔️human can analyse every aspect of the project: architecture, naming, easiness of understanding, maturity of library and frameworks&lt;/li&gt;
&lt;li&gt;✔️they can provide much more information about the problems they detect since they understand the context around the codebase&lt;/li&gt;
&lt;li&gt;✔️they can provide a prioritization of the problems&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The more the developers in your teams are trained about writing quality the more efficient they will be to detect defects. This is another reason why you should invest a lot in training if you want to achieve high quality in your code.&lt;/p&gt;

&lt;p&gt;You also need to agree on the best way to write things: what is OK and what is not OK to write in the code.&lt;br&gt;
For example, these pieces of code are doing the exact same thing in Symfony.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight php"&gt;&lt;code&gt;
&lt;span class="cd"&gt;/**
* @ORM\Column(unique=true)
*/&lt;/span&gt;
&lt;span class="k"&gt;private&lt;/span&gt; &lt;span class="nv"&gt;$email&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;


&lt;span class="cd"&gt;/**
* @ORM\Column(type="string", length=255, unique=true)
*/&lt;/span&gt;
&lt;span class="k"&gt;private&lt;/span&gt; &lt;span class="nv"&gt;$email&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Both ways have their advantages: the former is shorter to write/read and the latter is more explicit. I prefer the explicit version because I think in this case the tradeoff between the code being super clear and having more words to write and read is worth it. Some other people could say that it is not worth it to add the type and length because it's the default.&lt;/p&gt;

&lt;p&gt;Who is right is less important than having your team agreeing in the standard way of doing it. Because once you agreed, people are autonomous to write and check quality on their own regarding this standard making little by little the whole code base coherent.&lt;/p&gt;

&lt;p&gt;The main drawback of human analysis is that they require a lot of effort to get and update the information about the overall quality.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fs08szm4e4u28cgw1o0yb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fs08szm4e4u28cgw1o0yb.png" alt="Comparison between static analysis and human analysis for software quality. Static analysis requires less effort than human but provides less information"&gt;&lt;/a&gt;&lt;br&gt;Comparison between static analysis and human analysis for software quality
  &lt;/p&gt;

&lt;h2&gt;
  
  
  Existing tools are time-consuming and don't help devs when they are coding
&lt;/h2&gt;

&lt;p&gt;At Theodo we experienced several systems to track self admitted technical debt (SATD, as &lt;a href="https://scholar.google.fr/scholar?q=self+admitted+technical+debt&amp;amp;hl=en&amp;amp;as_sdt=0&amp;amp;as_vis=1&amp;amp;oi=scholart" rel="noopener noreferrer"&gt;software quality researchers calls it&lt;/a&gt;).&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;On small or short projects, we use a special column in Trello/Jira/Monday/Google doc to track tasks we need to do to fix quality problems. This works OK as long as the team fixes everything quickly, so the column doesn't get too long and messy.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;When the project grows we quickly need a real tech roadmap on a separate board.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fo4ekptlfsjgt5pavwg4b.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fo4ekptlfsjgt5pavwg4b.png" alt="Example of debt management using Trello"&gt;&lt;/a&gt;&lt;br&gt;Example of debt management using Trello
  &lt;/p&gt;

&lt;p&gt;We can also use a specialized bug tracking tool like &lt;a href="https://www.bugzilla.org/" rel="noopener noreferrer"&gt;Bugzilla&lt;/a&gt; or &lt;a href="https://bugherd.com/" rel="noopener noreferrer"&gt;Bugherd&lt;/a&gt;.&lt;br&gt;
It works well, but it has two drawbacks:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;❌ it is time-consuming to update it when an item has been fixed or is no longer valid&lt;/li&gt;
&lt;li&gt;❌ developers don't see the defect in their IDE while coding and thus could copy/paste it creating the contagious aspect of the debt explained by Bill Clark.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2&gt;
  
  
  Introducing Tyrion: a tool to help teams track software quality through human analysis
&lt;/h2&gt;

&lt;p&gt;I initiated &lt;a href="https://github.com/theodo/tyrion" rel="noopener noreferrer"&gt;Tyrion&lt;/a&gt; to remove those main drawbacks and be able to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;✔️Document the debt while coding directly in the IDE&lt;/li&gt;
&lt;li&gt;✔️Painlessly update the debt tracking system when something has been fixed&lt;/li&gt;
&lt;li&gt;✔️Quickly get an overview and the trend of the debt&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;
  
  
  Writing comments in the code to map the debt
&lt;/h3&gt;

&lt;p&gt;Instead of registering all technical defects in a tool, the main idea of Tyrion is to add them directly in the code base as comments. Tyrion will parse these comments to generate the debt graphs or CSV files so you can analysis the debt.&lt;/p&gt;

&lt;p&gt;The syntax of the comment is straightforward: the only thing you need to add to a classic comment is a type to allow Tyrion to group them:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// TODO DEBT_TYPE "Author: comment"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I like the following example from a current project. Albéric and Emyly are working on improving the accessibility of the webapp. Nothing urgent from the business and nothing requires immediate change from a technical point of view. But still, they know they can do this piece of code better, so they mark it as debt to improve it a bit later.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// TODO accessibility "Alberic: Add keyboard behaviours and focusability"&lt;/span&gt;
&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;Select&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;React&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;FC&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;Props&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;({&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Even if you don't use Tyrion, adding debt comments in the code is valuable by it-self. It trains developers to evaluate the quality of the code while they are coding. It also partially protects you again the contagious effect of the debt because if you have correctly marked with comments&lt;br&gt;
the debt in the code, developers will think twice before copy/pasting a piece of code that is marked as a debt.&lt;/p&gt;

&lt;p&gt;If you have a large code base, it can take a while to document the whole technical debt. You can do it gradually during few weeks. While working on some part of the app each member of your team will read different files and find something to mark as debt. By doing that you will create little by little the debt map of your project.&lt;br&gt;
Of course, it's better to fix a problem when you see it but for various reason you don't always have the time to do it.&lt;/p&gt;

&lt;p&gt;If your project is of reasonable size, you can also organize a big debt mapping session one afternoon.&lt;/p&gt;
&lt;h3&gt;
  
  
  Using the CLI to generate the first graph
&lt;/h3&gt;

&lt;p&gt;Once you have commented at least a part of the debt you have in your project, you can start using the Tyrion CLI.&lt;/p&gt;

&lt;p&gt;First you need to download it with: &lt;code&gt;npm i -g tyrionl&lt;/code&gt; or &lt;code&gt;yarn global add tyrionl&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Then just run &lt;code&gt;tyrion&lt;/code&gt; in the root directory of your project.&lt;br&gt;
It will scan your files to look for &lt;code&gt;TODO&lt;/code&gt;, &lt;code&gt;FIXME&lt;/code&gt; or &lt;code&gt;@debt&lt;/code&gt; strings in the comments and then assume it is a debt comment.&lt;/p&gt;

&lt;p&gt;This first mode is useful to get information of the current debt status of your project. It can help you respond to question such as "How much debt do we have right now?" or "What &lt;strong&gt;kind&lt;/strong&gt; of debt do we have most?"&lt;/p&gt;

&lt;p&gt;If I run Tyrion in the frontend part of our webapp, I got the following graph where we can find the &lt;code&gt;acessibility&lt;/code&gt; type&lt;br&gt;
of debt from the above debt comment among other types we use on the project.&lt;/p&gt;


  &lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fureou01inhycn086h6tv.png" alt=""&gt;An example of the debt graph showing the current distribution of types of debt
  

&lt;h3&gt;
  
  
  You can customize the weight of each type on the global debt score
&lt;/h3&gt;

&lt;p&gt;All kind of debt doesn't have the same impact. A security issue can be more critic than an over complex function. So you may want to weight differently each kind of debt. This can be done by creating a &lt;code&gt;.tyrion-config.json&lt;/code&gt; file in the root of your project. You can then assign different value to each type of debt.&lt;/p&gt;

&lt;p&gt;Here is the default configuration:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"pricer"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"bug"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"architecture"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"bugRisk"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"security"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"securityRisk"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"quality"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"test"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"doc"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"ci"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;30&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"deploy"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"devEnv"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"outdated"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;5&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"standard"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;100&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"ignorePath"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="s2"&gt;"node_modules"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="s2"&gt;"README.md"&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can find more information on how to use Tyrion on the &lt;a href="https://github.com/theodo/tyrion" rel="noopener noreferrer"&gt;README&lt;/a&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  The trend of the debt may be the most important information
&lt;/h3&gt;

&lt;p&gt;After a while of commenting debt in your code, you will be able to use the second mode that will analyse your Git&lt;br&gt;
history and will create a graph of the evolution of your debt. The command to get it is &lt;code&gt;tyrion -e 200&lt;/code&gt;. You can replace &lt;code&gt;200&lt;/code&gt; with the number of days you want to scan backward.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fg3ua0sm5laxqh6frtazy.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fg3ua0sm5laxqh6frtazy.png" alt="An example of a debt report showing the evolution of the debt"&gt;&lt;/a&gt;&lt;br&gt;An example of a debt report showing the evolution of the debt
  &lt;/p&gt;

&lt;p&gt;This kind of report will help you and your team respond to the question "Are we creating debt or increasing quality?"&lt;br&gt;
It is important to know because if the trend of your debt is increasing, you should invest more in quality.&lt;br&gt;
Remember you won't go faster by overlooking quality 😉.&lt;/p&gt;

&lt;h3&gt;
  
  
  Sharing it with the product/business team
&lt;/h3&gt;

&lt;p&gt;If you are reading this, you are probably a developer, and you probably want to spend more time on quality. You may not be able to do so because someone in the business side of your project prefer that you focus on a short term deadline.&lt;/p&gt;

&lt;p&gt;So you need to negotiate with this person. This tool was also build to help you to do so by providing graph and data&lt;br&gt;
to support your case.&lt;/p&gt;

&lt;p&gt;If you need a csv file to allow business people have a closer look at the data you can generate it with the option &lt;code&gt;--csv&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fy84rn377i6evalpzvaak.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fy84rn377i6evalpzvaak.png" alt="Sharing quality data with product team is a good way to onboard them on the topic"&gt;&lt;/a&gt;&lt;br&gt;Sharing quality data with product team is a good way to onboard them on the topic
  &lt;/p&gt;

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

&lt;p&gt;Keeping a high level of code quality on a project for years is something very difficult. One positive side effect of using Tyrion on a project is that developers can grow their quality awareness while coding. If all developers of your team ask them-selves "Is this piece of code I'm writing/reading the best we can do?" for each feature, you will be on a good track to keep the quality high on the long run.&lt;/p&gt;


&lt;p&gt;I will be happy to discuss about Tyrion and quality management with you. Feel free to either contact me:&lt;br&gt;&lt;br&gt;
  &lt;/p&gt;
&lt;ul&gt;


    &lt;li&gt;📧 by &lt;a href="mailto:maximet@theodo.fr"&gt;email&lt;/a&gt;
&lt;/li&gt;


    &lt;li&gt;🐦 on &lt;a href="https://twitter.com/maxthoon" rel="noopener noreferrer"&gt;twitter&lt;/a&gt;
&lt;/li&gt;


    &lt;li&gt;🐙 by leaving an issue or a pull request on the &lt;a href="https://github.com/theodo/tyrion" rel="noopener noreferrer"&gt;Tyrion repository&lt;/a&gt;
&lt;/li&gt;


    &lt;li&gt;💬 by leaving a comment below&lt;/li&gt;


  &lt;/ul&gt;

</description>
      <category>webdev</category>
      <category>typescript</category>
      <category>codequality</category>
      <category>management</category>
    </item>
    <item>
      <title>Typescript: use the nullish coalescing operator to prevent bugs</title>
      <dc:creator>Maxime Thoonsen 🌳</dc:creator>
      <pubDate>Fri, 21 Aug 2020 10:09:16 +0000</pubDate>
      <link>https://forem.com/maxthoon/typescript-use-the-nullish-coalescing-operator-to-prevent-bugs-19im</link>
      <guid>https://forem.com/maxthoon/typescript-use-the-nullish-coalescing-operator-to-prevent-bugs-19im</guid>
      <description>&lt;p&gt;My goal as a CTO is to improve quality. The score of this game is the number of bugs we find each week. Today I share with you a typical bug that more than one person got caught by.&lt;/p&gt;

&lt;p&gt;Let's say you want to initialize the audio volume of your react application with the value previously saved in the localStorage or defaulting it to &lt;code&gt;0.5&lt;/code&gt; if nothing was saved. You could write something like:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Bad example&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;initializeAudio&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;volume&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;localStorage&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;volume&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="mf"&gt;0.5&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

  &lt;span class="c1"&gt;// ...&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;The problem is that if the user has saved their volume to &lt;code&gt;0&lt;/code&gt; it will be interpreted as falsy and your code will use the default value instead of the right value. Some devs prefer the simplicity of || than putting an explicit if clause. And more than once, they were right because 0 was not a plausible value. But as a standard it is too dangerous. For example someone else could see the code and think the || is a good coding stantard in all situation which will eventually create a bug.&lt;/p&gt;

&lt;p&gt;Typescript 3.7 comes with the best option: you can now use the nullish coalescing operator to prevent that wrong behavior and safely write something like:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Good example&lt;/strong&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;initializeAudio&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;volume&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;localStorage&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;volume&lt;/span&gt; &lt;span class="p"&gt;??&lt;/span&gt; &lt;span class="mf"&gt;0.5&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

  &lt;span class="c1"&gt;// ...&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;That will be compiled in:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;initializeAudio&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;_a&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;volume&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;_a&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;localStorage&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;volume&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;!==&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nx"&gt;_a&lt;/span&gt; &lt;span class="o"&gt;!==&lt;/span&gt; &lt;span class="k"&gt;void&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="nx"&gt;_a&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mf"&gt;0.5&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="c1"&gt;// ...&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;To make sure people from your team use it, you can use the &lt;a href="https://github.com/typescript-eslint/typescript-eslint/blob/master/packages/eslint-plugin/docs/rules/prefer-nullish-coalescing.md"&gt;prefer-nullish-coalescing&lt;/a&gt; ESLint rule. You can also use it with javascript and this &lt;a href="https://babeljs.io/docs/en/babel-plugin-proposal-nullish-coalescing-operator"&gt;babel plugin&lt;/a&gt;. If you want to go deeper in the understanding of this operator you can go &lt;a href="https://javascript.info/nullish-coalescing-operator"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;I hope this article will help your team prevent this kind of bugs. For more actionable code quality tips, find me on &lt;a href="https://twitter.com/maxthoon"&gt;Twitter&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;And you? What's your secrets to prevent bugs in your application? &lt;/p&gt;

</description>
      <category>javascript</category>
      <category>typescript</category>
      <category>webdev</category>
      <category>react</category>
    </item>
  </channel>
</rss>
