<?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: Ahmed Omeiza</title>
    <description>The latest articles on DEV Community by Ahmed Omeiza (@omeiza_ahmed).</description>
    <link>https://dev.to/omeiza_ahmed</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.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F3393350%2F879b446b-2d46-411c-9fbb-1bed737b48fc.png</url>
      <title>DEV Community: Ahmed Omeiza</title>
      <link>https://dev.to/omeiza_ahmed</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/omeiza_ahmed"/>
    <language>en</language>
    <item>
      <title>Docker Compose: Run Your App and Its Dependencies Together</title>
      <dc:creator>Ahmed Omeiza</dc:creator>
      <pubDate>Mon, 02 Nov 2026 14:19:16 +0000</pubDate>
      <link>https://dev.to/omeiza_ahmed/docker-compose-run-your-app-and-its-dependencies-together-1gdp</link>
      <guid>https://dev.to/omeiza_ahmed/docker-compose-run-your-app-and-its-dependencies-together-1gdp</guid>
      <description>&lt;p&gt;A backend that works on one developer’s machine can still fail on another because its database, cache, or environment variables are configured differently. Docker Compose helps make that setup repeatable by describing the parts of an application stack in one YAML file.&lt;/p&gt;

&lt;h2&gt;
  
  
  Define the stack once
&lt;/h2&gt;

&lt;p&gt;A Compose file describes services—usually containers—and how they connect. It can also configure ports, environment variables, networks, and persistent volumes. Docker Compose reads that file and starts the services together.&lt;/p&gt;

&lt;p&gt;For a small ASP.NET Core API backed by PostgreSQL, a local &lt;code&gt;compose.yaml&lt;/code&gt; might look like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight yaml"&gt;&lt;code&gt;&lt;span class="na"&gt;services&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;api&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;build&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;.&lt;/span&gt;
    &lt;span class="na"&gt;ports&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;8080:8080"&lt;/span&gt;
    &lt;span class="na"&gt;environment&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;ASPNETCORE_URLS&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;http://+:8080&lt;/span&gt;
      &lt;span class="na"&gt;ConnectionStrings__DefaultConnection&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;Host=db;Port=5432;Database=appdb;Username=appuser;Password=devpassword&lt;/span&gt;
    &lt;span class="na"&gt;depends_on&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;db&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
        &lt;span class="na"&gt;condition&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;service_healthy&lt;/span&gt;

  &lt;span class="na"&gt;db&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
    &lt;span class="na"&gt;image&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;postgres:17&lt;/span&gt;
    &lt;span class="na"&gt;environment&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;POSTGRES_DB&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;appdb&lt;/span&gt;
      &lt;span class="na"&gt;POSTGRES_USER&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;appuser&lt;/span&gt;
      &lt;span class="na"&gt;POSTGRES_PASSWORD&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;devpassword&lt;/span&gt;
    &lt;span class="na"&gt;volumes&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="pi"&gt;-&lt;/span&gt; &lt;span class="s"&gt;postgres_data:/var/lib/postgresql/data&lt;/span&gt;
    &lt;span class="na"&gt;healthcheck&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
      &lt;span class="na"&gt;test&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="pi"&gt;[&lt;/span&gt;&lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;CMD-SHELL"&lt;/span&gt;&lt;span class="pi"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;"&lt;/span&gt;&lt;span class="s"&gt;pg_isready&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;-U&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;appuser&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;-d&lt;/span&gt;&lt;span class="nv"&gt; &lt;/span&gt;&lt;span class="s"&gt;appdb"&lt;/span&gt;&lt;span class="pi"&gt;]&lt;/span&gt;
      &lt;span class="na"&gt;interval&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;5s&lt;/span&gt;
      &lt;span class="na"&gt;timeout&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="s"&gt;3s&lt;/span&gt;
      &lt;span class="na"&gt;retries&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt; &lt;span class="m"&gt;5&lt;/span&gt;

&lt;span class="na"&gt;volumes&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
  &lt;span class="na"&gt;postgres_data&lt;/span&gt;&lt;span class="pi"&gt;:&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Run &lt;code&gt;docker compose up --build&lt;/code&gt; from the directory containing the file. Compose builds the API image, starts PostgreSQL, and connects the services on its default network.&lt;/p&gt;

&lt;p&gt;Notice that the API connects to &lt;code&gt;db&lt;/code&gt;, the Compose service name, rather than &lt;code&gt;localhost&lt;/code&gt;. Inside a container, &lt;code&gt;localhost&lt;/code&gt; refers to that same container. Compose makes services discoverable to one another by service name on the shared network.&lt;/p&gt;

&lt;h2&gt;
  
  
  Startup order is not the same as readiness
&lt;/h2&gt;

&lt;p&gt;A common mistake is assuming &lt;code&gt;depends_on&lt;/code&gt; means the database is ready to accept connections. Basic dependency ordering only ensures the database container starts first. The &lt;code&gt;service_healthy&lt;/code&gt; condition makes Compose wait for the database health check before starting the API.&lt;/p&gt;

&lt;p&gt;That helps with startup races, but the API should still handle a database becoming unavailable later. Compose’s startup check does not replace application level retries or resilience.&lt;/p&gt;

&lt;h2&gt;
  
  
  Keep local data and secrets in mind
&lt;/h2&gt;

&lt;p&gt;The named volume keeps PostgreSQL data when the container is recreated. Removing the containers with &lt;code&gt;docker compose down&lt;/code&gt; leaves named volumes in place; &lt;code&gt;docker compose down -v&lt;/code&gt; also removes them, including the stored database data.&lt;/p&gt;

&lt;p&gt;The example password is for local development only. For shared or production environments, provide credentials through an appropriate secrets mechanism instead of committing real passwords to the Compose file.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Key takeaway:&lt;/strong&gt; Docker Compose makes a multi-service development environment easy to describe and start consistently. Use service names for container-to-container connections, health checks for readiness, and persistent volumes for data you want to keep.&lt;/p&gt;

</description>
      <category>backend</category>
      <category>devops</category>
      <category>docker</category>
      <category>infrastructure</category>
    </item>
    <item>
      <title>OpenID Connect: What “Sign in with Google” Actually Adds to OAuth</title>
      <dc:creator>Ahmed Omeiza</dc:creator>
      <pubDate>Sat, 31 Oct 2026 21:31:21 +0000</pubDate>
      <link>https://dev.to/omeiza_ahmed/openid-connect-what-sign-in-with-google-actually-adds-to-oauth-36mp</link>
      <guid>https://dev.to/omeiza_ahmed/openid-connect-what-sign-in-with-google-actually-adds-to-oauth-36mp</guid>
      <description>&lt;p&gt;A user clicks &lt;strong&gt;Sign in with Google&lt;/strong&gt;, returns to your app, and is logged in. OAuth is involved—but OAuth alone doesn’t define how your app confirms who the user is. That’s the role of OpenID Connect (OIDC).&lt;/p&gt;

&lt;h2&gt;
  
  
  OAuth grants access; OIDC adds identity
&lt;/h2&gt;

&lt;p&gt;OAuth 2.0 lets an application obtain permission to access a resource, such as a user’s calendar or profile API. OIDC builds an identity layer on top of OAuth 2.0, so a client can verify that a user has authenticated and receive information about them.&lt;/p&gt;

&lt;p&gt;The key addition is the &lt;strong&gt;ID token&lt;/strong&gt;. It carries claims about the authentication, including who issued it and the user’s subject identifier. An &lt;strong&gt;access token&lt;/strong&gt; is for calling an API; it is not a substitute for the ID token when your app needs to establish a login.&lt;/p&gt;

&lt;h2&gt;
  
  
  What happens during a typical sign-in
&lt;/h2&gt;

&lt;p&gt;Imagine a web app that lets users sign in with an identity provider:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;The app redirects the user to the provider’s authorization endpoint.&lt;/li&gt;
&lt;li&gt;The provider authenticates the user and returns an authorization code.&lt;/li&gt;
&lt;li&gt;The app exchanges the code at the token endpoint.&lt;/li&gt;
&lt;li&gt;The app validates the returned ID token, then uses its claims to identify the signed-in user.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;OIDC discovery metadata can tell the app where the provider’s endpoints and signing keys are, so the app doesn’t need to hard-code each endpoint.&lt;/p&gt;

&lt;h2&gt;
  
  
  Use the right claim as the user key
&lt;/h2&gt;

&lt;p&gt;A common mistake is to treat an email address as the user’s permanent identity. Email addresses can change. OIDC provides a &lt;code&gt;sub&lt;/code&gt; (subject) claim intended to identify the user at that issuer. In practice, use the combination of the token’s issuer (&lt;code&gt;iss&lt;/code&gt;) and subject (&lt;code&gt;sub&lt;/code&gt;) to associate an external identity with a local account.&lt;/p&gt;

&lt;p&gt;Also, don’t just decode an ID token and trust its contents. Validate it using a maintained OIDC library. Validation includes checks such as the issuer and audience, as well as the token’s signature and time-related claims.&lt;/p&gt;

&lt;h2&gt;
  
  
  Key takeaway
&lt;/h2&gt;

&lt;p&gt;OIDC is the identity layer that lets an application verify a login using OAuth 2.0 flows. Use the ID token to understand the authentication, and the access token to call the APIs it authorizes.&lt;/p&gt;

</description>
      <category>security</category>
      <category>softwaredevelopment</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Salting vs Peppering Passwords: What’s the Difference?</title>
      <dc:creator>Ahmed Omeiza</dc:creator>
      <pubDate>Fri, 30 Oct 2026 16:01:46 +0000</pubDate>
      <link>https://dev.to/omeiza_ahmed/salting-vs-peppering-passwords-whats-the-difference-24nb</link>
      <guid>https://dev.to/omeiza_ahmed/salting-vs-peppering-passwords-whats-the-difference-24nb</guid>
      <description>&lt;p&gt;If a password database is stolen, attackers can try to guess passwords offline. Salting and peppering can make that attack harder, but they solve different problems.&lt;/p&gt;

&lt;h2&gt;
  
  
  Salting: a unique value for each password
&lt;/h2&gt;

&lt;p&gt;A &lt;strong&gt;salt&lt;/strong&gt; is a random value added to a password before it is processed by a password-hashing algorithm. Each password gets its own salt, and the salt is stored alongside the resulting hash.&lt;/p&gt;

&lt;p&gt;The salt makes identical passwords produce different stored hashes. It also prevents attackers from efficiently reusing precomputed tables of password hashes. A salt does not need to be secret.&lt;/p&gt;

&lt;p&gt;Use a password-hashing algorithm designed to slow down guessing, such as Argon2id, with suitable parameters. A fast general-purpose hash such as SHA-256 is not a substitute.&lt;/p&gt;

&lt;h2&gt;
  
  
  Peppering: a secret kept outside the database
&lt;/h2&gt;

&lt;p&gt;A &lt;strong&gt;pepper&lt;/strong&gt; is a secret value used in addition to the password and salt. Unlike a salt, it must be kept separate from the password database—for example, in a secrets manager or hardware security module.&lt;/p&gt;

&lt;p&gt;If an attacker obtains only the database, the pepper may make it harder to verify password guesses. But if the pepper is stored beside the hashes, it offers little extra protection.&lt;/p&gt;

&lt;h2&gt;
  
  
  A simplified example
&lt;/h2&gt;

&lt;p&gt;The following is conceptual pseudocode, not a specific .NET API:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;salt = secureRandomBytes()
pepperedInput = HMAC_SHA256(pepperKey, password)
storedHash = Argon2id(pepperedInput, salt, parameters)

store(salt, storedHash, algorithm, parameters)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The application keeps &lt;code&gt;pepperKey&lt;/code&gt; in a separate secrets store. When a user signs in, it repeats the same steps and compares the resulting hash using a safe verification method. In practice, use a well-maintained password-hashing library that handles salts, parameters, and verification correctly.&lt;/p&gt;

&lt;h2&gt;
  
  
  The trade-off
&lt;/h2&gt;

&lt;p&gt;A pepper adds operational responsibility. If the key is lost, the application cannot verify passwords protected with it; users may need to reset them. Rotating a pepper also requires care: after a successful login, the application can verify with the old key and rehash using the new one. Accounts that never sign in may need a password reset before the old key can be retired.&lt;/p&gt;

&lt;h2&gt;
  
  
  Key takeaway
&lt;/h2&gt;

&lt;p&gt;Use a unique salt and a slow password-hashing algorithm for every password. Treat peppering as an optional extra layer: keep the pepper outside the database, and plan how you will recover from key loss and handle rotation.&lt;/p&gt;

</description>
      <category>authentication</category>
      <category>cybersecurity</category>
      <category>security</category>
    </item>
    <item>
      <title>Secrets Management: Why Your API Keys and Passwords Should Never Live in Your Code</title>
      <dc:creator>Ahmed Omeiza</dc:creator>
      <pubDate>Wed, 28 Oct 2026 13:05:08 +0000</pubDate>
      <link>https://dev.to/omeiza_ahmed/secrets-management-why-your-api-keys-and-passwords-should-never-live-in-your-code-42n6</link>
      <guid>https://dev.to/omeiza_ahmed/secrets-management-why-your-api-keys-and-passwords-should-never-live-in-your-code-42n6</guid>
      <description>&lt;p&gt;Imagine pushing your application to GitHub, only to realize you've accidentally committed your production database password or payment gateway API key.&lt;/p&gt;

&lt;p&gt;Even if you delete it in the next commit, the damage may already be done.&lt;/p&gt;

&lt;p&gt;This is why &lt;strong&gt;Secrets Management&lt;/strong&gt; is an essential part of building secure applications.&lt;/p&gt;

&lt;h2&gt;
  
  
  What Is Secrets Management?
&lt;/h2&gt;

&lt;p&gt;Secrets Management is the process of securely storing, accessing, rotating, and revoking sensitive credentials used by applications.&lt;/p&gt;

&lt;p&gt;These secrets include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;API keys:&lt;/strong&gt; Credentials used to authenticate requests to external services.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Database credentials:&lt;/strong&gt; Usernames and passwords used to access databases.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Encryption keys:&lt;/strong&gt; Keys used to encrypt and decrypt sensitive information.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Signing keys:&lt;/strong&gt; Keys used to generate and verify cryptographic signatures.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Access tokens:&lt;/strong&gt; Credentials that authorize access to protected resources.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The goal is simple: &lt;strong&gt;Only authorized applications and services should have access to the secrets they need, and only when they need them.&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  The Problem With Hardcoding Secrets
&lt;/h2&gt;

&lt;p&gt;Consider this C# 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="kt"&gt;var&lt;/span&gt; &lt;span class="n"&gt;apiKey&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;"sk_live_123456789"&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;connectionString&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt;
    &lt;span class="s"&gt;"Host=localhost;Password=SuperSecret123"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The application might work perfectly, but the security implications are significant.&lt;/p&gt;

&lt;p&gt;If this code gets pushed to a public repository, anyone with access to it could potentially obtain those credentials.&lt;/p&gt;

&lt;p&gt;Even private repositories aren't a guarantee of safety. Secrets can leak through logs, build artifacts, compromised developer accounts, or accidentally shared configuration files.&lt;/p&gt;

&lt;p&gt;And deleting the credentials from your latest commit doesn't remove them from Git history.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The better approach is to separate secrets from application code.&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  How Should Applications Manage Secrets?
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. Use User Secrets During Development
&lt;/h3&gt;

&lt;p&gt;In ASP.NET Core, Microsoft provides the Secret Manager tool for keeping development credentials outside your project directory.&lt;/p&gt;

&lt;p&gt;Initialize it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;dotnet user-secrets init
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Store a development API key:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;dotnet user-secrets &lt;span class="nb"&gt;set&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="s2"&gt;"Payments:ApiKey"&lt;/span&gt; &lt;span class="s2"&gt;"your-dev-api-key"&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then retrieve it through the configuration system:&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;apiKey&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;builder&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Configuration&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="s"&gt;"Payments:ApiKey"&lt;/span&gt;
&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="p"&gt;??&lt;/span&gt; &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nf"&gt;InvalidOperationException&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="s"&gt;"Payments API key is missing"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The credential is no longer hardcoded in your application.&lt;/p&gt;

&lt;p&gt;However, there's an important distinction: &lt;strong&gt;.NET User Secrets are not encrypted.&lt;/strong&gt; They're designed for local development, not production secret storage.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Use a Secrets Manager in Production
&lt;/h3&gt;

&lt;p&gt;Production environments require stronger protection.&lt;/p&gt;

&lt;p&gt;Popular solutions include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Azure Key Vault&lt;/li&gt;
&lt;li&gt;AWS Secrets Manager&lt;/li&gt;
&lt;li&gt;HashiCorp Vault&lt;/li&gt;
&lt;li&gt;Google Cloud Secret Manager&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Instead of embedding credentials in your application, these services provide controlled access to sensitive information.&lt;/p&gt;

&lt;p&gt;For example, an ASP.NET Core application can use Azure Key Vault:&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;builder&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Configuration&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;AddAzureKeyVault&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="n"&gt;vaultUri&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;DefaultAzureCredential&lt;/span&gt;&lt;span class="p"&gt;());&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here, &lt;code&gt;vaultUri&lt;/code&gt; is a non-secret configuration value, and the required Azure configuration and identity packages must be installed.&lt;/p&gt;

