<?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: Phil the Dev</title>
    <description>The latest articles on DEV Community by Phil the Dev (@philip-ainberger).</description>
    <link>https://dev.to/philip-ainberger</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%2F1099873%2Fde06d547-b48d-446b-ad14-a6f0ca37f46d.png</url>
      <title>DEV Community: Phil the Dev</title>
      <link>https://dev.to/philip-ainberger</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/philip-ainberger"/>
    <language>en</language>
    <item>
      <title>Understanding JWTs: A Simple Guide for Beginners</title>
      <dc:creator>Phil the Dev</dc:creator>
      <pubDate>Wed, 05 Jul 2023 15:40:59 +0000</pubDate>
      <link>https://dev.to/philip-ainberger/understanding-jwts-a-simple-guide-for-beginners-aba</link>
      <guid>https://dev.to/philip-ainberger/understanding-jwts-a-simple-guide-for-beginners-aba</guid>
      <description>&lt;h2&gt;
  
  
  What is a JWT?
&lt;/h2&gt;

&lt;p&gt;JWT, short for JSON Web Tokens, is a compact, URL-safe way of representing claims (information) to be transferred between two parties, the client and server. Think of it like a secret message in the form of a cryptographically signed note, which can only be understood by the intended recipient.&lt;/p&gt;

&lt;h2&gt;
  
  
  Structure of a JWT
&lt;/h2&gt;

&lt;p&gt;A JWT has three distinct parts, each separated by a dot (.):&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Header:&lt;/strong&gt; It contains metadata about the token and the cryptographic algorithm used, usually HMAC SHA256 or RSA.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Payload:&lt;/strong&gt; The actual data that the token carries is stored here. It's also known as the 'claims' and can include data like user details and additional metadata.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Signature:&lt;/strong&gt; The signature is a cryptographically secured proof that verifies the sender and ensures the message wasn't altered during transit.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&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%2Fuploads%2Farticles%2F94cai6lqmj2hoxnewc2o.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%2Fuploads%2Farticles%2F94cai6lqmj2hoxnewc2o.png" alt="Structure of a JWT"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  How Does a JWT Work?
&lt;/h2&gt;

&lt;p&gt;Here's the play-by-play of JWT in action:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;A client logs in using their credentials, sending a request to the server.&lt;/li&gt;
&lt;li&gt;The server verifies these credentials. If they're valid, the server generates a JWT and sends it back to the client.&lt;/li&gt;
&lt;li&gt;The client stores the JWT, usually in local storage, and includes it in every subsequent HTTP request's header.&lt;/li&gt;
&lt;li&gt;The server, upon receiving these requests, verifies the JWT. If it's valid, the client is authenticated and authorized.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Why Use JWT?
&lt;/h2&gt;

&lt;p&gt;JWTs are universal - any programming language can generate a JWT because they're essentially JSON. Also, they facilitate maintaining session state on the client, reducing server load, which is more scalable.&lt;/p&gt;

&lt;h2&gt;
  
  
  Security Considerations
&lt;/h2&gt;

&lt;p&gt;While JWTs are handy, they do come with some vulnerabilities:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Token Theft:&lt;/strong&gt; JWTs are stored on the client-side, and hence can be stolen. Always ensure your transmission is secure, preferably via HTTPS.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;No In-built Invalidity Mechanism:&lt;/strong&gt; JWTs can't be invalidated individually or in a group from a user, due to their stateless nature.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Token Size:&lt;/strong&gt; Storing too much data in a JWT can make it heavy, affecting network performance.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Algorithm Vulnerabilities:&lt;/strong&gt; Some algorithms in the JWT header are vulnerable to attacks. Always use secure and updated algorithms, and treat your signing keys like secrets.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;In conclusion, JWTs are a potent tool in web development, providing stateless, secure, and scalable communication. Remember, how effectively you wield JWTs in your application depends on your specific needs and the level of security you require.&lt;/p&gt;

&lt;p&gt;I hope this gives you a better understanding of JWTs! Feel free to share your thoughts 😄&lt;/p&gt;

</description>
      <category>programming</category>
      <category>webdev</category>
      <category>beginners</category>
      <category>security</category>
    </item>
    <item>
      <title>Understand OAuth in 3 minutes</title>
      <dc:creator>Phil the Dev</dc:creator>
      <pubDate>Mon, 03 Jul 2023 15:40:45 +0000</pubDate>
      <link>https://dev.to/philip-ainberger/understand-oauth-in-3-minutes-ham</link>
      <guid>https://dev.to/philip-ainberger/understand-oauth-in-3-minutes-ham</guid>
      <description>&lt;p&gt;The term OAuth is likely a term on every developer's mind. But how do you break down this concept to someone just starting their coding journey, or even to someone who isn't involved in development at all? Here's my attempt to explain it 😄&lt;/p&gt;

