<?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: TSOTSI1</title>
    <description>The latest articles on DEV Community by TSOTSI1 (@tsotsi1).</description>
    <link>https://dev.to/tsotsi1</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%2F440735%2F676d0465-7ba5-47e2-b153-03e16a591e44.jpeg</url>
      <title>DEV Community: TSOTSI1</title>
      <link>https://dev.to/tsotsi1</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/tsotsi1"/>
    <language>en</language>
    <item>
      <title>Untangling `.npmrc` Configuration and Authentication: A Journey Down the Rabbit Hole</title>
      <dc:creator>TSOTSI1</dc:creator>
      <pubDate>Tue, 12 Mar 2024 13:52:00 +0000</pubDate>
      <link>https://dev.to/tsotsi1/untangling-npmrc-configuration-and-authentication-a-journey-down-the-rabbit-hole-4fcn</link>
      <guid>https://dev.to/tsotsi1/untangling-npmrc-configuration-and-authentication-a-journey-down-the-rabbit-hole-4fcn</guid>
      <description>&lt;p&gt;When working with Node.js and npm, the &lt;code&gt;.npmrc&lt;/code&gt; file becomes an integral part of your development environment. It contains crucial configurations that dictate how your npm installations behave. Yet, the details of the &lt;code&gt;.npmrc&lt;/code&gt; file and the authentication principles behind it often remain shrouded in mystery. Today, let's uncover these less-travelled paths and make sense of the wonderland that is &lt;code&gt;.npmrc&lt;/code&gt;.&lt;br&gt;
 &lt;br&gt;
 &lt;/p&gt;

&lt;h2&gt;
  
  
  Understanding &lt;code&gt;.npmrc&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;The &lt;code&gt;.npmrc&lt;/code&gt; file is a configuration file for npm. It can be located in four places, each corresponding to a different level of configuration:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Per-project configuration (in your project root): &lt;code&gt;/path/to/my/project/.npmrc&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Per-user configuration (in your home directory): &lt;code&gt;~/.npmrc&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Global configuration (in the npm install directory): &lt;code&gt;$PREFIX/etc/npmrc&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Built-in npm configuration: &lt;code&gt;/path/to/npm/npmrc&lt;/code&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Each level has its use cases, but the real magic lies in understanding and manipulating these files for a smoother and more customized development experience.&lt;br&gt;
 &lt;/p&gt;

&lt;h2&gt;
  
  
  Diving into Authentication
&lt;/h2&gt;

&lt;p&gt;When it comes to private npm registries, authentication becomes vital. Typically, npm uses authentication tokens, which can be set in the &lt;code&gt;.npmrc&lt;/code&gt; file using the &lt;code&gt;npm login&lt;/code&gt; command. This token is sent with every request to the registry to confirm your identity.&lt;/p&gt;

&lt;p&gt;The creation of these tokens involves a process called token-based authentication, where the client exchanges valid user credentials for a token. This token then serves as a key to access the specified resources, thereby preserving the security of user credentials.&lt;br&gt;
 &lt;/p&gt;

&lt;h2&gt;
  
  
  The Uncommon Corners of &lt;code&gt;.npmrc&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;While the fundamentals of &lt;code&gt;.npmrc&lt;/code&gt; and npm authentication are widely discussed, some subtleties often go unnoticed.&lt;br&gt;
 &lt;/p&gt;

&lt;h3&gt;
  
  
  Scoped Registries
&lt;/h3&gt;

&lt;p&gt;One lesser-known feature of &lt;code&gt;.npmrc&lt;/code&gt; is the ability to set up scoped registries. With scoped registries, you can specify different registries for packages based on their scope, allowing for a high degree of customization. It is particularly useful when working with a mix of public and private packages.&lt;br&gt;
 &lt;/p&gt;

&lt;h3&gt;
  
  
  Environment Variables in &lt;code&gt;.npmrc&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;Did you know that you can use environment variables in your &lt;code&gt;.npmrc&lt;/code&gt; file? This is a nifty feature when dealing with sensitive data like authentication tokens, which you might not want to commit to your source control. You can set these variables in your environment and refer to them in your &lt;code&gt;.npmrc&lt;/code&gt; file as &lt;code&gt;${VARIABLE_NAME}&lt;/code&gt;.&lt;br&gt;
 &lt;/p&gt;

&lt;h3&gt;
  
  
  Two-Factor Authentication (2FA)
&lt;/h3&gt;

&lt;p&gt;In the context of npm and &lt;code&gt;.npmrc&lt;/code&gt;, Two-Factor Authentication (2FA) provides an extra layer of security when publishing packages or when an authentication token is created. The additional step of confirming the user’s identity using something they have (like a mobile device) prevents attackers from taking over a user's account, even if they have the token.&lt;br&gt;
 &lt;br&gt;
 &lt;/p&gt;

&lt;h2&gt;
  
  
  Wrapping Up
&lt;/h2&gt;

&lt;p&gt;The &lt;code&gt;.npmrc&lt;/code&gt; file and the authentication process behind npm provide a complex yet fascinating landscape to navigate. By understanding the nuances, you can not only streamline your npm experience but also enhance the security of your packages.&lt;/p&gt;

&lt;p&gt;In the rapidly evolving world of web development, remember to go beyond the beaten path and delve into the uncommon corners. After all, sometimes the road less traveled leads to the greatest treasures. Happy coding!&lt;/p&gt;

</description>
    </item>
    <item>
      <title>The Basic Principles of Clean Code</title>
      <dc:creator>TSOTSI1</dc:creator>
      <pubDate>Tue, 12 Mar 2024 13:51:09 +0000</pubDate>
      <link>https://dev.to/tsotsi1/the-basic-principles-of-clean-code-1cia</link>
      <guid>https://dev.to/tsotsi1/the-basic-principles-of-clean-code-1cia</guid>
      <description>&lt;p&gt;Writing code is an art, and like all art, it must be done with care and a sense of craftsmanship. In this article, we'll explore the basic principles of clean code, which can help you write code that is easier to read, maintain, and debug.&lt;br&gt;
 &lt;br&gt;
 &lt;/p&gt;

&lt;h3&gt;
  
  
  1. Use Descriptive Names
&lt;/h3&gt;

&lt;p&gt;When naming variables, functions, classes, and other entities, use names that clearly express what they represent. Avoid using abbreviations or single-letter names that don't provide any context.&lt;br&gt;
 &lt;/p&gt;

&lt;h3&gt;
  
  
  2. Write Functions that Do One Thing
&lt;/h3&gt;