&lt;p&gt;With the appropriate permissions and a managed identity in Azure, the application can authenticate to Key Vault without maintaining another long-lived client secret.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Apply the Principle of Least Privilege
&lt;/h3&gt;

&lt;p&gt;Not every application should access every secret.&lt;/p&gt;

&lt;p&gt;If your payment service only needs a payment gateway API key, it shouldn't also have permission to retrieve your database administrator credentials.&lt;/p&gt;

&lt;p&gt;Restrict access based on what each application or service actually needs.&lt;/p&gt;

&lt;p&gt;This reduces the potential damage if an application is compromised.&lt;/p&gt;

&lt;h3&gt;
  
  
  4. Rotate and Revoke Secrets
&lt;/h3&gt;

&lt;p&gt;Secrets shouldn't be treated as permanent credentials.&lt;/p&gt;

&lt;p&gt;Suppose your webhook signing key has been exposed.&lt;/p&gt;

&lt;p&gt;Simply encrypting the existing key won't solve the problem. An attacker who already possesses it may still be able to generate valid signatures.&lt;/p&gt;

&lt;p&gt;You need to replace the key and revoke the compromised one.&lt;/p&gt;

&lt;p&gt;For planned rotations, a system may temporarily support both old and new keys to avoid disrupting existing integrations. A confirmed compromise, however, may require immediate revocation.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Good secret rotation should minimize exposure without unnecessarily breaking dependent services.&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Secrets Management vs Encryption vs Hashing
&lt;/h2&gt;

&lt;p&gt;These concepts are related, but they solve different problems.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Hashing:&lt;/strong&gt; Useful when you only need to verify a presented credential without retrieving its original value. For example, a securely generated, high-entropy API token can be stored using an appropriate digest.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Encryption:&lt;/strong&gt; Useful when the original secret must be retrieved, such as a webhook signing key needed to generate an HMAC signature.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Secrets Management:&lt;/strong&gt; Covers the wider lifecycle, including secure storage, access control, auditing, rotation, and revocation.&lt;/p&gt;

&lt;p&gt;Encrypting a secret is valuable, but if the decryption key is hardcoded beside it, you've simply moved the security problem somewhere else.&lt;/p&gt;

&lt;h2&gt;
  
  
  Common Secrets Management Mistakes
&lt;/h2&gt;