&lt;h2&gt;
  
  
  What is OAuth?
&lt;/h2&gt;

&lt;p&gt;OAuth, which stands for Open Authorization, is a standard protocol that allows third-party applications to access user data without exposing their password. Imagine using your university ID to check out a library book. You're not giving the librarian your login details, just proof that you're a student. The librarian doesn't see your grades or tuition details, just confirms you're allowed to borrow books.&lt;/p&gt;

&lt;h2&gt;
  
  
  How Does OAuth Work?
&lt;/h2&gt;

&lt;p&gt;Think of when you log into a new app, and it asks if you want to log in using your Google account. Once you click 'yes', you're redirected to a Google sign-in page. Here's where OAuth comes into play.&lt;/p&gt;

&lt;p&gt;You input your Google credentials (this is authentication, proving who you are), but instead of giving these credentials back to the original app, Google sends back a token. This token is like a temporary key, giving the app permission to access specific information from your Google account for a set amount of time.&lt;/p&gt;

&lt;p&gt;For a visual explanation I've found the following diagram particularly helpful:&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%2Fuploads%2Farticles%2Fqsyjvzbfezdpn63r5vkl.jpg" 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%2Fuploads%2Farticles%2Fqsyjvzbfezdpn63r5vkl.jpg" alt="OAuth visualization"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Why is OAuth Important?
&lt;/h2&gt;

&lt;p&gt;OAuth plays an essential role in enhancing user experience and security. By using OAuth, users don't have to remember another set of credentials, and the application doesn't have to manage secure storage of user passwords. Plus, users can control which information they want to share and can revoke access at any time.&lt;/p&gt;

&lt;h2&gt;
  
  
  OAuth in a Nutshell
&lt;/h2&gt;

&lt;p&gt;To put it simply, OAuth is like a digital passport. In the realm of web security, it serves as a safe and efficient way to give applications the ability to communicate with each other using tokens, instead of sharing sensitive information, like passwords.&lt;/p&gt;

&lt;p&gt;Remember, OAuth isn't about gaining access but about giving limited access to third-party services without exposing user credentials. It's like giving the keys to your car but not your house!&lt;/p&gt;

&lt;h2&gt;
  
  
  Summing Up
&lt;/h2&gt;

&lt;p&gt;Grasping the concept of OAuth is crucial in the modern landscape of web development and security. It's all about protecting user data while providing the flexibility of interconnected services. By understanding and implementing OAuth, we can offer a secure and streamlined user experience.&lt;/p&gt;

&lt;p&gt;As with any security strategy, the way you implement OAuth will depend on your specific application's needs and the level of security it requires. &lt;/p&gt;

&lt;p&gt;As always you are welcome to share your thoughts 😄&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>beginners</category>
      <category>programming</category>
      <category>codenewbie</category>
    </item>
    <item>
      <title>SOLID Principles: A Quick Guide (.NET examples)</title>
      <dc:creator>Phil the Dev</dc:creator>
      <pubDate>Wed, 28 Jun 2023 18:35:53 +0000</pubDate>
      <link>https://dev.to/philip-ainberger/solid-principles-a-quick-guide-net-examples-lia</link>
      <guid>https://dev.to/philip-ainberger/solid-principles-a-quick-guide-net-examples-lia</guid>
      <description>&lt;p&gt;Recently, I was thinking about some topics for a short and knowledge-refreshing article. One subject that I rarely hear being talked about, but is really important in software development, are the SOLID principles. For a lot of experienced developers, these "rules" may seem pretty clear, yet I often come across code changes that don't follow these principles. Sometimes, I even find some that I've made myself, so no disrespect intended.&lt;/p&gt;

&lt;p&gt;To enhance the value of this article, I've included some basic explanations and examples in C#&lt;/p&gt;

&lt;h2&gt;
  
  
  Single Responsibility Principle (SRP)
&lt;/h2&gt;

&lt;p&gt;Each class should have one, and only one, reason to change. This means a class should only have one job.&lt;/p&gt;

&lt;p&gt;Example:&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;Order&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;CalculateTotalSum&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="cm"&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;GetItems&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="cm"&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;PrintOrder&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="cm"&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;ShowOrder&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="cm"&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;This Order class violates SRP because it has more than one responsibility. A better approach is to split this into several classes, each handling a single concern.&lt;/p&gt;




