<?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: Alexandre Leduc</title>
    <description>The latest articles on DEV Community by Alexandre Leduc (@alexleduc76).</description>
    <link>https://dev.to/alexleduc76</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%2F273713%2Fd858c62d-f642-4522-8c55-c6012980fee3.jpeg</url>
      <title>DEV Community: Alexandre Leduc</title>
      <link>https://dev.to/alexleduc76</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/alexleduc76"/>
    <language>en</language>
    <item>
      <title>Why we use snake_case for variables and camelCase for functions</title>
      <dc:creator>Alexandre Leduc</dc:creator>
      <pubDate>Tue, 20 Aug 2024 22:55:01 +0000</pubDate>
      <link>https://dev.to/alexleduc76/why-we-use-snakecase-for-variables-and-camelcase-for-functions-4hm9</link>
      <guid>https://dev.to/alexleduc76/why-we-use-snakecase-for-variables-and-camelcase-for-functions-4hm9</guid>
      <description>&lt;p&gt;To be less stressed, and therefore better programmers, we have to do our best to free our code from bullshit that makes it a hard to maintain, and hard to onboard new devs-to.&lt;/p&gt;

&lt;p&gt;We use the same name for database fields, JSON property names returned from an API, the HTML form field name attributes, and finally, the Javascript variable names that contain those database-originating values. Naming your data exactly the same in all layers of the stack frees you from having to keep a mental mapping of what is what. Discipline yourself to enforce this rule, and you will be a less stressed programmer.&lt;/p&gt;

&lt;p&gt;We use snake case for naming variables we define ourselves. It sets them apart from most things that are defined in a library, because most libraries use camel case for variable names. &lt;/p&gt;

&lt;p&gt;We use full words instead of acronyms, and if something is an array, it is spelled plural. This helps people from all nationalities understand what a piece of data is, without knowing shorthand versions of words.&lt;/p&gt;

&lt;p&gt;We use camel case for function names simply because it allows us to quickly identify that an identifier is a function, and not a variable. Yes, I know functions can be saved as values, but the difference is that you can't call a primitive/object/array value by adding parentheses to it. That's where the line between function and value is, and having a visual cue to tell one from the other is helpful.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>fullstack</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Opinionated code formatters suck (*)</title>
      <dc:creator>Alexandre Leduc</dc:creator>
      <pubDate>Sun, 03 Dec 2023 17:19:45 +0000</pubDate>
      <link>https://dev.to/alexleduc76/opinionated-code-formatters-suck-3b1</link>
      <guid>https://dev.to/alexleduc76/opinionated-code-formatters-suck-3b1</guid>
      <description>&lt;p&gt;(*) Unless you are OK with the formatting rules they impose on you.&lt;/p&gt;

&lt;p&gt;This article makes the case that opinionated code formatters like &lt;a href="https://prettier.io/docs/en/option-philosophy" rel="noopener noreferrer"&gt;Prettier&lt;/a&gt; and &lt;a href="https://biomejs.dev/formatter/" rel="noopener noreferrer"&gt;Biome&lt;/a&gt;, and the argument they make that providing customizable formatting rules only serves to enable bike shedding arguments between coders, is a fallacy.&lt;/p&gt;

&lt;p&gt;Code formatting is a topic that is dear to many programmers who have spent years working on huge code bases, because they help teams maintain a consistent format and, as a result of that uniformity, can greatly help with &lt;strong&gt;code readability&lt;/strong&gt;. I put the emphasis on code readability here because this is the true value that formatters provide. The easier it is for programmers to read each other's code, the faster they will be at understanding it.&lt;/p&gt;