&lt;p&gt;Even experienced developers sometimes overlook these issues:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Committing &lt;code&gt;.env&lt;/code&gt; files or sensitive &lt;code&gt;appsettings.json&lt;/code&gt; values to Git.&lt;/li&gt;
&lt;li&gt;Assuming environment variables are automatically encrypted.&lt;/li&gt;
&lt;li&gt;Logging API keys, authorization headers, or connection strings.&lt;/li&gt;
&lt;li&gt;Sharing production credentials across development and staging environments.&lt;/li&gt;
&lt;li&gt;Using one credential across multiple unrelated services.&lt;/li&gt;
&lt;li&gt;Failing to rotate or revoke exposed credentials.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Secret scanning in your development and CI/CD workflows can also help catch accidental leaks before they become security incidents.&lt;/p&gt;

&lt;h2&gt;
  
  
  Key Takeaway
&lt;/h2&gt;

&lt;p&gt;Secrets Management isn't just about hiding passwords or API keys.&lt;/p&gt;

&lt;p&gt;It's about controlling &lt;strong&gt;who can access sensitive credentials, how they're protected, and what happens when they're compromised.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A secure application should never depend on hardcoded production secrets.&lt;/p&gt;

&lt;p&gt;Keep development credentials outside your codebase, use dedicated secret stores in production, prefer managed identities where possible, enforce least-privilege access, and build rotation into your security strategy.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Because the best way to handle a leaked secret is to design your system so that one compromised credential doesn't compromise everything.&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>backend</category>
      <category>cybersecurity</category>
      <category>devops</category>
      <category>security</category>
    </item>
    <item>
      <title>Test-Driven Development (TDD): Write the Test Before the Code</title>
      <dc:creator>Ahmed Omeiza</dc:creator>
      <pubDate>Mon, 26 Oct 2026 12:13:33 +0000</pubDate>
      <link>https://dev.to/omeiza_ahmed/test-driven-development-tdd-write-the-test-before-the-code-4gdm</link>
      <guid>https://dev.to/omeiza_ahmed/test-driven-development-tdd-write-the-test-before-the-code-4gdm</guid>
      <description>&lt;p&gt;Most developers write code first and test it afterward.&lt;/p&gt;

&lt;p&gt;But what if you reversed that process?&lt;/p&gt;

&lt;p&gt;Instead of writing an implementation and then checking whether it works, you start by defining what the code should do through a test.&lt;/p&gt;

&lt;p&gt;That's the idea behind &lt;strong&gt;Test-Driven Development (TDD)&lt;/strong&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  What Is Test-Driven Development?
&lt;/h2&gt;

&lt;p&gt;Test-Driven Development is a software development approach where developers write automated tests before implementing the functionality those tests describe.&lt;/p&gt;

&lt;p&gt;The goal isn't simply to have more tests.&lt;/p&gt;

&lt;p&gt;It's to use tests to guide how software is designed and implemented.&lt;/p&gt;

&lt;p&gt;TDD follows a simple cycle called &lt;strong&gt;Red-Green-Refactor&lt;/strong&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Red: Write a Failing Test
&lt;/h3&gt;

&lt;p&gt;Start by writing a test that describes the expected behavior of a feature.&lt;/p&gt;

&lt;p&gt;The test should fail because the functionality hasn't been implemented yet.&lt;/p&gt;

&lt;p&gt;This confirms that your test can detect the missing behavior.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Green: Make the Test Pass
&lt;/h3&gt;

&lt;p&gt;Write the simplest code necessary to satisfy the test.&lt;/p&gt;

&lt;p&gt;Don't worry about making everything perfect immediately.&lt;/p&gt;

&lt;p&gt;Focus on getting the expected behavior working.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Refactor: Improve the Code
&lt;/h3&gt;

&lt;p&gt;Once the test passes, improve the implementation without changing its behavior.&lt;/p&gt;

&lt;p&gt;You might remove duplication, improve naming, or simplify complex logic.&lt;/p&gt;

&lt;p&gt;Run the tests again to ensure everything still works.&lt;/p&gt;

&lt;p&gt;Then repeat the cycle for the next requirement.&lt;/p&gt;

&lt;h2&gt;
  
  
  Practical Example: TDD in C
&lt;/h2&gt;

&lt;p&gt;Imagine you're building an e-commerce application that needs to calculate discounts.&lt;/p&gt;

&lt;p&gt;A customer purchasing an item worth $200 should pay $180 after a 10% discount.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 1: Write the test first (Red)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Using xUnit:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight csharp"&gt;&lt;code&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="n"&gt;Fact&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;ApplyDiscount_ShouldReturnDiscountedPrice&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// Arrange&lt;/span&gt;
    &lt;span class="kt"&gt;decimal&lt;/span&gt; &lt;span class="n"&gt;price&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="m"&gt;200m&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="kt"&gt;decimal&lt;/span&gt; &lt;span class="n"&gt;discount&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="m"&gt;10m&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="c1"&gt;// Act&lt;/span&gt;
    &lt;span class="kt"&gt;var&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;DiscountCalculator&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;ApplyDiscount&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="n"&gt;price&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;discount&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

    &lt;span class="c1"&gt;// Assert&lt;/span&gt;
    &lt;span class="n"&gt;Assert&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Equal&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;180m&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="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;At this stage, the test fails because the discount functionality hasn't been implemented.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 2: Implement the functionality (Green)&lt;/strong&gt;&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;static&lt;/span&gt; &lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;DiscountCalculator&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;static&lt;/span&gt; &lt;span class="kt"&gt;decimal&lt;/span&gt; &lt;span class="nf"&gt;ApplyDiscount&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="kt"&gt;decimal&lt;/span&gt; &lt;span class="n"&gt;price&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="kt"&gt;decimal&lt;/span&gt; &lt;span class="n"&gt;percentage&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;price&lt;/span&gt; &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;price&lt;/span&gt; &lt;span class="p"&gt;*&lt;/span&gt; &lt;span class="n"&gt;percentage&lt;/span&gt; &lt;span class="p"&gt;/&lt;/span&gt; &lt;span class="m"&gt;100m&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;Run the test again.&lt;/p&gt;

&lt;p&gt;It passes because the calculation now produces the expected result.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 3: Refactor&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;We can make the calculation slightly more readable.&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;static&lt;/span&gt; &lt;span class="kt"&gt;decimal&lt;/span&gt; &lt;span class="nf"&gt;ApplyDiscount&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="kt"&gt;decimal&lt;/span&gt; &lt;span class="n"&gt;price&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="kt"&gt;decimal&lt;/span&gt; &lt;span class="n"&gt;percentage&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;discountAmount&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="n"&gt;price&lt;/span&gt; &lt;span class="p"&gt;*&lt;/span&gt; &lt;span class="n"&gt;percentage&lt;/span&gt; &lt;span class="p"&gt;/&lt;/span&gt; &lt;span class="m"&gt;100m&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;price&lt;/span&gt; &lt;span class="p"&gt;-&lt;/span&gt; &lt;span class="n"&gt;discountAmount&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;The behavior remains unchanged, and the test should still pass.&lt;/p&gt;

&lt;p&gt;From here, we can introduce additional tests for edge cases like a 0% discount, a 100% discount, or invalid discount percentages.&lt;/p&gt;

&lt;p&gt;Each new requirement starts with another failing test.&lt;/p&gt;

&lt;p&gt;That's TDD in action.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why Does TDD Matter?
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;1. Encourages Better Code Design&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Writing tests first forces you to think about how your code will be used before deciding how to implement it.&lt;/p&gt;

&lt;p&gt;This can encourage smaller methods, clearer responsibilities, and loosely coupled components.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Catches Bugs Earlier&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Instead of discovering unexpected behavior much later, you get feedback while implementing each requirement.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Makes Refactoring Safer&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Automated tests help detect when changes accidentally break existing behavior.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. Clarifies Requirements&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Tests provide executable examples of what the application is expected to do.&lt;/p&gt;

&lt;p&gt;They can also help other developers understand existing functionality.&lt;/p&gt;

&lt;h2&gt;
  
  
  Does TDD Have Drawbacks?
&lt;/h2&gt;

&lt;p&gt;TDD isn't a silver bullet.&lt;/p&gt;

&lt;p&gt;Writing tests first can initially slow development, particularly when requirements are unclear or developers are unfamiliar with testing practices.&lt;/p&gt;

&lt;p&gt;Tests can also become expensive to maintain when they're tightly coupled to implementation details.&lt;/p&gt;

&lt;p&gt;And passing unit tests doesn't guarantee that an entire system works correctly.&lt;/p&gt;

&lt;p&gt;Integration tests, security testing, and other validation techniques still matter.&lt;/p&gt;

&lt;p&gt;The key is to test meaningful behavior rather than every internal implementation detail.&lt;/p&gt;

&lt;h2&gt;
  
  
  When Should You Use TDD?
&lt;/h2&gt;

&lt;p&gt;TDD is particularly useful when:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Implementing business rules and calculations.&lt;/li&gt;
&lt;li&gt;Building services with clearly defined behavior.&lt;/li&gt;
&lt;li&gt;Fixing bugs that should never reappear.&lt;/li&gt;
&lt;li&gt;Developing features with complex edge cases.&lt;/li&gt;
&lt;li&gt;Refactoring existing functionality with a reliable test suite.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It may be less practical during early exploration when requirements and interfaces are changing rapidly.&lt;/p&gt;

&lt;h2&gt;
  
  
  Key Takeaway
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;TDD isn't about writing tests for the sake of testing. It's about using tests to drive development decisions.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Instead of asking, "How do I test this code I've written?"&lt;/p&gt;

&lt;p&gt;You start by asking, "What should this code do, and how will I know it works?"&lt;/p&gt;

&lt;p&gt;That shift can lead to more predictable, maintainable, and reliable software.&lt;/p&gt;