&lt;h2&gt;
  
  
  Open-Closed Principle (OCP)
&lt;/h2&gt;

&lt;p&gt;Software entities should be open for extension but closed for modification. This encourages stability while allowing system growth.&lt;/p&gt;

&lt;p&gt;Example:&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;Rectangle&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;double&lt;/span&gt; &lt;span class="n"&gt;Height&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;set&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;double&lt;/span&gt; &lt;span class="n"&gt;Width&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;set&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="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;AreaCalculator&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;double&lt;/span&gt; &lt;span class="nf"&gt;TotalArea&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Rectangle&lt;/span&gt;&lt;span class="p"&gt;[]&lt;/span&gt; &lt;span class="n"&gt;arrRectangles&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="kt"&gt;double&lt;/span&gt; &lt;span class="n"&gt;area&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="k"&gt;foreach&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;objRectangle&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;arrRectangles&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="n"&gt;area&lt;/span&gt; &lt;span class="p"&gt;+=&lt;/span&gt; &lt;span class="n"&gt;objRectangle&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Height&lt;/span&gt; &lt;span class="p"&gt;*&lt;/span&gt; &lt;span class="n"&gt;objRectangle&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Width&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;area&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;In this example, if we want to add a new shape, we'd have to modify the AreaCalculator class, which violates OCP.&lt;/p&gt;




&lt;h2&gt;
  
  
  Liskov Substitution Principle (LSP)
&lt;/h2&gt;

&lt;p&gt;This principle insists that subclasses must be substitutable for their base classes without affecting functionality.&lt;/p&gt;

&lt;p&gt;Example:&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;Vehicle&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;virtual&lt;/span&gt; &lt;span class="k"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;StartEngine&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="cm"&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="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;ElectricCar&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;public&lt;/span&gt; &lt;span class="k"&gt;override&lt;/span&gt; &lt;span class="k"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;StartEngine&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="cm"&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="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Bicycle&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;public&lt;/span&gt; &lt;span class="k"&gt;override&lt;/span&gt; &lt;span class="k"&gt;void&lt;/span&gt; &lt;span class="nf"&gt;StartEngine&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="cm"&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;Here, a Bicycle doesn't have an engine to start, so substituting a Vehicle with a Bicycle would cause issues, thus violating LSP. A better approach would be to have a separate class for vehicles with engines.&lt;/p&gt;




&lt;h2&gt;
  
  
  Interface Segregation Principle (ISP)
&lt;/h2&gt;

&lt;p&gt;No client should be forced to depend on interfaces they do not use.&lt;/p&gt;

&lt;p&gt;Example&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;IWorker&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;Work&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;Eat&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;Here, if a robot implements IWorker, the Eat method is useless. This violates ISP. It's better to break this into two interfaces: IWorker and IEater.&lt;/p&gt;




&lt;h2&gt;
  
  
  Dependency Inversion Principle (DIP)
&lt;/h2&gt;

&lt;p&gt;High-level modules should not depend on low-level modules, but both should depend on abstractions. This reduces tight coupling.&lt;/p&gt;

&lt;p&gt;Example:&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;Email&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;SendEmail&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="cm"&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="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Notification&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;private&lt;/span&gt; &lt;span class="n"&gt;Email&lt;/span&gt; &lt;span class="n"&gt;_email&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;Notification&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;_email&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;Email&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;here, the Notification class is tightly coupled with the Email class. Using DIP, we can introduce an interface to decouple them.&lt;/p&gt;




&lt;p&gt;Despite their importance in writing maintainable and scalable code, these principles are frequently overlooked. For me it was a short, simple and much needed refresher. Hopefully for any other reader too 😀&lt;br&gt;
Feel free to comment your thoughts&lt;/p&gt;

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

</description>
      <category>programming</category>
      <category>tutorial</category>
      <category>architecture</category>
      <category>beginners</category>
    </item>
    <item>
      <title>The Art of Code Commenting</title>
      <dc:creator>Phil the Dev</dc:creator>
      <pubDate>Sun, 25 Jun 2023 18:21:12 +0000</pubDate>
      <link>https://dev.to/philip-ainberger/the-art-of-code-commenting-3m7i</link>
      <guid>https://dev.to/philip-ainberger/the-art-of-code-commenting-3m7i</guid>
      <description>&lt;p&gt;Lately, I've been reflecting a lot on my process of documenting and teaching my code to others. As a young dev 😅, I'm always looking for ways to improve. One thing I've noticed in my past work is that the code commentary often wasn't optimal. Let me tell you, returning to a project that I haven't touched for almost two years and finding only 10 comments across the entire project is hellish. So, I hope you can learn something from this article and my thoughts.&lt;/p&gt;