&lt;p&gt;Each function you write should only do one thing. If a function is doing multiple things, it's a sign that it should be broken down into smaller functions. Each function should be small, ideally less than 20 lines of code.&lt;br&gt;
 &lt;/p&gt;

&lt;h3&gt;
  
  
  3. Keep Function Arguments to a Minimum
&lt;/h3&gt;

&lt;p&gt;The more arguments a function has, the harder it is to understand and use. Aim for no more than two or three arguments per function. If you find that a function requires more arguments, consider if it might be better to group related arguments into an object.&lt;br&gt;
 &lt;/p&gt;

&lt;h3&gt;
  
  
  4. Avoid Side Effects
&lt;/h3&gt;

&lt;p&gt;Functions should avoid altering any states or producing any effects that aren't related to their main purpose. These "side effects" can lead to bugs that are hard to track down and understand.&lt;br&gt;
 &lt;/p&gt;

&lt;h3&gt;
  
  
  5. Write Code Once
&lt;/h3&gt;

&lt;p&gt;Don't repeat yourself (DRY). If you find yourself writing the same code in multiple places, consider how you can refactor to avoid repetition. Code duplication makes your codebase larger than necessary and can lead to bugs if the duplicate code gets out of sync.&lt;br&gt;
 &lt;/p&gt;

&lt;h3&gt;
  
  
  6. Comment Wisely
&lt;/h3&gt;

&lt;p&gt;Use comments to explain the 'why' rather than the 'what'. Comments should be used to explain the purpose of the code, any limitations, and how it's used. Avoid unnecessary comments that don't add any value.&lt;br&gt;
 &lt;/p&gt;

&lt;h3&gt;
  
  
  7. Code Formatting
&lt;/h3&gt;

&lt;p&gt;Consistent code formatting is important for readability. This includes indentation, spacing, and the use of braces. Many teams use a linter or a code formatter like Prettier to enforce a consistent coding style.&lt;br&gt;
 &lt;/p&gt;

&lt;h3&gt;
  
  
  8. Error Handling
&lt;/h3&gt;

&lt;p&gt;Error handling is not an afterthought; it should be planned from the start. Functions that might fail should throw exceptions, and these exceptions should be caught and handled appropriately.&lt;br&gt;
 &lt;/p&gt;

&lt;h3&gt;
  
  
  9. Keep Your Code Simple
&lt;/h3&gt;

&lt;p&gt;Avoid over-engineering. Write the simplest code that can solve the problem at hand. Resist the temptation to use complex patterns or fancy language features when they're not necessary.&lt;br&gt;
 &lt;/p&gt;

&lt;h3&gt;
  
  
  10. Test Your Code
&lt;/h3&gt;

&lt;p&gt;Testing is not optional. Every piece of code you write should be tested, ideally with automated tests. Tests give you confidence that your code works as expected and allows you to make changes without fear of breaking things.&lt;br&gt;
 &lt;br&gt;
 &lt;/p&gt;

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

&lt;p&gt;Clean code is all about readability and maintainability. It's about writing code that is easy to read, easy to understand, and easy to change. These principles provide a solid foundation for writing clean code, but remember that every principle has exceptions. The key is to use your judgement and aim for code that is clean and efficient, without becoming a victim of dogmatism.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>7 Unique Insights into the Principles of Clean Code</title>
      <dc:creator>TSOTSI1</dc:creator>
      <pubDate>Fri, 16 Jun 2023 01:12:00 +0000</pubDate>
      <link>https://dev.to/tsotsi1/7-unique-insights-into-the-principles-of-clean-code-48do</link>
      <guid>https://dev.to/tsotsi1/7-unique-insights-into-the-principles-of-clean-code-48do</guid>
      <description>&lt;p&gt;When discussing clean code, many commonly talk about using descriptive names, keeping functions small, or avoiding code duplication. &lt;/p&gt;

&lt;p&gt;While these principles are essential, they don't paint the entire picture. In this article, we'll dive into some less discussed but equally critical aspects of writing clean, maintainable code.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F07u8tscy08hq9o2ijvn7.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F07u8tscy08hq9o2ijvn7.gif" alt=" " width="640" height="580"&gt;&lt;/a&gt;&lt;/p&gt;

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