</description>
      <category>programming</category>
      <category>softwaredevelopment</category>
      <category>testing</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Supply Chain Attacks: When Trusted Dependencies Become a Security Risk</title>
      <dc:creator>Ahmed Omeiza</dc:creator>
      <pubDate>Mon, 26 Oct 2026 12:11:36 +0000</pubDate>
      <link>https://dev.to/omeiza_ahmed/supply-chain-attacks-when-trusted-dependencies-become-a-security-risk-216i</link>
      <guid>https://dev.to/omeiza_ahmed/supply-chain-attacks-when-trusted-dependencies-become-a-security-risk-216i</guid>
      <description>&lt;p&gt;You can write secure code, validate every input, enforce authentication, and follow security best practices.&lt;/p&gt;

&lt;p&gt;But what happens when the library your application depends on is compromised?&lt;/p&gt;

&lt;p&gt;That's the danger of a &lt;strong&gt;software supply chain attack&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Sometimes, attackers don't need to break into your application directly. They only need to compromise something your application already trusts.&lt;/p&gt;

&lt;h2&gt;
  
  
  What Is a Supply Chain Attack?
&lt;/h2&gt;

&lt;p&gt;A software supply chain attack happens when an attacker compromises a component, tool, or process involved in building, distributing, or deploying software.&lt;/p&gt;

&lt;p&gt;Instead of attacking the final application directly, attackers target its dependencies or development infrastructure.&lt;/p&gt;

&lt;p&gt;These targets can include:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Third-party packages from NuGet, npm, or PyPI.&lt;/li&gt;
&lt;li&gt;Open-source libraries and their maintainers.&lt;/li&gt;
&lt;li&gt;CI/CD pipelines and build tools.&lt;/li&gt;
&lt;li&gt;Container images and deployment artifacts.&lt;/li&gt;
&lt;li&gt;Package registries and update mechanisms.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The dangerous part is that compromised code can enter an application through a seemingly legitimate update.&lt;/p&gt;

&lt;h2&gt;
  
  
  How Do Supply Chain Attacks Work?
&lt;/h2&gt;

&lt;p&gt;Imagine you're developing an ASP.NET Core application that uses a popular NuGet package for logging.&lt;/p&gt;

&lt;p&gt;Everything works correctly, and the package has thousands of downloads.&lt;/p&gt;

&lt;p&gt;One day, an attacker compromises the package maintainer's account and publishes a malicious update.&lt;/p&gt;

&lt;p&gt;Your team upgrades the dependency.&lt;/p&gt;

&lt;p&gt;The malicious version contains code designed to steal sensitive information.&lt;/p&gt;

&lt;p&gt;Depending on how the package is constructed, that code might execute during the build process or when your application runs.&lt;/p&gt;

&lt;p&gt;The result?&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Your application becomes compromised without the attacker ever accessing your source repository directly.&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Common Types of Supply Chain Attacks
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. Compromised Dependencies
&lt;/h3&gt;

&lt;p&gt;An attacker gains control of a legitimate package and publishes a malicious version.&lt;/p&gt;

&lt;p&gt;Developers install the update because they already trust the package.&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Dependency Confusion
&lt;/h3&gt;

&lt;p&gt;An attacker publishes a public package that conflicts with the name of an internal dependency.&lt;/p&gt;

&lt;p&gt;If the package manager is misconfigured, the build might download the attacker's package instead of the intended private package.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Typosquatting
&lt;/h3&gt;

&lt;p&gt;Attackers publish packages with names that closely resemble popular libraries.&lt;/p&gt;

&lt;p&gt;A simple spelling mistake can lead developers to install malicious code.&lt;/p&gt;

&lt;h3&gt;
  
  
  4. CI/CD Pipeline Compromise
&lt;/h3&gt;

&lt;p&gt;Attackers target build pipelines, automation tools, or credentials.&lt;/p&gt;

&lt;p&gt;A compromised pipeline can produce malicious artifacts even when the application's source code remains unchanged.&lt;/p&gt;

&lt;h2&gt;
  
  
  How Can Developers Prevent Supply Chain Attacks?
&lt;/h2&gt;

&lt;p&gt;Completely eliminating the risk isn't realistic, but several practices significantly reduce exposure.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Audit your dependencies.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;For .NET 10 projects, you can check for known vulnerabilities using:&lt;/p&gt;

&lt;p&gt;&lt;code&gt;dotnet package list --vulnerable --include-transitive&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;For .NET 9 or earlier, use the &lt;code&gt;dotnet list package&lt;/code&gt; command form.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Lock dependency versions.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Use dependency lock files such as &lt;code&gt;packages.lock.json&lt;/code&gt; and locked-mode restores to prevent unexpected dependency changes.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Review package updates.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Don't blindly approve every dependency update. Examine the changes, package ownership, and release history.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. Secure your CI/CD pipeline.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Apply least-privilege permissions, protect secrets, and pin external build actions to trusted immutable references.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;5. Verify your build artifacts.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Use artifact signing and build provenance where appropriate to help verify where and how software was produced.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;6. Continuously monitor dependencies.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A package considered safe today might be compromised tomorrow.&lt;/p&gt;

&lt;p&gt;One important distinction: vulnerability scanners identify known security issues. They cannot guarantee that a package contains no newly introduced malicious code.&lt;/p&gt;

&lt;h2&gt;
  
  
  Key Takeaway
&lt;/h2&gt;

&lt;p&gt;Modern software development depends heavily on code we didn't write.&lt;/p&gt;

&lt;p&gt;Every third-party library, build tool, and deployment integration introduces an additional trust relationship.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Supply chain security isn't just about protecting your code. It's about protecting everything your code depends on.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Before trusting a dependency, ask yourself:&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Do I know where this code came from, who controls it, and what happens if it gets compromised?&lt;/em&gt;&lt;/p&gt;

</description>
      <category>cybersecurity</category>
      <category>infosec</category>
      <category>security</category>
    </item>
    <item>
      <title>Cross-Site Request Forgery (CSRF): When Your Browser Becomes the Attacker</title>
      <dc:creator>Ahmed Omeiza</dc:creator>
      <pubDate>Sat, 24 Oct 2026 16:08:43 +0000</pubDate>
      <link>https://dev.to/omeiza_ahmed/cross-site-request-forgery-csrf-when-your-browser-becomes-the-attacker-2nh5</link>
      <guid>https://dev.to/omeiza_ahmed/cross-site-request-forgery-csrf-when-your-browser-becomes-the-attacker-2nh5</guid>
      <description>&lt;p&gt;Imagine logging into your banking application, then opening another website in a different tab.&lt;/p&gt;

&lt;p&gt;Without your knowledge, that website triggers a request to your banking application to perform an action you never authorized.&lt;/p&gt;

&lt;p&gt;You didn't initiate the action, but your browser may still send your authentication cookies with the request.&lt;/p&gt;

&lt;p&gt;That's the idea behind &lt;strong&gt;Cross-Site Request Forgery (CSRF)&lt;/strong&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  What Is CSRF?
&lt;/h2&gt;

&lt;p&gt;Cross-Site Request Forgery is a web security vulnerability that tricks a user's browser into performing unwanted actions on a website where the user is already authenticated.&lt;/p&gt;

&lt;p&gt;The attacker doesn't necessarily need to steal your password or session cookie.&lt;/p&gt;

&lt;p&gt;Instead, they exploit the trust between your browser and the application.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The problem isn't that the application doesn't recognize the user. It's that the application cannot determine whether the user intended the request.&lt;/strong&gt;&lt;/p&gt;

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

&lt;p&gt;Consider an application where users can change their email addresses.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;A user logs into &lt;code&gt;bank.example&lt;/code&gt; and receives an authentication cookie.&lt;/li&gt;
&lt;li&gt;The user visits an attacker-controlled website.&lt;/li&gt;
&lt;li&gt;The malicious website attempts to submit a request to &lt;code&gt;bank.example&lt;/code&gt; to change the user's email address.&lt;/li&gt;
&lt;li&gt;If the browser includes the session cookie and the application lacks CSRF protection, the server may process the request.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The server sees a valid authenticated session, but the action originated from an untrusted website.&lt;/p&gt;

&lt;p&gt;Modern cookie restrictions such as &lt;code&gt;SameSite=Lax&lt;/code&gt; can block many cross-site requests, but vulnerable configurations and application behaviors can still expose CSRF risks.&lt;/p&gt;

&lt;h2&gt;
  
  
  How Can Developers Prevent CSRF?
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;1. Use anti-CSRF tokens&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Generate an unpredictable token and require it on state-changing requests. The server validates the token before processing the action.&lt;/p&gt;

&lt;p&gt;An attacker-controlled website shouldn't be able to obtain a valid token from the protected application.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Configure SameSite cookies&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Use &lt;code&gt;SameSite=Lax&lt;/code&gt; or &lt;code&gt;SameSite=Strict&lt;/code&gt; where appropriate to restrict when browsers include cookies in cross-site requests.&lt;/p&gt;

&lt;p&gt;Treat this as an additional defense rather than assuming it covers every scenario.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Validate request origins&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Use the &lt;code&gt;Origin&lt;/code&gt; header, with carefully configured fallback checks, or Fetch Metadata headers to reject unexpected cross-site requests.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. Protect state-changing endpoints&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Operations such as changing passwords, updating account details, or transferring funds should require appropriate CSRF protection.&lt;/p&gt;

&lt;p&gt;Never use GET requests for operations that modify application state.&lt;/p&gt;

&lt;h2&gt;
  
  
  CSRF Protection in ASP.NET Core
&lt;/h2&gt;

&lt;p&gt;ASP.NET Core provides built-in antiforgery support.&lt;/p&gt;

&lt;p&gt;For MVC applications, developers can use &lt;code&gt;[ValidateAntiForgeryToken]&lt;/code&gt; on protected actions or configure &lt;code&gt;[AutoValidateAntiforgeryToken]&lt;/code&gt; to validate unsafe HTTP methods automatically.&lt;/p&gt;

&lt;p&gt;Razor Pages also provides built-in antiforgery support for forms.&lt;/p&gt;