&lt;p&gt;Also, make sure to keep an eye out for my upcoming article specifically focusing on &lt;strong&gt;the art of code commenting in &lt;u&gt;.NET&lt;/u&gt;&lt;/strong&gt;. You won't want to miss it! Be sure to follow me to stay up-to-date with all my latest insights and articles.&lt;/p&gt;




&lt;p&gt;Comments in code are akin to leaving notes to your future self and to others who might work on the code. Why did I write this piece of code in a certain way? Why did I not choose an alternate approach? Code, by its nature, tells you "how", comments should ideally tell you "why". This is a philosophy I've come to appreciate over the years.&lt;/p&gt;

&lt;p&gt;So based on my reflection and my past experience I think the following practices are making a lot of sense. At least to me 😅&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Comment the Why, not the What:&lt;/strong&gt; I strive to write code that is self-explanatory in terms of what it does. My comments are then dedicated to providing context, explaining my decisions, or highlighting any non-obvious aspect of the code.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Keep Comments Relevant:&lt;/strong&gt; One of the things I've learned the hard way is that outdated or incorrect comments can be worse than no comments. So, every time I update my code, I make it a point to update relevant comments as well.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Avoid Redundant Comments:&lt;/strong&gt; As tempting as it might be to comment everything, I avoid commenting on the obvious. I believe that if my code is clean and clear, it should largely speak for itself.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Use XML Documentation Comments:&lt;/strong&gt; I find XML documentation comments an excellent tool to provide information about my code's classes, methods, properties, etc. Not only do they help generate a separate XML file, but they also provide IntelliSense documentation in the Visual Studio code editor, making life easier for me and my team.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Commented-Out Code:&lt;/strong&gt; Early on, I used to leave commented-out code in my source files, but soon I realized that it creates unnecessary clutter. I've come to rely on source control for remembering old code instead.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In the end, I would say that code commenting is truly an art form. When done right, it can greatly enhance the understandability of your codebase and improve productivity for both yourself and others. And always remember, your comments are a reflection of your thought process, so strive to make them as clear as possible. &lt;/p&gt;




&lt;p&gt;I'm sure there are many more insights to be gathered from the vast community of developers out there. So, I encourage you all to share your thoughts and practices you've used over the years in the comments section. Let's learn from each other!&lt;/p&gt;

&lt;p&gt;Enjoy coding 😄&lt;/p&gt;