&lt;p&gt;The specific formatting rules that are enforced by a formatter, and whether they make code more or less readable, is a highly subjective thing. For example, whether you think that putting an 'else' on the same line as the closing curly brace instead of a new line, is more or less readable is a matter of personal preference. Perfectly valid arguments could be made for one way or the other.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;if(i === 0) {
    // do something
} else {
    // do something else
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;if(i === 0) {
    // do something
}
else {
    // do something else
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;However, just because something is subjective doesn't mean that it's not valuable, or that all point of view are equal. The value of a point of view is in the eye of the beholder. If my team is used to putting an "else" on a new line, then that's the valuable formatting rule for us. It would be pointless to argue about it. If your team is used to code that is formatted a certain way and a new hire changes all the code base's formatting by installing Prettier, you will get a lot of teeth grating from the coders who are used to the in-house style and have come to expect things to be formatted a certain way. Arguing that everyone should just accept the formatting rules picked by some tool author that doesn't care about the way you do things just means that your own subjectivity aligns with that of the tool author. Good for you! Too bad for everyone else who thinks the opinionated format is &lt;strong&gt;less readable&lt;/strong&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  Who are the opinionated formatter's authors to decide what's best for everyone else?
&lt;/h3&gt;

&lt;p&gt;Dismissing everyone's subjectivity by imposing the subjectivity of the authors of the formatter does not provide any value. Giving users the option to customize the formatting doesn't take anything away from teams that are perfectly fine with using the defaults. The reverse is not true. If Prettier/Biome were configurable, team leads could enforce internal formatting rules in its configuration files and not have to worry about rogue devs installing one of them and reformatting the whole code base.&lt;/p&gt;

&lt;p&gt;A formatter should concern itself with enforcing the rules that fit users of that tool, not that of the authors of the tool.&lt;/p&gt;

&lt;h3&gt;
  
  
  A closer look into the bike shedding argument
&lt;/h3&gt;

&lt;p&gt;Such debates over code formatting might be something people do on the Internet, but in real work scenarios, that's not something I have seen happen. This feels like a straw man argument to justify imposing your own subjectivity on others. On all projects I have worked on, the lead developer decided the (&lt;a href="https://eslint.style/packages/js" rel="noopener noreferrer"&gt;ESlint&lt;/a&gt;) formatting rules enforced on the project and that was never up for debate.&lt;/p&gt;

&lt;p&gt;The value of a formatter is in enforcing the rules that makes the code more readable &lt;strong&gt;for you&lt;/strong&gt;. Dismissing someone's else's need to use different rules as bike shedding, or an example of &lt;a href="https://github.com/prettier/prettier/issues/40" rel="noopener noreferrer"&gt;tragedy of the commons&lt;/a&gt;, is short-sighted at best, arrogant at worse. Whatever formatting rule &lt;strong&gt;choices&lt;/strong&gt; these tool authors have made is what &lt;strong&gt;they&lt;/strong&gt; think readable code should look like. It doesn't make the code universally more readable for everyone.&lt;/p&gt;

&lt;h3&gt;
  
  
  Prettier &amp;amp; Biome VS &lt;a href="https://eslint.style/packages/js" rel="noopener noreferrer"&gt;ESlint&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;Where I work, we use ESLint as a formatter because it allows us to customize the formatting rules to what &lt;strong&gt;we&lt;/strong&gt; consider to be more readable, and it works perfectly fine for our needs. So you might ask: "Why don't you just keep using ESLint and let everyone else who likes opinionated formatters use that?". Well, this rant came as a result of learning about Biome, a formatter that is written in Rust. I installed it to see how much faster it is and got immediately excited about the noticeable difference compared to other formatters written in JavaScript. As a developer working on huge code bases, I often find the performance of some of the tool chain (formatters, linters, etc.) sluggish, and I'd like to adopt anything that makes my workflow faster. But as soon as I looked at the limited formatting configuration options, I immediately discarded it as yet another thing that doesn't recognize my subjectivity as valid and valuable.&lt;/p&gt;

&lt;p&gt;I doubt it will make the authors of Prettier and Biome change their minds, but I hope that if someone decides to port ESlint to Rust in the future, they will not take the easy road of imposing one-size-fits-all formatting on us. The tooling ecosystem should provide more options, not less.&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>prettier</category>
      <category>biome</category>
      <category>eslint</category>
    </item>
  </channel>
</rss>