&lt;p&gt;For APIs using cookie-based authentication, ensure the relevant endpoints have an appropriate CSRF defense.&lt;/p&gt;

&lt;p&gt;APIs authenticated exclusively with bearer tokens explicitly supplied through authorization headers are generally not susceptible to traditional cookie-based CSRF.&lt;/p&gt;

&lt;h2&gt;
  
  
  Key Takeaway
&lt;/h2&gt;

&lt;p&gt;Authentication verifies &lt;strong&gt;who is making a request&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;CSRF protection helps verify that the request came through an intended, trusted interaction.&lt;/p&gt;

&lt;p&gt;A valid session doesn't automatically mean a request is legitimate.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Secure applications must validate not just the user's identity, but also the trustworthiness of state-changing requests.&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>cybersecurity</category>
      <category>infosec</category>
      <category>security</category>
    </item>
    <item>
      <title>Technical Debt: The Hidden Cost of Moving Fast in Software Development</title>
      <dc:creator>Ahmed Omeiza</dc:creator>
      <pubDate>Fri, 23 Oct 2026 10:30:23 +0000</pubDate>
      <link>https://dev.to/omeiza_ahmed/technical-debt-the-hidden-cost-of-moving-fast-in-software-development-2l2f</link>
      <guid>https://dev.to/omeiza_ahmed/technical-debt-the-hidden-cost-of-moving-fast-in-software-development-2l2f</guid>
      <description>&lt;h1&gt;
  
  
  Technical Debt: The Hidden Cost of Moving Fast in Software Development
&lt;/h1&gt;

&lt;p&gt;Every developer has been there.&lt;/p&gt;

&lt;p&gt;You're working on a feature, the deadline is approaching, and you know there's a cleaner way to implement something.&lt;/p&gt;

&lt;p&gt;But the cleaner approach will take longer.&lt;/p&gt;

&lt;p&gt;So you take a shortcut, ship the feature, and tell yourself:&lt;/p&gt;

&lt;p&gt;&lt;em&gt;"I'll refactor this later."&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Three months later, that same piece of code has become a nightmare to maintain.&lt;/p&gt;

&lt;p&gt;That's technical debt.&lt;/p&gt;

&lt;h2&gt;
  
  
  What Is Technical Debt?
&lt;/h2&gt;

&lt;p&gt;Technical debt is the future cost of choosing a quicker or less sustainable solution today instead of a more maintainable approach.&lt;/p&gt;

&lt;p&gt;Think of it like borrowing money.&lt;/p&gt;

&lt;p&gt;A loan helps you achieve something now, but you'll eventually need to repay it, usually with interest.&lt;/p&gt;

&lt;p&gt;Technical debt works similarly.&lt;/p&gt;

&lt;p&gt;You save development time today, but future changes may require additional effort because of the shortcuts you took.&lt;/p&gt;

&lt;p&gt;And just like financial debt, &lt;strong&gt;not all technical debt is bad.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Sometimes, taking on debt is a reasonable engineering decision.&lt;/p&gt;

&lt;p&gt;The problem starts when nobody plans to pay it back.&lt;/p&gt;

&lt;h2&gt;
  
  
  A Practical Example
&lt;/h2&gt;

&lt;p&gt;Imagine you're building an e-commerce application using C# and ASP.NET Core.&lt;/p&gt;

&lt;p&gt;You need to calculate discounts for customers.&lt;/p&gt;

&lt;p&gt;To deliver the feature quickly, you write:&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="kt"&gt;decimal&lt;/span&gt; &lt;span class="nf"&gt;CalculateDiscount&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="kt"&gt;decimal&lt;/span&gt; &lt;span class="n"&gt;price&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="kt"&gt;string&lt;/span&gt; &lt;span class="n"&gt;customerType&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;customerType&lt;/span&gt; &lt;span class="p"&gt;==&lt;/span&gt; &lt;span class="s"&gt;"Premium"&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;price&lt;/span&gt; &lt;span class="p"&gt;*&lt;/span&gt; &lt;span class="m"&gt;0.20m&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;customerType&lt;/span&gt; &lt;span class="p"&gt;==&lt;/span&gt; &lt;span class="s"&gt;"Regular"&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;price&lt;/span&gt; &lt;span class="p"&gt;*&lt;/span&gt; &lt;span class="m"&gt;0.05m&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="m"&gt;0&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;At first, this works perfectly.&lt;/p&gt;

&lt;p&gt;But as the business grows, new requirements arrive:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Different discounts for seasonal promotions.&lt;/li&gt;
&lt;li&gt;Special pricing for loyal customers.&lt;/li&gt;
&lt;li&gt;Discount rules based on order value.&lt;/li&gt;
&lt;li&gt;Multiple discount conditions.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Suddenly, your simple method becomes a collection of complicated conditional statements.&lt;/p&gt;

&lt;p&gt;Every new requirement makes the code harder to understand, test, and modify.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The original implementation wasn't necessarily wrong. It simply became expensive to maintain as requirements evolved.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A better approach might involve extracting discount rules into separate strategies or services.&lt;/p&gt;

&lt;p&gt;However, that additional abstraction should be introduced when the complexity justifies it, not simply because a design pattern exists.&lt;/p&gt;

&lt;h2&gt;
  
  
  Common Causes of Technical Debt
&lt;/h2&gt;

&lt;p&gt;Technical debt doesn't always come from bad developers or poor coding practices.&lt;/p&gt;

&lt;p&gt;Sometimes, it comes from reasonable decisions made under real constraints.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Tight deadlines&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Developers prioritize delivering features quickly, postponing refactoring or architectural improvements.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Poor architectural decisions&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Choosing an architecture that doesn't fit the application's requirements can make future changes unnecessarily difficult.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Insufficient testing&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Without automated tests, developers become hesitant to modify existing code because they cannot confidently predict what might break.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. Outdated dependencies&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Delaying framework and library upgrades can eventually make updates more complicated, expensive, and risky.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;5. Changing requirements&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;An implementation that made sense six months ago may no longer support the application's current needs.&lt;/p&gt;

&lt;h2&gt;
  
  
  How Do You Know Technical Debt Is Becoming a Problem?
&lt;/h2&gt;

&lt;p&gt;Technical debt often reveals itself through everyday development challenges.&lt;/p&gt;

&lt;p&gt;You might notice that:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Small features take increasingly longer to implement.&lt;/li&gt;
&lt;li&gt;Fixing one bug introduces several others.&lt;/li&gt;
&lt;li&gt;Developers avoid modifying certain modules.&lt;/li&gt;
&lt;li&gt;The same logic is duplicated across the application.&lt;/li&gt;
&lt;li&gt;Deployments become stressful because testing is unreliable.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These are signs that the cost of maintaining the system may be increasing.&lt;/p&gt;

&lt;p&gt;The dangerous part is that technical debt rarely announces itself.&lt;/p&gt;

&lt;p&gt;It accumulates quietly until development velocity starts declining.&lt;/p&gt;

&lt;h2&gt;
  
  
  How to Manage Technical Debt
&lt;/h2&gt;

&lt;p&gt;The goal isn't to eliminate every shortcut or rewrite the application whenever the code becomes messy.&lt;/p&gt;

&lt;p&gt;It's to manage debt deliberately.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Make technical debt visible.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Document known issues and explain how they affect maintainability, performance, security, or delivery speed.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Prioritize based on impact.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Not every poorly written method needs immediate refactoring. Focus on debt that frequently slows development or introduces significant risk.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Refactor incrementally.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Improve problematic code when working in the affected areas, supported by automated tests.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. Invest in testing.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Unit and integration tests make future changes safer and reduce the cost of refactoring.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;5. Avoid unnecessary abstractions.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Overengineering can also create technical debt. Sometimes, a simple implementation is the most maintainable solution.&lt;/p&gt;

&lt;h2&gt;
  
  
  Final Thoughts
&lt;/h2&gt;

&lt;p&gt;Technical debt is not always evidence of poor engineering.&lt;/p&gt;

&lt;p&gt;Sometimes, it's the result of a deliberate trade-off between delivery speed and long-term maintainability.&lt;/p&gt;

&lt;p&gt;But there's a difference between &lt;strong&gt;choosing to take on technical debt and allowing it to accumulate without control.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Good engineering isn't about writing perfect code from day one.&lt;/p&gt;

&lt;p&gt;It's about making decisions that deliver value today without making tomorrow unnecessarily expensive.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The real cost of technical debt isn't the shortcut you take today. It's the additional work that shortcut creates every time you need to change the system.&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>refactoring</category>
      <category>softwaredevelopment</category>
      <category>softwareengineering</category>
    </item>
    <item>
      <title>Observer Pattern: How to Keep Components in Sync Without Tight Coupling</title>
      <dc:creator>Ahmed Omeiza</dc:creator>
      <pubDate>Thu, 22 Oct 2026 09:45:23 +0000</pubDate>
      <link>https://dev.to/omeiza_ahmed/observer-pattern-how-to-keep-components-in-sync-without-tight-coupling-55n0</link>
      <guid>https://dev.to/omeiza_ahmed/observer-pattern-how-to-keep-components-in-sync-without-tight-coupling-55n0</guid>
      <description>&lt;p&gt;Imagine building an e-commerce application.&lt;/p&gt;

&lt;p&gt;Whenever a customer places an order, several things need to happen:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Send an order confirmation email.&lt;/li&gt;
&lt;li&gt;Update inventory.&lt;/li&gt;
&lt;li&gt;Notify the shipping service.&lt;/li&gt;
&lt;li&gt;Record the activity for analytics.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;One approach is to make the &lt;code&gt;OrderService&lt;/code&gt; call every other service directly.&lt;/p&gt;

&lt;p&gt;It works. But what happens when you need to add another action, like sending an SMS?&lt;/p&gt;

&lt;p&gt;You modify the &lt;code&gt;OrderService&lt;/code&gt; again.&lt;/p&gt;

&lt;p&gt;This is the problem the &lt;strong&gt;Observer Pattern&lt;/strong&gt; helps solve.&lt;/p&gt;