</description>
      <category>programming</category>
      <category>productivity</category>
      <category>beginners</category>
      <category>discuss</category>
    </item>
    <item>
      <title>Beyond 200, 404, and 500: Exploring Lesser-Known HTTP Status Codes</title>
      <dc:creator>Phil the Dev</dc:creator>
      <pubDate>Fri, 23 Jun 2023 17:15:46 +0000</pubDate>
      <link>https://dev.to/philip-ainberger/beyond-200-404-and-500-exploring-lesser-known-http-status-codes-2hfd</link>
      <guid>https://dev.to/philip-ainberger/beyond-200-404-and-500-exploring-lesser-known-http-status-codes-2hfd</guid>
      <description>&lt;p&gt;Recently, while troubleshooting an issue with a third-party API, I came across an HTTP status code that I hadn't seen in a while. Beyond the commonly seen 200 (OK), 404 (Not Found), or 500 (Internal Server Error), this was one of the lesser-known ones and it got me interested. So, I decided to look into other articles about uncommon status codes. In this article, I'd like to share some of these that I haven't used a lot myself.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;202 (Accepted):&lt;/strong&gt; Indicates that a request has been received and understood but is not immediately acted upon, typically useful for asynchronous tasks.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;204 (No Content):&lt;/strong&gt; Often used in DELETE operations, this status code denotes a successful request that doesn't require a further response.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;205 (Reset Content):&lt;/strong&gt; Instructs the client to reset its document view, potentially useful when resetting a user interface.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;206 (Partial Content):&lt;/strong&gt; If only part of the resource is sent, following a range header from the client, this status code is employed, typically useful for handling large files.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;207 (Multi-Status):&lt;/strong&gt; This is leveraged to provide multiple independent responses for a single request, primarily utilized in Web Distributed Authoring and Versioning (WebDAV).&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;226 (IM Used):&lt;/strong&gt; This status code indicates that the server has fulfilled a GET request for the resource, and the response is a representation of the result of one or more instance-manipulations applied to the current instance. It's useful when the client has applied a series of range requests, with the 226 status code indicating that the entire set has been fulfilled.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;301 (Moved Permanently):&lt;/strong&gt; Announces that a resource's URL has permanently changed, proving essential during URL restructuring or website migration.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;304 (Not Modified):&lt;/strong&gt; A boon for efficient caching, this status code informs the client that the cached version of the response is still valid.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;307 (Temporary Redirect):&lt;/strong&gt; Indicates a temporary relocation of the resource, suggesting clients to continue using the original URL for future requests.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;409 (Conflict):&lt;/strong&gt; Signifies a conflict in request parameters, such as simultaneous updates on a single resource from different clients.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;418 (I'm a teapot):&lt;/strong&gt; While a humorous Easter egg from 1998, it's used by some APIs for rate limiting.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;422 (Unprocessable Entity):&lt;/strong&gt; Indicates that the server can't process the request, despite understanding its syntax, commonly encountered in RESTful APIs and WebDAV.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;429 (Too Many Requests):&lt;/strong&gt; This status code is used to implement rate limiting, thereby preventing potential server overload.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;451 (Unavailable For Legal Reasons):&lt;/strong&gt; Servers resort to this status code to deny access to resources due to legal demands.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These are just a few of the numerous status codes defined in HTTP. However, not all of them make their way into everyday use, while others remain hidden in specific scenarios or API documentation. If you've come across an unusual status code in your development journey or have a particular one that you find intriguing, I would love to hear about it. Please share your experiences in the comments.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>programming</category>
      <category>api</category>
      <category>discuss</category>
    </item>
    <item>
      <title>Authentication vs. Authorization</title>
      <dc:creator>Phil the Dev</dc:creator>
      <pubDate>Tue, 20 Jun 2023 19:06:41 +0000</pubDate>
      <link>https://dev.to/philip-ainberger/authentication-vs-authorization-olf</link>
      <guid>https://dev.to/philip-ainberger/authentication-vs-authorization-olf</guid>
      <description>&lt;p&gt;When building web applications, there are two key security terms you need to know - Authentication and Authorization. They may seem similar, but they have different roles in ensuring the security of an application. Let's simplify these concepts a bit.&lt;/p&gt;

&lt;h2&gt;
  
  
  Authentication
&lt;/h2&gt;

&lt;p&gt;Authentication is all about proving who you are to the system. It is the process of validating a user's identity. It could be a user, a login, or a session. The system checks if the person is genuinely who they claim to be. This is often done using a username and password, but it could also involve more advanced methods like biometric scans or two-factor authentication.&lt;/p&gt;

&lt;p&gt;Imagine logging into a website. You enter your username and password, and the website checks if they match what it has on record. If it's a match, you're authenticated. You've successfully proved your identity to the system.&lt;/p&gt;

&lt;h2&gt;
  
  
  Authorization
&lt;/h2&gt;

&lt;p&gt;After the system knows who you are (thanks to authentication), it needs to know what you can do within it. This is where authorization comes into play. Authorization is all about permissions - it determines what actions you can take or what resources you can access in the system.&lt;/p&gt;

&lt;p&gt;Think about using a computer where you're not the admin. You can do some things (like creating a document), but not others (like installing new software). That's an example of authorization at work.&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%2Fuploads%2Farticles%2Fzn4vv2eb4ywkkkmpa0am.jpg" 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%2Fuploads%2Farticles%2Fzn4vv2eb4ywkkkmpa0am.jpg" alt="Visualization of both processes together"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  The Core Difference
&lt;/h2&gt;

&lt;p&gt;In simple terms, &lt;strong&gt;authentication is about proving who you are&lt;/strong&gt;, while &lt;strong&gt;authorization is about what you can do in the system&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Think about it this way: Authentication is like unlocking and entering your house with a key. Authorization is like knowing which rooms you're allowed to go into once you're inside.&lt;/p&gt;




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

&lt;p&gt;Both authentication and authorization are important for web security. If a system doesn't manage these well, it's like leaving your front door wide open - not a good idea!&lt;/p&gt;

&lt;p&gt;How you use these processes depends on your application's needs, the tools you're using, and how secure you want it to be. You could use something like JSON Web Tokens (JWT) to manage both processes, or OAuth if you want to let third parties have access without exposing user credentials.&lt;/p&gt;

&lt;p&gt;In summary, knowing the difference between authentication and authorization is important for building secure web applications. They're two different concepts, but both are key parts of web security.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>programming</category>
      <category>auth</category>
    </item>
  </channel>
</rss>