&lt;h3&gt;
  
  
  1. Embracing &lt;strong&gt;YAGNI&lt;/strong&gt; (You Ain't Gonna Need It)
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;YAGNI&lt;/strong&gt; is a principle of extreme programming that suggests developers should not add functionality until deemed necessary. &lt;/p&gt;

&lt;p&gt;While it might be tempting to add 'flexibility' to your code because you 'might need it in the future', it often leads to unnecessary complexity. Stick to the requirements, and don't write code that you ain't gonna need.&lt;br&gt;
 &lt;/p&gt;

&lt;h3&gt;
  
  
  2. Considering Code as Liability, Not an Asset
&lt;/h3&gt;

&lt;p&gt;An unusual but pragmatic perspective on code is to view it as a liability rather than an asset. Every line of code written has an inherent cost. &lt;/p&gt;

&lt;p&gt;It needs to be understood, maintained, and tested. Before writing more code, ask if the feature is essential or if there's a simpler way to implement it.&lt;br&gt;
 &lt;/p&gt;

&lt;h3&gt;
  
  
  3. Proactive Refactoring
&lt;/h3&gt;

&lt;p&gt;Refactoring is often seen as a chore – something to be done 'later'. But proactive refactoring, or continuously improving the codebase as part of the development process, leads to cleaner code. &lt;/p&gt;

&lt;p&gt;If you see an opportunity to improve the code, take it. As the saying goes, "leave the code better than you found it".&lt;br&gt;
 &lt;/p&gt;

&lt;h3&gt;
  
  
  4. Valuing Readability Over Cleverness
&lt;/h3&gt;

&lt;p&gt;Writing clever code might feel satisfying, but if it comes at the expense of readability, it's not clean code. &lt;/p&gt;

&lt;p&gt;Prioritize writing code that is easy to understand over code that's 'smart'. Remember, code is read more often than it is written, so optimize for the reader, not the writer.&lt;br&gt;
 &lt;/p&gt;

&lt;h3&gt;
  
  
  5. Treating Performance Optimization with Caution
&lt;/h3&gt;

&lt;p&gt;While high performance is important, premature optimization can lead to overly complex code that is difficult to read and maintain. &lt;/p&gt;

&lt;p&gt;The first priority should be writing clear, correct code. Once that's in place, use profiling tools to identify performance bottlenecks and optimize as necessary.&lt;br&gt;
 &lt;/p&gt;

&lt;h3&gt;
  
  
  6. Embracing Simplicity Over Completeness
&lt;/h3&gt;

&lt;p&gt;It might be tempting to build a complete system with all possible features. &lt;/p&gt;

&lt;p&gt;However, keeping the codebase small and simple is crucial for maintainability. A minimal but well-implemented feature set often serves better than an exhaustive list of poorly maintained features.&lt;br&gt;
 &lt;/p&gt;

&lt;h3&gt;
  
  
  7. Using Code Reviews as a Learning Opportunity
&lt;/h3&gt;

&lt;p&gt;Code reviews are not just about finding bugs or enforcing coding standards. &lt;/p&gt;

&lt;p&gt;They're also an excellent opportunity to learn and share knowledge. Encourage open discussions, ask questions, share insights, and you'll find that your team's ability to write clean code improves over time.&lt;/p&gt;

&lt;p&gt;To boost your Code Reviews, kindly refer to this article. &lt;a href="https://dev.to/tsotsi1/enhancing-code-reviews-with-conventional-comments-2j9i"&gt;Enhancing Code Reviews with Conventional Comments&lt;/a&gt;&lt;/p&gt;

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

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

&lt;p&gt;Writing clean code is not just about following a set of rules. It's about a mindset that prioritizes readability, simplicity, and maintainability. It requires continual learning and adaptation. &lt;/p&gt;

&lt;p&gt;Embrace these principles, and you'll find yourself writing cleaner, more maintainable code in no time. Happy coding🤘!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fadzq5o682hrr4bdfaajb.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fadzq5o682hrr4bdfaajb.gif" alt=" " width="396" height="516"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>cleancode</category>
      <category>programming</category>
      <category>computerscience</category>
    </item>
    <item>
      <title>Harnessing the Power Strictly Typed Forms in Angular: A Simple Tutorial</title>
      <dc:creator>TSOTSI1</dc:creator>
      <pubDate>Mon, 12 Jun 2023 00:53:32 +0000</pubDate>
      <link>https://dev.to/tsotsi1/harnessing-the-power-of-angular-typed-forms-a-simple-tutorial-4ed8</link>
      <guid>https://dev.to/tsotsi1/harnessing-the-power-of-angular-typed-forms-a-simple-tutorial-4ed8</guid>
      <description>&lt;p&gt;When working with Angular, handling forms is a common task. However, forms can get complicated very quickly, and ensuring type safety can become a struggle. &lt;/p&gt;

&lt;p&gt;That's where Angular Typed Forms come in. Let's dive into how we can leverage typed forms to make our applications more robust.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fl56llnjq4s7f9w6uxsyd.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fl56llnjq4s7f9w6uxsyd.gif" alt=" " width="390" height="240"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt; &lt;br&gt;
 &lt;/p&gt;
&lt;h2&gt;
  
  
  Understanding Angular Typed Forms
&lt;/h2&gt;

&lt;p&gt;Angular provides two ways to work with forms: &lt;strong&gt;template-driven&lt;/strong&gt; and &lt;strong&gt;reactive.&lt;/strong&gt; While both have their benefits, reactive forms provide more flexibility and are better suited for working with typed forms.&lt;/p&gt;

&lt;p&gt;Angular Typed Forms is an innovative approach to reactive forms that brings strong typing into the picture. With typed forms, you define your form controls and groups using interfaces, helping you to maintain type safety.&lt;br&gt;
 &lt;/p&gt;
&lt;h2&gt;
  
  
  Setting Up a Book Collection Typed Form
&lt;/h2&gt;

&lt;p&gt;Suppose we're working on a form for a book collection. We'll start by defining an interface for our form data.&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="kr"&gt;interface&lt;/span&gt; &lt;span class="nx"&gt;BookForm&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;title&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;author&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;genre&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="p"&gt;[];&lt;/span&gt;
  &lt;span class="nl"&gt;publicationYear&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="kr"&gt;number&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;Now, we'll use this interface to create a typed form group.&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="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;bookForm&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;FormGroup&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;BookForm&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
  &lt;span class="na"&gt;title&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;FormControl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;''&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
  &lt;span class="na"&gt;author&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;FormControl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;''&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
  &lt;span class="na"&gt;genre&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;FormArray&lt;/span&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="kr"&gt;string&lt;/span&gt;&lt;span class="o"&gt;&amp;gt;&lt;/span&gt;&lt;span class="p"&gt;([]),&lt;/span&gt;
  &lt;span class="na"&gt;publicationYear&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;FormControl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;''&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt; &lt;/p&gt;

&lt;h2&gt;
  
  
  Manipulating Typed Form Values
&lt;/h2&gt;

&lt;p&gt;One of the most common operations on forms is getting and setting values. With typed forms, this becomes straightforward, and the compiler will warn you if you're accessing or assigning properties that do not exist on the interface.&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;// Getting values&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;bookTitle&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;bookForm&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;controls&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;title&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;// Setting values&lt;/span&gt;
&lt;span class="nx"&gt;bookForm&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;controls&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;publicationYear&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;setValue&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="mi"&gt;2023&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt; &lt;/p&gt;

&lt;h2&gt;
  
  
  Working with Form Arrays
&lt;/h2&gt;

&lt;p&gt;Form arrays are used when you have a variable set of controls. With typed forms, you can handle form arrays with ease.&lt;/p&gt;

&lt;p&gt;Here's how you add a new genre to the array in our book form:&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="nx"&gt;bookForm&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;controls&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;genre&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;push&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;FormControl&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Science Fiction&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This way, working with forms becomes more intuitive, and you get the benefit of strong typing, which prevents many common mistakes that might be overlooked when dealing with 'any' types.&lt;br&gt;
 &lt;br&gt;
 &lt;/p&gt;

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

&lt;p&gt;By using Angular Typed Forms, we ensure that our forms are type safe. It brings in an extra layer of security to our applications by enabling us to leverage TypeScript's powerful typing. &lt;/p&gt;

&lt;p&gt;It makes our code cleaner, easier to understand, and less prone to errors. The typed forms provide a simple, yet innovative way to handle the complexities of form management in Angular, making your development process much more efficient and enjoyable.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fml72gaayszd064kqwci7.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fml72gaayszd064kqwci7.gif" alt=" " width="540" height="304"&gt;&lt;/a&gt;&lt;br&gt;
 &lt;/p&gt;

&lt;p&gt;Thanks for reading, and happy coding🤘!&lt;br&gt;
 &lt;br&gt;
 &lt;/p&gt;

</description>
      <category>angular</category>
      <category>typescript</category>
      <category>frontend</category>
      <category>typedform</category>
    </item>
    <item>
      <title>Enhancing Code Reviews with Conventional Comments</title>
      <dc:creator>TSOTSI1</dc:creator>
      <pubDate>Sun, 11 Jun 2023 01:00:09 +0000</pubDate>
      <link>https://dev.to/tsotsi1/enhancing-code-reviews-with-conventional-comments-2j9i</link>
      <guid>https://dev.to/tsotsi1/enhancing-code-reviews-with-conventional-comments-2j9i</guid>
      <description>&lt;p&gt;In software development, code reviews are a vital practice that ensures code quality, promotes consistency, and fosters knowledge sharing. Yet, at times, they can drive me absolutely bananas!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwm2k5cesmvskbqxdyy2m.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwm2k5cesmvskbqxdyy2m.gif" alt=" " width="300" height="236"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;However, the effectiveness of code reviews is contingent on clear, concise communication. This is where Conventional Comments play a pivotal role. &lt;/p&gt;

&lt;p&gt;Conventional Comments provide a standardized method of delivering and receiving feedback during code reviews, reducing misunderstandings and promoting more efficient discussions.&lt;/p&gt;

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

&lt;h2&gt;
  
  
  What are Conventional Comments?
&lt;/h2&gt;

&lt;p&gt;Conventional Comments are a structured commenting system for code reviews and other forms of technical dialogue. They establish a set of predefined labels, such as &lt;code&gt;nitpick&lt;/code&gt;, &lt;code&gt;issue&lt;/code&gt;, &lt;code&gt;suggestion&lt;/code&gt;, &lt;code&gt;praise&lt;/code&gt;, &lt;code&gt;question&lt;/code&gt;, &lt;code&gt;thought&lt;/code&gt;, and notably, &lt;code&gt;non-blocking&lt;/code&gt;. Each label corresponds to a specific comment type and expected response.&lt;br&gt;
&lt;br&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Labels instances:&lt;/strong&gt;&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Labels&lt;/th&gt;
&lt;th&gt;Description&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;praise&lt;/td&gt;
&lt;td&gt;Highlights something positive. Always look for something to sincerely praise.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;nitpick&lt;/td&gt;
&lt;td&gt;Trivial, preference-based requests. These should be non-blocking by nature.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;suggestion&lt;/td&gt;
&lt;td&gt;Proposes improvements to the current subject. Be explicit and clear on what is being suggested and why it is an improvement.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;issue&lt;/td&gt;
&lt;td&gt;Highlights specific problems with the subject under review. These problems can be user-facing or behind the scenes. It is strongly recommended to pair this comment with a suggestion.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;todo&lt;/td&gt;
&lt;td&gt;Small, trivial, but necessary changes. Distinguishing todo comments from issues or suggestions helps direct the reader's attention to comments requiring more involvement.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;question&lt;/td&gt;
&lt;td&gt;Appropriate if you have a potential concern but are not quite sure if it's relevant or not. Asking the author for clarification or investigation can lead to a quick resolution.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;thought&lt;/td&gt;
&lt;td&gt;Represents an idea that popped up from reviewing. These comments are non-blocking by nature, but they are extremely valuable and can lead to more focused initiatives and mentoring opportunities.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;chore&lt;/td&gt;
&lt;td&gt;Simple tasks that must be done before the subject can be “officially” accepted. Usually, these comments reference some common process.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;note&lt;/td&gt;
&lt;td&gt;Always non-blocking and simply highlight something the reader should take note of.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;typo&lt;/td&gt;
&lt;td&gt;Typo comments are like todo:, where the main issue is a misspelling.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;polish&lt;/td&gt;
&lt;td&gt;Polish comments are like a suggestion, where there is nothing necessarily wrong with the relevant content, there's just some ways to immediately improve the quality.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;quibble&lt;/td&gt;
&lt;td&gt;Quibbles are very much like nitpick:, except it does not conjure up images of lice and animal hygiene practices.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Decoration instances:&lt;/strong&gt;&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Decoration&lt;/th&gt;
&lt;th&gt;Description&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;non-blocking&lt;/td&gt;
&lt;td&gt;A comment with this decoration should not prevent the subject under review from being accepted. This is helpful for organizations that consider comments blocking by default.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;blocking&lt;/td&gt;
&lt;td&gt;A comment with this decoration should prevent the subject under review from being accepted, until it is resolved. This is helpful for organizations that consider comments non-blocking by default.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;if-minor&lt;/td&gt;
&lt;td&gt;This decoration gives some freedom to the author that they should resolve the comment only if the changes end up being minor or trivial.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt; &lt;/p&gt;

&lt;p&gt;For instance, a &lt;code&gt;suggestion&lt;/code&gt; tag signifies a possible improvement proposed by the reviewer, but it isn't obligatory. On the other hand, an &lt;code&gt;issue&lt;/code&gt; tag denotes a problem that needs rectification. &lt;/p&gt;

&lt;p&gt;The &lt;code&gt;non-blocking&lt;/code&gt; tag is used to indicate a comment that should not prevent the code from being merged, but which the author might consider addressing.&lt;br&gt;
 &lt;br&gt;
 &lt;/p&gt;

&lt;h2&gt;
  
  
  How do Conventional Comments Elevate Code Reviews?
&lt;/h2&gt;

&lt;p&gt; &lt;/p&gt;

&lt;h3&gt;
  
  
  1. Improving Clarity in Communication
&lt;/h3&gt;

&lt;p&gt;By standardizing labels and formats, Conventional Comments enhance the clarity of comments, eliminating vague language and misunderstandings, ensuring all participants understand the intent and meaning of the comments.&lt;/p&gt;

&lt;p&gt;For instance, if a reviewer writes: "&lt;code&gt;issue: This function might cause a memory leak.&lt;/code&gt;", the developer immediately recognizes a problem that requires fixing rather than a simple suggestion or consideration.&lt;br&gt;
 &lt;/p&gt;

&lt;h3&gt;
  
  
  2. Providing Structured Feedback
&lt;/h3&gt;

&lt;p&gt;Conventional Comments facilitate a way to organize and structure comments, making code reviews more efficient and aiding developers in understanding and responding to feedback faster.&lt;/p&gt;

&lt;p&gt;For instance, a &lt;code&gt;praise&lt;/code&gt; comment can directly link positive feedback to a specific piece of code, while a &lt;code&gt;thought&lt;/code&gt; comment can propose ideas that might warrant further discussion.&lt;br&gt;
 &lt;/p&gt;

&lt;h3&gt;
  
  
  3. Encouraging Open and Constructive Dialogue
&lt;/h3&gt;

&lt;p&gt;Conventional Comments foster open and constructive conversations. By explicitly labeling the type of comment, developers can better understand the nature and intent of the feedback, leading to increased confidence in participating in the review process.&lt;/p&gt;

&lt;p&gt;For example, a &lt;code&gt;suggestion&lt;/code&gt; comment sparking a deeper discussion could lead to improvements in the code or design and enhance knowledge sharing among the team.&lt;br&gt;
 &lt;br&gt;
 &lt;br&gt;
 &lt;/p&gt;

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

&lt;p&gt;Conventional Comments makes code reviews more effective and productive. &lt;/p&gt;

&lt;p&gt;By adopting this structured commenting approach, development teams can improve clarity in communication, provide more structured feedback, and foster open, constructive conversations.&lt;/p&gt;

&lt;p&gt;Both reviewers and reviewees stand to benefit from the implementation of Conventional Comments. Happy coding🤘!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fa80gmypwk59wbiwyrnjb.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fa80gmypwk59wbiwyrnjb.gif" alt=" " width="480" height="360"&gt;&lt;/a&gt;&lt;/p&gt;

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

&lt;h6&gt;
  
  
  Reference: &lt;a href="https://conventionalcomments.org/" rel="noopener noreferrer"&gt;https://conventionalcomments.org/&lt;/a&gt;
&lt;/h6&gt;

</description>
      <category>codereview</category>
      <category>computerscience</category>
      <category>codequality</category>
      <category>development</category>
    </item>
    <item>
      <title>Exploring HTTP Communication with Refit</title>
      <dc:creator>TSOTSI1</dc:creator>
      <pubDate>Sat, 10 Jun 2023 12:27:23 +0000</pubDate>
      <link>https://dev.to/tsotsi1/delving-deeper-into-http-communication-with-refit-52da</link>
      <guid>https://dev.to/tsotsi1/delving-deeper-into-http-communication-with-refit-52da</guid>
      <description>&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flvywefba3vrgz4j2m78p.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flvywefba3vrgz4j2m78p.jpg" alt=" " width="800" height="600"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Refit is a lightweight, type-safe REST library that empowers .NET developers to create HTTP API clients in a declarative way, reducing redundant code and streamlining your programming process. &lt;/p&gt;

&lt;p&gt;While Refit is highly advantageous for simplifying API client development, it's not without its caveats. &lt;/p&gt;

&lt;p&gt;Understanding both its powerful features and limitations can help developers optimize their use of this tool.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fd97o1lxzfortv711butv.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fd97o1lxzfortv711butv.gif" alt=" " width="1080" height="592"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt; &lt;br&gt;
 &lt;/p&gt;
&lt;h2&gt;
  
  
  Installation and Setup
&lt;/h2&gt;

&lt;p&gt;Refit is easily accessible via the NuGet package manager. You can add it to your project by running the following command:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;Install-Package Refit
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After installation, you're ready to start building your API client.&lt;br&gt;
&lt;br&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  API Interface Definition
&lt;/h2&gt;

&lt;p&gt;With Refit, API endpoints are declared as interfaces. This approach ensures type safety and aligns with best practices of object-oriented programming. For instance, suppose we have a web service that allows managing artists for a music streaming service. We could define the endpoints like this:&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="k"&gt;interface&lt;/span&gt; &lt;span class="nc"&gt;IMusicApi&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nf"&gt;Get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"/artists"&lt;/span&gt;&lt;span class="p"&gt;)]&lt;/span&gt;
    &lt;span class="n"&gt;Task&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;List&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;Artist&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;GetArtists&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

    &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nf"&gt;Get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"/artists/{id}"&lt;/span&gt;&lt;span class="p"&gt;)]&lt;/span&gt;
    &lt;span class="n"&gt;Task&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;Artist&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;GetArtist&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;id&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

    &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nf"&gt;Post&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"/artists"&lt;/span&gt;&lt;span class="p"&gt;)]&lt;/span&gt;
    &lt;span class="n"&gt;Task&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;Artist&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nf"&gt;CreateArtist&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="n"&gt;Body&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="n"&gt;Artist&lt;/span&gt; &lt;span class="n"&gt;artist&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

    &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nf"&gt;Put&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"/artists/{id}"&lt;/span&gt;&lt;span class="p"&gt;)]&lt;/span&gt;
    &lt;span class="n"&gt;Task&lt;/span&gt; &lt;span class="nf"&gt;UpdateArtist&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;id&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;Body&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="n"&gt;Artist&lt;/span&gt; &lt;span class="n"&gt;artist&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

    &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nf"&gt;Delete&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"/artists/{id}"&lt;/span&gt;&lt;span class="p"&gt;)]&lt;/span&gt;
    &lt;span class="n"&gt;Task&lt;/span&gt; &lt;span class="nf"&gt;DeleteArtist&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;id&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 interface, we can perform CRUD operations on Artist objects. Each method corresponds to a specific HTTP verb, and parameters translate to parts of the URL or the request body.&lt;br&gt;
&lt;br&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Refit Implementation
&lt;/h2&gt;

&lt;p&gt;With our API interface in place, we can now let Refit implement it for us. Using the &lt;code&gt;RestService&lt;/code&gt; class, we can construct an instance that provides an implementation of our interface:&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="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;musicApi&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;RestService&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;For&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;IMusicApi&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;(&lt;/span&gt;&lt;span class="s"&gt;"http://api.example.com"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This instance allows us to make HTTP requests, such as retrieving a list of artists:&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="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;artists&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;musicApi&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;GetArtists&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;.NET Core supports registering via HttpClientFactory&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="n"&gt;services&lt;/span&gt;
    &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;AddRefitClient&lt;/span&gt;&lt;span class="p"&gt;&amp;lt;&lt;/span&gt;&lt;span class="n"&gt;IMusicApi&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;()&lt;/span&gt;
    &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;ConfigureHttpClient&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;c&lt;/span&gt; &lt;span class="p"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;c&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;BaseAddress&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nf"&gt;Uri&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"http://api.example.com"&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Behind the scenes, Refit automatically translates these method calls into corresponding HTTP requests, and automatically deserializes the returned JSON into the defined objects.&lt;br&gt;
 &lt;/p&gt;
&lt;h2&gt;
  
  
  Advanced Features: Custom Converters, Authentication and More
&lt;/h2&gt;

&lt;p&gt;Refit offers flexibility in various aspects. You can plug in custom converters if the standard JSON.NET serialization doesn't suit your needs. Similarly, for APIs requiring authentication, Refit allows integrating various authentication methods. You can use &lt;code&gt;HttpClient&lt;/code&gt; message handlers to attach auth tokens to your requests or integrate more complex authentication flows.&lt;br&gt;
 &lt;/p&gt;
&lt;h2&gt;
  
  
  Handling Errors
&lt;/h2&gt;

&lt;p&gt;Refit throws an &lt;code&gt;ApiException&lt;/code&gt; when a response indicates an HTTP error status. This exception provides crucial details like the status code and error content, facilitating error handling and debugging:&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;try&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;artist&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;musicApi&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;GetArtist&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;123&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="k"&gt;catch&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;ApiException&lt;/span&gt; &lt;span class="n"&gt;ex&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;Console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;WriteLine&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;$"An error occurred: &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;ex&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;StatusCode&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt; &lt;/p&gt;

&lt;h2&gt;
  
  
  Limitations of Refit
&lt;/h2&gt;

&lt;p&gt;While Refit is a powerful and convenient tool, it has certain limitations and considerations. First, as Refit is built on top of &lt;code&gt;HttpClient&lt;/code&gt;, it inherits some of HttpClient's limitations. For instance, control over timeouts, authentication, and cookie handling still needs to be implemented by you.&lt;/p&gt;

&lt;p&gt;Moreover, Refit defaults to using JSON.NET as the serialization tool, but this can be configured to use other serialization tools. If you have special serialization requirements, you might need extra configurations.&lt;/p&gt;

&lt;p&gt;Additionally, Refit is most suited for standard RESTful APIs. If your API has non-standard features, such as unique URL structures or request formats, you might need to implement these using other means.&lt;br&gt;
  &lt;/p&gt;

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

&lt;p&gt;Refit is an invaluable tool in the .NET ecosystem, especially for developers working extensively with REST APIs. It encourages cleaner code, enhances productivity, and reduces the likelihood of errors.&lt;/p&gt;

&lt;p&gt;With it, you can focus more on your business logic and less on the nitty-gritty details of HTTP communication.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fd2ebljom3o08gjqclulc.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fd2ebljom3o08gjqclulc.gif" alt=" " width="200" height="200"&gt;&lt;/a&gt;&lt;/p&gt;

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

&lt;p&gt;Thanks for reading, and happy coding🤘!&lt;br&gt;
 &lt;/p&gt;

&lt;h6&gt;
  
  
  Reference: &lt;a href="https://github.com/reactiveui/refit" rel="noopener noreferrer"&gt;https://github.com/reactiveui/refit&lt;/a&gt;
&lt;/h6&gt;

</description>
      <category>dotnet</category>
      <category>csharp</category>
      <category>backend</category>
      <category>api</category>
    </item>
    <item>
      <title>Entity Framework(EF) Enum issue/bug/feature</title>
      <dc:creator>TSOTSI1</dc:creator>
      <pubDate>Mon, 13 Mar 2023 21:05:20 +0000</pubDate>
      <link>https://dev.to/tsotsi1/entity-frameworkef-enum-issuebugfeature-4o65</link>
      <guid>https://dev.to/tsotsi1/entity-frameworkef-enum-issuebugfeature-4o65</guid>
      <description>&lt;p&gt;There is an issue that I have faced before with the Entity Framework (EF) issue/feature for enums. Even though I used &lt;strong&gt;&lt;em&gt;.HasDefaultValue()&lt;/em&gt;&lt;/strong&gt; of EF Core, it still did not work.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxht3k4e49c0ct1rkm2de.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fxht3k4e49c0ct1rkm2de.png" alt=" " width="450" height="364"&gt;&lt;/a&gt;&lt;br&gt;
&lt;br&gt;
&lt;/p&gt;

&lt;p&gt;The issue at hand is as follows:&lt;br&gt;
&lt;a href="https://github.com/dotnet/efcore/issues/15070" rel="noopener noreferrer"&gt;https://github.com/dotnet/efcore/issues/15070&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;When a developer uses an enum as an attribute of a column, the default value will always be the first enum, which is usually 0, and cannot be updated. How can we avoid this issue until the feature is fixed or modified? Here are two possible solutions below.&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Assign specific number(exclude 0) to Enum
&lt;/h3&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="k"&gt;enum&lt;/span&gt; &lt;span class="n"&gt;State&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;Walking&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;Reading&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="m"&gt;2&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;Drinking&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="m"&gt;3&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;Pros: The solution is clear and easy to understand.&lt;/p&gt;

&lt;p&gt;Cons: It requires maintenance, as every individual needs to assign a specific number to the enum value.&lt;br&gt;
&lt;br&gt;
&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Make default value as the first attribute of enum
&lt;/h3&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="k"&gt;enum&lt;/span&gt; &lt;span class="n"&gt;State&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="n"&gt;Walking&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;Reading&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;Drinking&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;Pros: There's no need to assign a number, and the enum remains clean.&lt;/p&gt;

&lt;p&gt;Cons: To prevent someone from modifying the enum without understanding, test cases are needed.&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
&lt;/p&gt;

&lt;h2&gt;
  
  
  Summary
&lt;/h2&gt;

&lt;p&gt;I personally used the approach of making the default value the first attribute of the enum. In my opinion, this is a cleaner approach and it only requires one test case to ensure that the order is not accidentally changed.&lt;/p&gt;

&lt;p&gt;On the other hand, assigning a specific number (excluding 0) to each enum attribute can be a big effort, especially if an enum has over 100 attributes. It can become quite messy.&lt;/p&gt;

&lt;p&gt;Ultimately, it's important to pick one approach to ensure that the data in the database is what you want. Any discussions on this topic are welcome. Thank you!&lt;/p&gt;



</description>
      <category>dotnet</category>
      <category>entityframework</category>
      <category>database</category>
      <category>csharp</category>
    </item>
    <item>
      <title>Naming Things in Program</title>
      <dc:creator>TSOTSI1</dc:creator>
      <pubDate>Sun, 15 Jan 2023 13:36:36 +0000</pubDate>
      <link>https://dev.to/tsotsi1/naming-things-in-program-552p</link>
      <guid>https://dev.to/tsotsi1/naming-things-in-program-552p</guid>
      <description>&lt;h4&gt;
  
  
  &lt;em&gt;There are only two hard things in Computer Science: cache invalidation and naming things.&lt;/em&gt;
&lt;/h4&gt;

&lt;p&gt;&lt;em&gt;-- Phil Karlton&lt;/em&gt;&lt;br&gt;
&lt;br&gt;&lt;/p&gt;

&lt;p&gt;Whether Phil said this quote or not. In my opinion, I totally agree with the naming of things, especially since English ain't my mother language. &lt;/p&gt;

&lt;p&gt;Good naming would let your objects proud to ask: "Say my name", and speak loudly like Mr. White in Breaking Bad. So how to name things? There are some concepts that come below.&lt;br&gt;
&lt;br&gt;&lt;br&gt;
&lt;br&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  1. Don't abbreviate names
&lt;/h2&gt;

&lt;p&gt;There is a classic example, you shouldn't name variables with a single letter. That won't tell you anything about the variables, for instance.&lt;/p&gt;

&lt;p&gt;❌ int y = 3;&lt;br&gt;
✅ int seconds = 3;&lt;br&gt;
&lt;br&gt;&lt;/p&gt;

&lt;p&gt;For class or function naming, abbreviating will easily make your team member or other developers who can't realize it at first sight, even yourself(After a few days you are back to check your code). See these instances below.&lt;/p&gt;

&lt;p&gt;❌ abbreviate&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="n"&gt;Public&lt;/span&gt; &lt;span class="k"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;MoveOnPg&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;✅ not abbreviate&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="n"&gt;Public&lt;/span&gt; &lt;span class="k"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;MoveOnPage&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;




&lt;h2&gt;
  
  
  2. Don't put types in variable names
&lt;/h2&gt;

&lt;p&gt;Many books before usually recommend putting the type in the prefix of the variable, but now with statically type languages, we don't need to do that.&lt;/p&gt;

&lt;p&gt;❌ type variable&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="kt"&gt;bool&lt;/span&gt; &lt;span class="n"&gt;bIsValid&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="n"&gt;int32_t&lt;/span&gt; &lt;span class="n"&gt;iCount&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="n"&gt;uint32_t&lt;/span&gt; &lt;span class="n"&gt;uNumUsers&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;✅ variable&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="kt"&gt;bool&lt;/span&gt; &lt;span class="n"&gt;IsValid&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="n"&gt;int32_t&lt;/span&gt; &lt;span class="n"&gt;Count&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="n"&gt;uint32_t&lt;/span&gt; &lt;span class="n"&gt;NumUsers&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;




&lt;h2&gt;
  
  
  3. Add units to variables unless the type tells you
&lt;/h2&gt;

&lt;p&gt;The parameters of the function, adding units are clear to whom to use it.&lt;/p&gt;

&lt;p&gt;❌ not type variable&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;void&lt;/span&gt; &lt;span class="nf"&gt;progress&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;overdue&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;✅ type variable&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;void&lt;/span&gt; &lt;span class="nf"&gt;progress&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;overdueSeconds&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Further, we can add the type instead for this case in C#, and here getting seconds.&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;void&lt;/span&gt; &lt;span class="nf"&gt;progress&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;TimeSpan&lt;/span&gt; &lt;span class="n"&gt;overdue&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
     &lt;span class="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;seconds&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;overdue&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;TotalSeconds&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;h2&gt;
  
  
  4. Don't put types in your types
&lt;/h2&gt;

&lt;p&gt;There is very common to see people to put types in the types, in particular the pattern in C#, for instance, adding the prefix in interface with "I".&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="k"&gt;interface&lt;/span&gt; &lt;span class="nc"&gt;IService&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;Configure&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;IConfiguration&lt;/span&gt; &lt;span class="n"&gt;configuration&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;Most of the time people don't care about whether it's an interface, class, or abstract class, they just want to know what they can use, Absolutely, for C# developers it quite makes sense to follow the pattern, since everyone does that, but for other languages, we shall avoid to do it.&lt;/p&gt;

&lt;p&gt;Another example is AbstractX, BaseX&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;class&lt;/span&gt; &lt;span class="nc"&gt;Car&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;BaseCar&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;private&lt;/span&gt; &lt;span class="k"&gt;const&lt;/span&gt; &lt;span class="kt"&gt;double&lt;/span&gt; &lt;span class="n"&gt;power&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="m"&gt;225&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;private&lt;/span&gt; &lt;span class="k"&gt;const&lt;/span&gt; &lt;span class="kt"&gt;double&lt;/span&gt; &lt;span class="n"&gt;acceleration&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="m"&gt;6.1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="nf"&gt;Car&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt; &lt;span class="k"&gt;base&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;power&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;acceleration&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="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It's good to rename the "BaseCar" to "Vehicle", and   we can also make the child vehicle become a especific vehicle: Sedan.&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;class&lt;/span&gt; &lt;span class="nc"&gt;Sedan&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;Vehicle&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;private&lt;/span&gt; &lt;span class="k"&gt;const&lt;/span&gt; &lt;span class="kt"&gt;double&lt;/span&gt; &lt;span class="n"&gt;power&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="m"&gt;225&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="k"&gt;private&lt;/span&gt; &lt;span class="k"&gt;const&lt;/span&gt; &lt;span class="kt"&gt;double&lt;/span&gt; &lt;span class="n"&gt;acceleration&lt;/span&gt;&lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="m"&gt;6.1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="nf"&gt;Sedan&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt; &lt;span class="k"&gt;base&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;power&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;acceleration&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="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;




&lt;h2&gt;
  
  
  5. Refactor if you find yourself naming code "Utils" or "Utilities"
&lt;/h2&gt;

&lt;p&gt;The class "Utils" or "Utilities", isn't a good name to make customers understand what this class can do, until they dig inside, see below.&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="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Utils&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;number&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="nf"&gt;Utils&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="k"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="nf"&gt;sum&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;number1&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;number2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;number&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;number1&lt;/span&gt; &lt;span class="p"&gt;+&lt;/span&gt; &lt;span class="n"&gt;number2&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="n"&gt;number&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;Actually, we don't need this "Utils" class, for the functional we can move this out, and create a sum class instead.&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="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Sum&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;private&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;result&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;int&lt;/span&gt; &lt;span class="n"&gt;Result&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
       &lt;span class="k"&gt;get&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
           &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="n"&gt;result&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="k"&gt;public&lt;/span&gt; &lt;span class="nf"&gt;Sum&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;firstNumber&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;result&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;firstNumber&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="k"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;Add&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;number&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;result&lt;/span&gt; &lt;span class="p"&gt;+=&lt;/span&gt; &lt;span class="n"&gt;number&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When you find there is class naming like this, rename it, or refactor it, hence, don't name code "Utils".&lt;br&gt;
&lt;br&gt;&lt;/p&gt;

&lt;p&gt;After reference these concepts, I'd like to say 😎&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fs9msbwhuf2skzlys1mwd.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fs9msbwhuf2skzlys1mwd.gif" alt=" " width="480" height="270"&gt;&lt;/a&gt;&lt;br&gt;
&lt;br&gt;&lt;/p&gt;

&lt;p&gt;Thanks for reading, and happy coding🤘!&lt;br&gt;
&lt;br&gt;&lt;br&gt;
&lt;br&gt;&lt;/p&gt;

&lt;h6&gt;
  
  
  Reference: &lt;a href="https://youtu.be/-J3wNP6u5YU" rel="noopener noreferrer"&gt;https://youtu.be/-J3wNP6u5YU&lt;/a&gt;
&lt;/h6&gt;

</description>
      <category>programming</category>
      <category>computerscience</category>
      <category>cleancode</category>
      <category>codequality</category>
    </item>
    <item>
      <title>Dotnet, C#, code format on JetBrain IDE Rider</title>
      <dc:creator>TSOTSI1</dc:creator>
      <pubDate>Fri, 13 Jan 2023 04:25:54 +0000</pubDate>
      <link>https://dev.to/tsotsi1/dotnet-c-code-format-on-jetbrain-ide-rider-504i</link>
      <guid>https://dev.to/tsotsi1/dotnet-c-code-format-on-jetbrain-ide-rider-504i</guid>
      <description>&lt;p&gt;Code review is an unavoidable topic at work for developers. Coding style aside, if the code format is different, that would add difficulty to the code review.&lt;/p&gt;

&lt;p&gt;Since then, this article has been about the basic code format for everyone in the same team, which can go through different IDE and platforms. Especially for Jetbrain IDE of C#, Rider. (If anyone is interested in VSCode, we can talk about it later).&lt;/p&gt;

&lt;p&gt;Here, I'd like to combine &lt;strong&gt;&lt;em&gt;CSharpier&lt;/em&gt;&lt;/strong&gt; and &lt;strong&gt;&lt;em&gt;Dotnet format&lt;/em&gt;&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Let's get started!&lt;br&gt;
&lt;br&gt;&lt;br&gt;
&lt;br&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  &lt;strong&gt;&lt;a href="https://github.com/belav/csharpier" rel="noopener noreferrer"&gt;CSharpier&lt;/a&gt;&lt;/strong&gt;
&lt;/h2&gt;
&lt;h3&gt;
  
  
  What is CSharpier?
&lt;/h3&gt;

&lt;p&gt;CSharpier is an opinionated code formatter for c#. It uses &lt;a href="https://github.com/dotnet/roslyn" rel="noopener noreferrer"&gt;Roslyn&lt;/a&gt; to parse your code and re-prints it using its own rules. The printing process was ported from prettier but has evolved over time. &lt;br&gt;
&lt;br&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  &lt;strong&gt;Quick Start&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Install CSharpier globally using the following command.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;dotnet tool install csharpier -g
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then format the contents of a directory and its children with the following command.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;dotnet csharpier .
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://plugins.jetbrains.com/plugin/18243-csharpier" rel="noopener noreferrer"&gt;CSharpier on Rider Plugin&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Steps:&lt;br&gt;
Open Settings -&amp;gt; Plugins -&amp;gt; Search "CSharpier" &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fg444npvk21e7mfp49t4l.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fg444npvk21e7mfp49t4l.png" alt=" " width="800" height="596"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;After installation, please "On Save" is turned on.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2bugmyqwfmx4spif2yg6.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F2bugmyqwfmx4spif2yg6.png" alt=" " width="800" height="593"&gt;&lt;/a&gt;&lt;br&gt;
&lt;br&gt;&lt;br&gt;
&lt;br&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  &lt;strong&gt;&lt;a href="https://github.com/dotnet/format" rel="noopener noreferrer"&gt;Dotnet Format&lt;/a&gt;&lt;/strong&gt;
&lt;/h2&gt;


&lt;h3&gt;
  
  
  What is Dotnet Format?
&lt;/h3&gt;

&lt;p&gt;dotnet-format is a code formatter for dotnet that applies style preferences to a project or solution. Preferences will be read from an .editorconfig file, if present, otherwise a default set of preferences will be used. At this time dotnet-format is able to format C# and Visual Basic projects with a subset of &lt;a href="https://github.com/dotnet/format/blob/main/docs/Supported-.editorconfig-options.md" rel="noopener noreferrer"&gt;supported .editorconfig options. &lt;/a&gt; &lt;br&gt;
&lt;br&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  &lt;strong&gt;Quick Start&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Install dotnet format&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;dotnet tool install -g dotnet-format
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Steps:&lt;/p&gt;

&lt;p&gt;1.Open Settings -&amp;gt; Tools -&amp;gt; File Watchers&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9yclap2qqy8eowet9klj.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F9yclap2qqy8eowet9klj.png" alt=" " width="800" height="590"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;2.Press The “Plus Sign” to Add a Custom watcher&lt;br&gt;
   Set the name to “dotnet format on save”&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;FileType: C#&lt;/li&gt;
&lt;li&gt;Scope: Open Files&lt;/li&gt;
&lt;li&gt;Program: Write dotnet-format&lt;/li&gt;
&lt;li&gt;Arguments: $SolutionPath$ -verbosity diagnostic--include $FileRelativePath$

&lt;ul&gt;
&lt;li&gt;Append --fix-style warning to fix any style issues automatically on save.&lt;/li&gt;
&lt;li&gt;Append --fix-analyzers warning to fix any analyzer warnings on save.

&lt;ul&gt;
&lt;li&gt;Advanced (Options)&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;Disabled all advanced option checkboxes.

&lt;ul&gt;
&lt;li&gt;All other values were left default&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;/li&gt;

&lt;/ul&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fl0e7go17e79n3hmc5bme.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fl0e7go17e79n3hmc5bme.png" alt=" " width="762" height="640"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;3.Press Ok, and Save Settings.&lt;br&gt;
&lt;br&gt;&lt;br&gt;
&lt;br&gt;&lt;/p&gt;

&lt;p&gt;That's it!&lt;br&gt;
Any feedback is welcome. Happy Coding 🤘!&lt;br&gt;
&lt;br&gt;&lt;br&gt;
&lt;br&gt;&lt;/p&gt;

&lt;h6&gt; Dotnet Format setup reference:&lt;/h6&gt;

&lt;p&gt;&lt;a href="https://strepto.github.io/Pause/blog/dotnet-format-rider" rel="noopener noreferrer"&gt;https://strepto.github.io/Pause/blog/dotnet-format-rider&lt;/a&gt;&lt;/p&gt;

</description>
      <category>welcome</category>
      <category>fullstack</category>
      <category>ai</category>
      <category>marketing</category>
    </item>
  </channel>
</rss>