&lt;h2&gt;
  
  
  What Is the Observer Pattern?
&lt;/h2&gt;

&lt;p&gt;The Observer Pattern is a behavioral design pattern that defines a &lt;strong&gt;one-to-many relationship between objects&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;When one object changes state or publishes an event, all registered observers are automatically notified.&lt;/p&gt;

&lt;p&gt;The pattern involves two main components:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1. Subject (Publisher)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The object being observed. It maintains a collection of observers and notifies them when something happens.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Observers (Subscribers)&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Objects interested in receiving notifications from the subject. Each observer decides how to react.&lt;/p&gt;

&lt;p&gt;The important idea is that the subject doesn't need to know what each observer does.&lt;/p&gt;

&lt;p&gt;It only knows how to notify them.&lt;/p&gt;

&lt;h2&gt;
  
  
  A Practical Example in C
&lt;/h2&gt;

&lt;p&gt;Let's implement a simple order notification system.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 1: Define the Observer Contract&lt;/strong&gt;&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;IOrderObserver&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;OnOrderPlaced&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;orderId&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;Every observer implements this interface.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 2: Create the Observers&lt;/strong&gt;&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;EmailObserver&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;IOrderObserver&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;OnOrderPlaced&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;orderId&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;$"Sending email for order &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;orderId&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;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;InventoryObserver&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;IOrderObserver&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;OnOrderPlaced&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;orderId&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;$"Updating inventory for order &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;orderId&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;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Each observer has a single responsibility.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 3: Implement the Subject&lt;/strong&gt;&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;OrderService&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;readonly&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;IOrderObserver&lt;/span&gt;&lt;span class="p"&gt;&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;_observers&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&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;Subscribe&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;IOrderObserver&lt;/span&gt; &lt;span class="n"&gt;observer&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;_observers&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;observer&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;Unsubscribe&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;IOrderObserver&lt;/span&gt; &lt;span class="n"&gt;observer&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="n"&gt;_observers&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Remove&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;observer&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;PlaceOrder&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;orderId&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;$"Order &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="n"&gt;orderId&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s"&gt; placed"&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;observer&lt;/span&gt; &lt;span class="k"&gt;in&lt;/span&gt; &lt;span class="n"&gt;_observers&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="n"&gt;observer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;OnOrderPlaced&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;orderId&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;Notice something important.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;OrderService&lt;/code&gt; doesn't reference &lt;code&gt;EmailObserver&lt;/code&gt; or &lt;code&gt;InventoryObserver&lt;/code&gt; directly.&lt;/p&gt;

&lt;p&gt;It only depends on the &lt;code&gt;IOrderObserver&lt;/code&gt; abstraction.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 4: Put Everything Together&lt;/strong&gt;&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;orderService&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;OrderService&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

&lt;span class="n"&gt;orderService&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Subscribe&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;EmailObserver&lt;/span&gt;&lt;span class="p"&gt;());&lt;/span&gt;
&lt;span class="n"&gt;orderService&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;Subscribe&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;InventoryObserver&lt;/span&gt;&lt;span class="p"&gt;());&lt;/span&gt;

&lt;span class="n"&gt;orderService&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;PlaceOrder&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;101&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Order 101 placed
Sending email for order 101
Updating inventory for order 101
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now imagine adding an SMS notification.&lt;/p&gt;

&lt;p&gt;You create an &lt;code&gt;SmsObserver&lt;/code&gt;, implement the interface, and subscribe it.&lt;/p&gt;

&lt;p&gt;No changes to the existing &lt;code&gt;OrderService&lt;/code&gt; are necessary.&lt;/p&gt;

&lt;p&gt;That's the real benefit.&lt;/p&gt;

&lt;h2&gt;
  
  
  Where Is the Observer Pattern Used?
&lt;/h2&gt;

&lt;p&gt;You've probably encountered the Observer Pattern without realizing it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;User Interfaces:&lt;/strong&gt; Button-click handlers and UI events notify registered listeners.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Real-Time Dashboards:&lt;/strong&gt; Components update when underlying application data changes.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Notification Systems:&lt;/strong&gt; Multiple subscribers react to an event, such as a completed payment.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;.NET Applications:&lt;/strong&gt; C# events and delegates, along with &lt;code&gt;IObservable&amp;lt;T&amp;gt;&lt;/code&gt; and &lt;code&gt;IObserver&amp;lt;T&amp;gt;&lt;/code&gt;, provide mechanisms for observer-style communication.&lt;/p&gt;

&lt;h2&gt;
  
  
  When Should You Avoid It?
&lt;/h2&gt;

&lt;p&gt;The Observer Pattern isn't always the right choice.&lt;/p&gt;

&lt;p&gt;As your application grows, having many observers can make event flows harder to trace.&lt;/p&gt;

&lt;p&gt;There are also a few things to consider:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A slow observer can delay other observers when notifications execute synchronously.&lt;/li&gt;
&lt;li&gt;An exception in one observer can interrupt notifications to the remaining observers.&lt;/li&gt;
&lt;li&gt;Forgotten subscriptions can cause memory leaks when a long-lived subject retains references to observers.&lt;/li&gt;
&lt;li&gt;The order in which observers execute can introduce unexpected dependencies.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For critical workflows like payment processing, durable messaging or an outbox-based approach may be more appropriate.&lt;/p&gt;

&lt;p&gt;The basic Observer Pattern provides notifications, not guaranteed message delivery.&lt;/p&gt;

&lt;h2&gt;
  
  
  Observer Pattern vs. Pub/Sub
&lt;/h2&gt;

&lt;p&gt;These concepts are closely related, but they aren't identical.&lt;/p&gt;

&lt;p&gt;In a traditional Observer implementation, the subject typically maintains direct references to its observers through an interface.&lt;/p&gt;

&lt;p&gt;In Publish/Subscribe architectures, publishers and subscribers are often separated by an event broker or message bus.&lt;/p&gt;

&lt;p&gt;The Observer Pattern commonly operates within a single process, while Pub/Sub systems can support communication across multiple services.&lt;/p&gt;

&lt;h2&gt;
  
  
  Final Thoughts
&lt;/h2&gt;

&lt;p&gt;The Observer Pattern is about more than sending notifications.&lt;/p&gt;

&lt;p&gt;It's about reducing dependencies between components.&lt;/p&gt;

&lt;p&gt;Instead of forcing one service to know everything that should happen after an event, let interested components subscribe and respond independently.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The takeaway:&lt;/strong&gt; When multiple components need to react to the same change, consider the Observer Pattern before filling your application with tightly coupled service calls.&lt;/p&gt;

&lt;p&gt;Good software design isn't about eliminating dependencies entirely. It's about managing them deliberately.&lt;/p&gt;

</description>
      <category>architecture</category>
      <category>programming</category>
      <category>softwareengineering</category>
      <category>systemdesign</category>
    </item>
    <item>
      <title>DRY vs WET Code: When Repeating Yourself Is Actually Better</title>
      <dc:creator>Ahmed Omeiza</dc:creator>
      <pubDate>Wed, 21 Oct 2026 20:08:37 +0000</pubDate>
      <link>https://dev.to/omeiza_ahmed/dry-vs-wet-code-when-repeating-yourself-is-actually-better-3nim</link>
      <guid>https://dev.to/omeiza_ahmed/dry-vs-wet-code-when-repeating-yourself-is-actually-better-3nim</guid>
      <description>&lt;p&gt;Every developer has heard the advice: &lt;strong&gt;"Don't Repeat Yourself."&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;But what if following that principle too aggressively makes your code harder to maintain?&lt;/p&gt;

&lt;p&gt;Sometimes, duplicating a few lines of code is better than creating an abstraction that complicates everything.&lt;/p&gt;

&lt;p&gt;This is where &lt;strong&gt;DRY vs WET&lt;/strong&gt; becomes interesting.&lt;/p&gt;

&lt;h2&gt;
  
  
  What Is DRY Code?
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;DRY (Don't Repeat Yourself)&lt;/strong&gt; is a software development principle that encourages developers to avoid duplicating knowledge or business logic across a codebase.&lt;/p&gt;

&lt;p&gt;The idea is simple: &lt;strong&gt;Every piece of knowledge should have a single, authoritative representation in a system.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Consider this C# 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="kt"&gt;decimal&lt;/span&gt; &lt;span class="nf"&gt;CalculateProductTax&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;decimal&lt;/span&gt; &lt;span class="n"&gt;price&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;price&lt;/span&gt; &lt;span class="p"&gt;*&lt;/span&gt; &lt;span class="m"&gt;0.075m&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;decimal&lt;/span&gt; &lt;span class="nf"&gt;CalculateServiceTax&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;decimal&lt;/span&gt; &lt;span class="n"&gt;price&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;price&lt;/span&gt; &lt;span class="p"&gt;*&lt;/span&gt; &lt;span class="m"&gt;0.075m&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;Both methods implement the same tax calculation.&lt;/p&gt;

&lt;p&gt;If the tax rate changes, you must update both methods. Forgetting one could introduce inconsistent behavior.&lt;/p&gt;

&lt;h3&gt;
  
  
  Applying DRY
&lt;/h3&gt;

&lt;p&gt;We can extract the shared logic:&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="kt"&gt;decimal&lt;/span&gt; &lt;span class="nf"&gt;CalculateTax&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kt"&gt;decimal&lt;/span&gt; &lt;span class="n"&gt;price&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;price&lt;/span&gt; &lt;span class="p"&gt;*&lt;/span&gt; &lt;span class="m"&gt;0.075m&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 both product and service calculations can reuse the same implementation.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Benefits of DRY:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Less duplicated business logic.&lt;/li&gt;
&lt;li&gt;Easier maintenance.&lt;/li&gt;
&lt;li&gt;More consistent behavior.&lt;/li&gt;
&lt;li&gt;Changes can be made in one place.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;But there is a catch.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Not everything that looks similar should be combined.&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  What Is WET Code?
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;WET&lt;/strong&gt; is commonly interpreted as "Write Everything Twice" or "We Enjoy Typing."&lt;/p&gt;

&lt;p&gt;It describes code that contains repetition rather than extracting every similarity into a reusable abstraction.&lt;/p&gt;

&lt;p&gt;Although WET is often used negatively, a little duplication can sometimes make code easier to understand.&lt;/p&gt;

&lt;p&gt;Consider two validation methods:&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="kt"&gt;bool&lt;/span&gt; &lt;span class="nf"&gt;ValidateCustomer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Customer&lt;/span&gt; &lt;span class="n"&gt;customer&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="p"&gt;!&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;IsNullOrEmpty&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;customer&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="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="kt"&gt;bool&lt;/span&gt; &lt;span class="nf"&gt;ValidateEmployee&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Employee&lt;/span&gt; &lt;span class="n"&gt;employee&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="p"&gt;!&lt;/span&gt;&lt;span class="kt"&gt;string&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;IsNullOrEmpty&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;employee&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="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Both methods perform the same check.&lt;/p&gt;

&lt;p&gt;A developer focused entirely on DRY might immediately introduce a shared interface, generic validator, or abstraction.&lt;/p&gt;

&lt;p&gt;But should they?&lt;/p&gt;

&lt;p&gt;Not necessarily.&lt;/p&gt;

&lt;p&gt;Customer and employee validation might have different business requirements in the future.&lt;/p&gt;

&lt;p&gt;If they evolve independently, combining them too early creates unnecessary coupling.&lt;/p&gt;

&lt;p&gt;Keeping them separate allows each implementation to change without affecting the other.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;This is where a little WET code makes sense.&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  The Hidden Danger of DRY: Premature Abstraction
&lt;/h2&gt;

&lt;p&gt;Imagine you have three services performing similar operations.&lt;/p&gt;

&lt;p&gt;You decide to combine them into one reusable method.&lt;/p&gt;

&lt;p&gt;A few weeks later, their requirements change.&lt;/p&gt;

&lt;p&gt;Suddenly, your reusable method starts looking 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;void&lt;/span&gt; &lt;span class="nf"&gt;Process&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="kt"&gt;bool&lt;/span&gt; &lt;span class="n"&gt;isCustomer&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="kt"&gt;bool&lt;/span&gt; &lt;span class="n"&gt;isEmployee&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="kt"&gt;bool&lt;/span&gt; &lt;span class="n"&gt;requiresApproval&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// Multiple conditional branches&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Instead of reducing complexity, the abstraction has introduced more of it.&lt;/p&gt;

&lt;p&gt;Now, changing one workflow risks affecting another.&lt;/p&gt;

&lt;p&gt;The problem isn't DRY itself.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The problem is abstracting code before understanding what genuinely belongs together.&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  The Rule of Three
&lt;/h2&gt;

&lt;p&gt;One practical approach is the &lt;strong&gt;Rule of Three&lt;/strong&gt;.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;First occurrence:&lt;/strong&gt; Write the code.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Second occurrence:&lt;/strong&gt; Notice the similarity, but don't rush to abstract.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Third occurrence:&lt;/strong&gt; Evaluate whether a shared abstraction makes sense.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This is a heuristic, not a strict rule.&lt;/p&gt;

&lt;p&gt;If two pieces of code represent the same business rule, centralizing that rule immediately may be appropriate.&lt;/p&gt;

&lt;p&gt;But if they only happen to look alike, keeping them separate can be the better design.&lt;/p&gt;

&lt;h2&gt;
  
  
  DRY vs WET: Which Should You Choose?
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Choose DRY when:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Multiple components share the same business rule.&lt;/li&gt;
&lt;li&gt;Duplicated logic must always remain consistent.&lt;/li&gt;
&lt;li&gt;Changes should propagate across all consumers.&lt;/li&gt;
&lt;li&gt;The abstraction has a clear responsibility.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Choose WET when:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Similar code serves different business purposes.&lt;/li&gt;
&lt;li&gt;Requirements are likely to evolve independently.&lt;/li&gt;
&lt;li&gt;Extracting shared logic introduces unnecessary complexity.&lt;/li&gt;
&lt;li&gt;A little duplication makes the code easier to understand.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  The Key Takeaway
&lt;/h2&gt;

&lt;p&gt;Good software engineering isn't about eliminating every duplicated line.&lt;/p&gt;

&lt;p&gt;It's about balancing &lt;strong&gt;reusability, readability, maintainability, and flexibility&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;DRY helps prevent duplicated knowledge, while deliberate WET code can help avoid premature abstractions.&lt;/p&gt;

&lt;p&gt;Remember:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Duplicated code is not always duplicated knowledge.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Sometimes, repeating yourself today is better than maintaining the wrong abstraction tomorrow.&lt;/p&gt;

</description>
      <category>csharp</category>
      <category>programming</category>
      <category>softwaredevelopment</category>
      <category>softwareengineering</category>
    </item>
    <item>
      <title>SQL Injection: When User Input Becomes a Database Command</title>
      <dc:creator>Ahmed Omeiza</dc:creator>
      <pubDate>Tue, 20 Oct 2026 08:37:58 +0000</pubDate>
      <link>https://dev.to/omeiza_ahmed/sql-injection-when-user-input-becomes-a-database-command-2j8n</link>
      <guid>https://dev.to/omeiza_ahmed/sql-injection-when-user-input-becomes-a-database-command-2j8n</guid>
      <description>&lt;p&gt;Imagine building a login system that checks a user's email and password against a database.&lt;/p&gt;

&lt;p&gt;Everything works perfectly until someone enters something unexpected into the login form.&lt;/p&gt;

&lt;p&gt;Suddenly, your application is executing SQL commands you never intended.&lt;/p&gt;

&lt;p&gt;That's the danger of &lt;strong&gt;SQL Injection (SQLi)&lt;/strong&gt;, one of the oldest and most dangerous vulnerabilities in web application security.&lt;/p&gt;

&lt;h2&gt;
  
  
  What Is SQL Injection?
&lt;/h2&gt;

&lt;p&gt;SQL Injection is a security vulnerability that occurs when an application allows untrusted input to change the structure of a SQL query.&lt;/p&gt;

&lt;p&gt;Instead of treating user input as data, the database ends up interpreting parts of it as SQL instructions.&lt;/p&gt;

&lt;p&gt;Depending on the vulnerability and database permissions, attackers might be able to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Access sensitive information.&lt;/li&gt;
&lt;li&gt;Bypass authentication.&lt;/li&gt;
&lt;li&gt;Modify or delete records.&lt;/li&gt;
&lt;li&gt;Execute unauthorized database operations.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The underlying problem is simple: &lt;strong&gt;the application fails to separate data from executable SQL.&lt;/strong&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  How Does SQL Injection Work?
&lt;/h2&gt;

&lt;p&gt;Consider a C# application that retrieves a user from a database.&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;query&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;$"SELECT * FROM Users WHERE Email = '&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="s"&gt;'"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;At first glance, this looks reasonable.&lt;/p&gt;

&lt;p&gt;If the user enters:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;john@example.com
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The resulting query becomes:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;Users&lt;/span&gt;
&lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;Email&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;'john@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;Everything works as expected.&lt;/p&gt;

&lt;p&gt;But what happens if someone enters:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="s1"&gt;' OR 1=1 --
&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Your application constructs:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight sql"&gt;&lt;code&gt;&lt;span class="k"&gt;SELECT&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="k"&gt;FROM&lt;/span&gt; &lt;span class="n"&gt;Users&lt;/span&gt;
&lt;span class="k"&gt;WHERE&lt;/span&gt; &lt;span class="n"&gt;Email&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s1"&gt;''&lt;/span&gt; &lt;span class="k"&gt;OR&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt; &lt;span class="c1"&gt;--';&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here's what happens:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The first &lt;code&gt;'&lt;/code&gt; closes the string.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;OR 1=1&lt;/code&gt; introduces a condition that is always true.&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;--&lt;/code&gt; comments out the remaining SQL.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Instead of retrieving one specific user, the database may return every user.&lt;/p&gt;

&lt;p&gt;And if an application's authentication logic incorrectly trusts that result, the consequences can be even worse.&lt;/p&gt;

&lt;h2&gt;
  
  
  How Do You Prevent SQL Injection?
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. Use Parameterized Queries
&lt;/h3&gt;

&lt;p&gt;The most important defense is to separate SQL commands from user-supplied values.&lt;/p&gt;

&lt;p&gt;Instead of concatenating strings:&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;query&lt;/span&gt; &lt;span class="p"&gt;=&lt;/span&gt; &lt;span class="s"&gt;$"SELECT * FROM Users WHERE Email = '&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="s"&gt;'"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Use parameters:&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;using&lt;/span&gt; &lt;span class="nn"&gt;var&lt;/span&gt; &lt;span class="n"&gt;command&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;NpgsqlCommand&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
    &lt;span class="s"&gt;"SELECT * FROM Users WHERE Email = @email"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="n"&gt;connection&lt;/span&gt;
&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="n"&gt;command&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Parameters&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;AddWithValue&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s"&gt;"email"&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;using&lt;/span&gt; &lt;span class="nn"&gt;var&lt;/span&gt; &lt;span class="n"&gt;reader&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;command&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;ExecuteReaderAsync&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, even if someone enters malicious SQL syntax, the database treats it as a value rather than executable SQL.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The query structure stays unchanged.&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Use an ORM Like Entity Framework Core
&lt;/h3&gt;

&lt;p&gt;If you're working with .NET, Entity Framework Core makes it easier to write queries safely.&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;user&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;context&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Users&lt;/span&gt;
    &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;FirstOrDefaultAsync&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;u&lt;/span&gt; &lt;span class="p"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="n"&gt;u&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="n"&gt;email&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;EF Core translates this LINQ expression into a parameterized SQL query.&lt;/p&gt;

&lt;p&gt;However, using an ORM doesn't automatically eliminate every SQL Injection risk.&lt;/p&gt;

&lt;p&gt;For example, this is still dangerous:&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;users&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;context&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Users&lt;/span&gt;
    &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;FromSqlRaw&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="s"&gt;$"SELECT * FROM Users WHERE Email = '&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="s"&gt;'"&lt;/span&gt;
    &lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;ToListAsync&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The safer approach is:&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;users&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;context&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;Users&lt;/span&gt;
    &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;FromSqlInterpolated&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
        &lt;span class="s"&gt;$"SELECT * FROM Users WHERE Email = &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="s"&gt;"&lt;/span&gt;
    &lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;ToListAsync&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here, EF Core converts the interpolated value into a database parameter.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Important:&lt;/strong&gt; &lt;code&gt;FromSqlRaw&lt;/code&gt; can also be safe when used correctly with explicit parameters. The vulnerability comes from inserting untrusted values directly into SQL text.&lt;/p&gt;

&lt;h3&gt;
  
  
  3. Apply the Principle of Least Privilege
&lt;/h3&gt;

&lt;p&gt;Your application shouldn't connect to the database using an account with unnecessary administrative permissions.&lt;/p&gt;

&lt;p&gt;For example, if a service only needs to read records, its database account shouldn't have permission to delete tables.&lt;/p&gt;

&lt;p&gt;This doesn't prevent SQL Injection itself, but it can significantly reduce the damage if a vulnerability is exploited.&lt;/p&gt;

&lt;h3&gt;
  
  
  4. Validate Input, but Don't Rely on Validation Alone
&lt;/h3&gt;

&lt;p&gt;Input validation is important.&lt;/p&gt;

&lt;p&gt;You can validate email formats, enforce length limits, and reject unexpected values.&lt;/p&gt;

&lt;p&gt;However, validation is not a replacement for parameterized queries.&lt;/p&gt;

&lt;p&gt;Attackers can find ways around weak validation rules, but properly parameterized values cannot alter the SQL query structure.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Key Takeaway
&lt;/h2&gt;

&lt;p&gt;SQL Injection isn't really about attackers knowing clever SQL commands.&lt;/p&gt;

&lt;p&gt;It's about an application allowing user-controlled data to become executable instructions.&lt;/p&gt;

&lt;p&gt;Whether you're using raw SQL, Dapper, ADO.NET, or Entity Framework Core, the principle remains the same:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Never build SQL queries by concatenating untrusted input.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Use parameterized queries, limit database permissions, and treat every external input as untrusted.&lt;/p&gt;

&lt;p&gt;Because sometimes, the difference between a secure application and a database breach is how you construct a single SQL query.&lt;/p&gt;

</description>
      <category>cybersecurity</category>
      <category>database</category>
      <category>security</category>
      <category>sql</category>
    </item>
    <item>
      <title>Containers vs Virtual Machines: What's the Difference, and When Should You Use Each?</title>
      <dc:creator>Ahmed Omeiza</dc:creator>
      <pubDate>Mon, 19 Oct 2026 10:51:32 +0000</pubDate>
      <link>https://dev.to/omeiza_ahmed/containers-vs-virtual-machines-whats-the-difference-and-when-should-you-use-each-5f0d</link>
      <guid>https://dev.to/omeiza_ahmed/containers-vs-virtual-machines-whats-the-difference-and-when-should-you-use-each-5f0d</guid>
      <description>&lt;p&gt;&lt;strong&gt;Two applications can run on the same server without interfering with each other. But how you isolate them can make a big difference in performance, resource usage, and deployment.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;That's where Containers and Virtual Machines (VMs) come in.&lt;/p&gt;

&lt;p&gt;Both solve a similar problem: running applications in isolated environments.&lt;/p&gt;

&lt;p&gt;But they achieve isolation differently, and understanding that difference can help you make better architectural decisions.&lt;/p&gt;

&lt;h2&gt;
  
  
  What Is a Virtual Machine?
&lt;/h2&gt;

&lt;p&gt;A Virtual Machine is a software-based computer that runs its own operating system on top of a physical machine.&lt;/p&gt;

&lt;p&gt;A &lt;strong&gt;hypervisor&lt;/strong&gt;, such as VMware ESXi, Hyper-V, or KVM, allows multiple VMs to share the same physical hardware.&lt;/p&gt;

&lt;p&gt;Each VM has its own:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Operating system&lt;/li&gt;
&lt;li&gt;Virtual CPU and memory&lt;/li&gt;
&lt;li&gt;Applications and dependencies&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For example, imagine you have a physical server running three applications.&lt;/p&gt;

&lt;p&gt;With VMs, you could create three separate virtual machines, each running its own operating system and application.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The advantage?&lt;/strong&gt; Strong isolation and flexibility to run different operating systems.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The trade-off?&lt;/strong&gt; Each VM carries the overhead of a separate guest operating system, increasing resource consumption.&lt;/p&gt;

&lt;h2&gt;
  
  
  What Is a Container?
&lt;/h2&gt;

&lt;p&gt;A container packages an application together with the dependencies it needs to run.&lt;/p&gt;

&lt;p&gt;Unlike traditional VMs, containers don't need a complete guest operating system for every application.&lt;/p&gt;

&lt;p&gt;Instead, they share the host operating system's kernel while maintaining isolated processes, filesystems, and network environments.&lt;/p&gt;

&lt;p&gt;Tools like Docker make it easier to build, package, and run containers.&lt;/p&gt;

&lt;p&gt;For example, consider an ASP.NET Core application that uses PostgreSQL and Redis.&lt;/p&gt;

&lt;p&gt;Instead of installing everything directly on your development machine, you can run each component in its own container.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Docker Host
│
├── ASP.NET Core Container
├── PostgreSQL Container
└── Redis Container
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Each service runs in its own environment, but they share the underlying host kernel.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The advantage?&lt;/strong&gt; Lightweight deployment, fast startup, and efficient resource usage.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;The trade-off?&lt;/strong&gt; Containers share the host kernel, so their isolation boundary is generally weaker than that of traditional VMs.&lt;/p&gt;

&lt;h2&gt;
  
  
  Containers vs Virtual Machines: Key Differences
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;1. Architecture&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Virtual Machines virtualize hardware, allowing each VM to run a complete guest operating system.&lt;/p&gt;

&lt;p&gt;Containers use operating-system-level isolation to run applications while sharing a kernel.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2. Resource Consumption&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;VMs generally require more memory and storage because each includes a guest operating system.&lt;/p&gt;

&lt;p&gt;Containers are usually lighter because they don't duplicate the entire operating system.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3. Startup Time&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;VMs often take longer to start because they boot a guest operating system.&lt;/p&gt;

&lt;p&gt;Containers can start in seconds or less, depending on the application and initialization requirements.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4. Isolation and Security&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;VMs provide strong isolation through the hypervisor and separate guest operating systems.&lt;/p&gt;

&lt;p&gt;Containers provide process-level isolation, but sharing the host kernel creates additional security considerations.&lt;/p&gt;

&lt;p&gt;Neither approach is automatically secure. Configuration, patching, and access controls still matter.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;5. Portability&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Containers make it easier to package and deploy applications consistently across compatible environments.&lt;/p&gt;

&lt;p&gt;VMs can also be moved between compatible virtualization platforms, but their images are typically larger.&lt;/p&gt;

&lt;h2&gt;
  
  
  When Should You Use Virtual Machines?
&lt;/h2&gt;

&lt;p&gt;Virtual Machines are a good choice when:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You need to run different operating systems on the same hardware.&lt;/li&gt;
&lt;li&gt;Strong workload isolation is a major requirement.&lt;/li&gt;
&lt;li&gt;You're hosting legacy applications with specific OS dependencies.&lt;/li&gt;
&lt;li&gt;You need full control over the guest operating system.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For example, an organization might use VMs to host multiple enterprise applications that require different operating systems or configurations.&lt;/p&gt;

&lt;h2&gt;
  
  
  When Should You Use Containers?
&lt;/h2&gt;

&lt;p&gt;Containers are particularly useful when:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You're building microservices.&lt;/li&gt;
&lt;li&gt;You need consistent development and production environments.&lt;/li&gt;
&lt;li&gt;You frequently deploy application updates.&lt;/li&gt;
&lt;li&gt;You want efficient resource utilization.&lt;/li&gt;
&lt;li&gt;You're working with automated CI/CD pipelines.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For example, an ASP.NET Core Web API can be packaged into a Docker image and deployed consistently across development, staging, and production environments, provided the required configuration and infrastructure are available.&lt;/p&gt;

&lt;h2&gt;
  
  
  Can Containers and Virtual Machines Work Together?
&lt;/h2&gt;

&lt;p&gt;Absolutely.&lt;/p&gt;

&lt;p&gt;In fact, many modern cloud architectures combine both technologies.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Physical Server
    │
    └── Virtual Machine
           │
           └── Container Runtime
                  │
                  ├── API Container
                  ├── Worker Container
                  └── Redis Container
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The VM provides an infrastructure isolation boundary, while containers provide lightweight application packaging and deployment.&lt;/p&gt;

&lt;p&gt;This is common in cloud environments where container workloads run on VM-based worker nodes.&lt;/p&gt;

&lt;p&gt;You don't always have to choose one over the other.&lt;/p&gt;

&lt;h2&gt;
  
  
  Final Takeaway
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Virtual Machines isolate operating systems. Containers isolate application environments while sharing a kernel.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;VMs provide flexibility and strong isolation, while containers offer lightweight packaging, faster startup, and efficient deployment.&lt;/p&gt;

&lt;p&gt;The right choice depends on your application's security requirements, infrastructure, scalability needs, and operational complexity.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Good engineering isn't about choosing the newest technology. It's about choosing the right abstraction for the problem you're solving.&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>architecture</category>
      <category>devops</category>
      <category>docker</category>
      <category>infrastructure</category>
    </item>
  </channel>
</rss>
