<?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: Sajidur Rahman Shajib</title>
    <description>The latest articles on DEV Community by Sajidur Rahman Shajib (@sajidurshajib).</description>
    <link>https://dev.to/sajidurshajib</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F690167%2F5e74e5d2-ca5b-4ee1-ab5b-82515f04c075.png</url>
      <title>DEV Community: Sajidur Rahman Shajib</title>
      <link>https://dev.to/sajidurshajib</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/sajidurshajib"/>
    <language>en</language>
    <item>
      <title>🔄 Push vs Pull Architecture: What’s the Real Difference?</title>
      <dc:creator>Sajidur Rahman Shajib</dc:creator>
      <pubDate>Thu, 24 Jul 2025 20:28:08 +0000</pubDate>
      <link>https://dev.to/sajidurshajib/push-vs-pull-architecture-whats-the-real-difference-48kc</link>
      <guid>https://dev.to/sajidurshajib/push-vs-pull-architecture-whats-the-real-difference-48kc</guid>
      <description>&lt;p&gt;In software architecture, &lt;strong&gt;Push&lt;/strong&gt; and &lt;strong&gt;Pull&lt;/strong&gt; models define how data flows between a producer (like a server) and a consumer (like a client). While both are valid, choosing the right one can significantly impact user experience, system performance, and scalability.&lt;/p&gt;




&lt;h2&gt;
  
  
  📤 What is Push Architecture?
&lt;/h2&gt;

&lt;p&gt;In a &lt;strong&gt;Push&lt;/strong&gt; model, the &lt;strong&gt;server initiates&lt;/strong&gt; the communication. It sends (or "pushes") data to the client whenever something new happens. The client doesn’t have to ask—it just gets notified.&lt;/p&gt;

&lt;h3&gt;
  
  
  ✅ Pros:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Low latency&lt;/li&gt;
&lt;li&gt;Real-time experience&lt;/li&gt;
&lt;li&gt;Efficient for frequent updates&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  ❌ Cons:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;More complex to implement&lt;/li&gt;
&lt;li&gt;Harder to scale with many clients&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;🧠 &lt;strong&gt;Examples:&lt;/strong&gt; WebSockets, Firebase Realtime Database, Server-Sent Events&lt;/p&gt;




&lt;h2&gt;
  
  
  📥 What is Pull Architecture?
&lt;/h2&gt;

&lt;p&gt;In a &lt;strong&gt;Pull&lt;/strong&gt; model, the &lt;strong&gt;client initiates&lt;/strong&gt; the communication. It regularly or occasionally requests data from the server, asking, “Do you have anything new?”&lt;/p&gt;

&lt;h3&gt;
  
  
  ✅ Pros:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Simpler and more predictable&lt;/li&gt;
&lt;li&gt;Easier to cache and scale&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  ❌ Cons:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Higher latency (delays)&lt;/li&gt;
&lt;li&gt;Might miss real-time events&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;🧠 &lt;strong&gt;Examples:&lt;/strong&gt; REST APIs, GraphQL, Cron Jobs&lt;/p&gt;




&lt;h2&gt;
  
  
  👩‍💻 Alice’s Story: Choosing Between Push and Pull
&lt;/h2&gt;

&lt;p&gt;Alice is a full-stack developer working on two features for her startup’s new app:&lt;/p&gt;

&lt;h3&gt;
  
  
  1. 🔔 Real-Time Notifications (Push)
&lt;/h3&gt;

&lt;p&gt;She wants users to get live alerts when someone likes their post. She builds this using &lt;strong&gt;WebSockets&lt;/strong&gt; so that once a user is connected, the server can immediately &lt;strong&gt;push&lt;/strong&gt; the like notification to their screen.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;🧠 No polling. Instant updates. Smooth UX.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  2. 📊 Weekly Reports Dashboard (Pull)
&lt;/h3&gt;

&lt;p&gt;For analytics, users only care about their &lt;strong&gt;weekly&lt;/strong&gt; activity. Alice decides to build this with a simple REST API that the frontend calls when the user opens the dashboard. The data is &lt;strong&gt;pulled&lt;/strong&gt; on demand.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;💡 No need to keep a live connection for static weekly reports.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Alice sees the strengths and trade-offs of both models firsthand.&lt;/p&gt;




&lt;h2&gt;
  
  
  🧮 Push vs Pull: Head-to-Head
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Aspect&lt;/th&gt;
&lt;th&gt;🔄 Push&lt;/th&gt;
&lt;th&gt;🔁 Pull&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Initiator&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Server&lt;/td&gt;
&lt;td&gt;Client&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Data Delivery&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Real-time&lt;/td&gt;
&lt;td&gt;On-demand&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Latency&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Low&lt;/td&gt;
&lt;td&gt;Can be high&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Complexity&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Higher&lt;/td&gt;
&lt;td&gt;Lower&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Best For&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Live feeds, chat, notifications&lt;/td&gt;
&lt;td&gt;Reports, forms, content APIs&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Examples&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;WebSocket, Firebase&lt;/td&gt;
&lt;td&gt;REST API, GraphQL&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;h2&gt;
  
  
  🧠 Conclusion: Which One Should You Use?
&lt;/h2&gt;

&lt;p&gt;As Alice learned, &lt;strong&gt;there's no one-size-fits-all&lt;/strong&gt;. Use &lt;strong&gt;Push&lt;/strong&gt; when you need instant updates. Use &lt;strong&gt;Pull&lt;/strong&gt; when your app can tolerate a delay or doesn’t change often.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;💭 &lt;strong&gt;As a developer, ask yourself:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;“Does my user need this data &lt;strong&gt;now&lt;/strong&gt;, or can it wait?”&lt;/em&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;That question might just guide you to the right architecture. 😉&lt;/p&gt;

</description>
      <category>push</category>
      <category>pull</category>
      <category>architecture</category>
      <category>systemdesign</category>
    </item>
    <item>
      <title>🌐 Proxy vs Reverse Proxy – Explained Simply with Alice 🧠</title>
      <dc:creator>Sajidur Rahman Shajib</dc:creator>
      <pubDate>Mon, 14 Jul 2025 14:35:14 +0000</pubDate>
      <link>https://dev.to/sajidurshajib/proxy-vs-reverse-proxy-explained-simply-with-alice-1oof</link>
      <guid>https://dev.to/sajidurshajib/proxy-vs-reverse-proxy-explained-simply-with-alice-1oof</guid>
      <description>&lt;p&gt;When you hear the terms &lt;strong&gt;Proxy&lt;/strong&gt; and &lt;strong&gt;Reverse Proxy&lt;/strong&gt;, it might sound like network jargon. But don't worry—let’s break it down in plain English, and better yet, let's bring in &lt;strong&gt;Alice&lt;/strong&gt; to help us understand it like a story.&lt;/p&gt;




&lt;h2&gt;
  
  
  🔍 What Is a Proxy?
&lt;/h2&gt;

&lt;p&gt;A &lt;strong&gt;Proxy (Forward Proxy)&lt;/strong&gt; is like a middleman between you (the client) and the internet. When you use a proxy, you're not directly talking to the website—you send the request to the proxy, and it fetches the site for you.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Key Point:&lt;/strong&gt; It hides the client (you) from the internet.&lt;/p&gt;




&lt;h2&gt;
  
  
  🔁 What Is a Reverse Proxy?
&lt;/h2&gt;

&lt;p&gt;A &lt;strong&gt;Reverse Proxy&lt;/strong&gt; is the opposite. It sits in front of servers and handles incoming requests. It decides &lt;strong&gt;which server&lt;/strong&gt; should process the request and then responds back to the client.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Key Point:&lt;/strong&gt; It hides the servers from the client.&lt;/p&gt;




&lt;h2&gt;
  
  
  🧵 The Story: Alice and the Library 📚
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Scene 1: Alice Uses a Proxy
&lt;/h3&gt;

&lt;p&gt;Alice lives in a country where some websites are blocked. She really wants to read a blog hosted abroad.&lt;/p&gt;

&lt;p&gt;So, she asks her tech-savvy friend Bob to help.&lt;/p&gt;

&lt;p&gt;Bob says, “Use this proxy server I set up. Instead of visiting the site directly, tell the proxy what you want. It’ll grab the page and show it to you.”&lt;/p&gt;

&lt;p&gt;Now, the website thinks the &lt;strong&gt;proxy&lt;/strong&gt; is the visitor, not Alice. Alice stays anonymous.&lt;/p&gt;

&lt;p&gt;🧠 &lt;strong&gt;This is a forward proxy.&lt;/strong&gt;&lt;/p&gt;




&lt;h3&gt;
  
  
  Scene 2: Alice Builds a Website
&lt;/h3&gt;

&lt;p&gt;Alice starts her own website. It becomes popular and crashes often. So she deploys 3 servers behind a &lt;strong&gt;reverse proxy&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Now, when visitors go to &lt;code&gt;aliceblog.com&lt;/code&gt;, the &lt;strong&gt;reverse proxy&lt;/strong&gt; handles the traffic, picks one of the backend servers, and returns the response.&lt;/p&gt;

&lt;p&gt;Visitors never know which server handled their request—they only see &lt;code&gt;aliceblog.com&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;🧠 &lt;strong&gt;This is a reverse proxy.&lt;/strong&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  💡 Practical Use Cases
&lt;/h2&gt;

&lt;h3&gt;
  
  
  ✅ Proxy (Forward Proxy)
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;🛡️ Privacy &amp;amp; Anonymity&lt;/strong&gt;  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Hide IP while browsing
&lt;/li&gt;
&lt;li&gt;Access blocked content&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;🏫 Network Control&lt;/strong&gt;  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Schools and offices block websites (e.g., Facebook)
&lt;/li&gt;
&lt;li&gt;Monitor and log browsing activity&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;📈 Web Scraping&lt;/strong&gt;  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Rotate IPs via proxy pools to avoid detection&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;📦 Caching&lt;/strong&gt;  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Cache frequently accessed pages to save bandwidth&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;




&lt;h3&gt;
  
  
  ✅ Reverse Proxy
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;📊 Load Balancing&lt;/strong&gt;  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Distribute traffic across multiple backend servers&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;🔒 SSL Termination&lt;/strong&gt;  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Handle HTTPS encryption at the proxy level&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;🧱 Security&lt;/strong&gt;  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Hide internal server structure from the outside world&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;⚡ Faster Content&lt;/strong&gt;  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Serve static content (CSS, JS, images) directly&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;🎯 API Gateway&lt;/strong&gt;  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Unified entry point for multiple services (common in microservices)&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;




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

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Feature&lt;/th&gt;
&lt;th&gt;Proxy (Forward)&lt;/th&gt;
&lt;th&gt;Reverse Proxy&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Who it hides&lt;/td&gt;
&lt;td&gt;Hides the &lt;strong&gt;client&lt;/strong&gt;
&lt;/td&gt;
&lt;td&gt;Hides the &lt;strong&gt;server&lt;/strong&gt;
&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Used by&lt;/td&gt;
&lt;td&gt;Client&lt;/td&gt;
&lt;td&gt;Server or network&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Purpose&lt;/td&gt;
&lt;td&gt;Anonymity, filtering&lt;/td&gt;
&lt;td&gt;Load balancing, security&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Whether you're scraping the web, protecting your infrastructure, or optimizing load, understanding proxies will give you an edge in modern web development.&lt;/p&gt;




&lt;p&gt;&lt;strong&gt;Now you're thinking like Alice. Stay curious. 🧠💡&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>proxy</category>
      <category>reverse</category>
      <category>network</category>
      <category>website</category>
    </item>
    <item>
      <title>🧩 When to Use NoSQL and SQL?</title>
      <dc:creator>Sajidur Rahman Shajib</dc:creator>
      <pubDate>Sun, 13 Jul 2025 12:42:51 +0000</pubDate>
      <link>https://dev.to/sajidurshajib/when-to-use-nosql-and-sql-a1m</link>
      <guid>https://dev.to/sajidurshajib/when-to-use-nosql-and-sql-a1m</guid>
      <description>&lt;p&gt;Choosing between &lt;strong&gt;SQL&lt;/strong&gt; and &lt;strong&gt;NoSQL&lt;/strong&gt; isn’t about which one is better—it’s about which one fits your project best. Let’s break it down in a clear, no-fluff way.&lt;/p&gt;




&lt;h2&gt;
  
  
  🧠 What is SQL?
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;SQL (Structured Query Language)&lt;/strong&gt; databases are &lt;strong&gt;relational&lt;/strong&gt;—they organize data in &lt;strong&gt;tables&lt;/strong&gt; with predefined &lt;strong&gt;schemas&lt;/strong&gt;. They’re great for handling &lt;strong&gt;structured data&lt;/strong&gt;, maintaining &lt;strong&gt;relationships&lt;/strong&gt;, and ensuring &lt;strong&gt;data integrity&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;🛠️ Popular SQL Databases: PostgreSQL, MySQL, SQLite, SQL Server&lt;/p&gt;




&lt;h2&gt;
  
  
  🌐 What is NoSQL?
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;NoSQL (Not Only SQL)&lt;/strong&gt; databases are &lt;strong&gt;non-relational&lt;/strong&gt;, designed for &lt;strong&gt;flexibility and scalability&lt;/strong&gt;. They store data as &lt;strong&gt;documents&lt;/strong&gt;, &lt;strong&gt;key-value pairs&lt;/strong&gt;, &lt;strong&gt;wide-columns&lt;/strong&gt;, or &lt;strong&gt;graphs&lt;/strong&gt;—perfect for dynamic, high-speed applications.&lt;/p&gt;

&lt;p&gt;⚙️ Popular NoSQL Databases: MongoDB, Redis, Cassandra, DynamoDB&lt;/p&gt;




&lt;h2&gt;
  
  
  📌 When to Use SQL
&lt;/h2&gt;

&lt;p&gt;Use &lt;strong&gt;SQL&lt;/strong&gt; when:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;✅ Your data is &lt;strong&gt;structured&lt;/strong&gt; and predictable&lt;/li&gt;
&lt;li&gt;🔗 You need &lt;strong&gt;relationships&lt;/strong&gt; between entities (users → orders)&lt;/li&gt;
&lt;li&gt;🧾 Complex &lt;strong&gt;queries and reporting&lt;/strong&gt; are required&lt;/li&gt;
&lt;li&gt;🧪 You need &lt;strong&gt;ACID transactions&lt;/strong&gt; (reliable and consistent)&lt;/li&gt;
&lt;li&gt;📊 You care about &lt;strong&gt;data integrity&lt;/strong&gt; and validation&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Example Use Cases:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Banking systems 💸
&lt;/li&gt;
&lt;li&gt;Inventory management 📦
&lt;/li&gt;
&lt;li&gt;E-commerce platforms 🛒
&lt;/li&gt;
&lt;li&gt;ERP or CRM systems 🧾&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  📌 When to Use NoSQL
&lt;/h2&gt;

&lt;p&gt;Use &lt;strong&gt;NoSQL&lt;/strong&gt; when:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;🔄 Your data is &lt;strong&gt;dynamic or semi-structured&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;🚀 You need &lt;strong&gt;high write/read throughput&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;🌍 Your app must scale across &lt;strong&gt;distributed systems&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;⚡ Schema needs to &lt;strong&gt;evolve quickly&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;⏱️ You care more about &lt;strong&gt;availability &amp;amp; speed&lt;/strong&gt; than strict consistency&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Example Use Cases:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Chat and messaging apps 💬
&lt;/li&gt;
&lt;li&gt;Real-time analytics 📈
&lt;/li&gt;
&lt;li&gt;IoT data and logs 📡
&lt;/li&gt;
&lt;li&gt;Caching systems 🔥
&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  ⚖️ SQL vs NoSQL — Side-by-Side
&lt;/h2&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Feature&lt;/th&gt;
&lt;th&gt;SQL&lt;/th&gt;
&lt;th&gt;NoSQL&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Structure&lt;/td&gt;
&lt;td&gt;Relational (tables)&lt;/td&gt;
&lt;td&gt;Flexible (docs, key-value, etc.)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Schema&lt;/td&gt;
&lt;td&gt;Fixed&lt;/td&gt;
&lt;td&gt;Dynamic&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Relationships&lt;/td&gt;
&lt;td&gt;Strong (JOINs)&lt;/td&gt;
&lt;td&gt;Weak or manual&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Query Language&lt;/td&gt;
&lt;td&gt;SQL&lt;/td&gt;
&lt;td&gt;Varies (MongoQL, etc.)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Scaling&lt;/td&gt;
&lt;td&gt;Vertical (scale-up)&lt;/td&gt;
&lt;td&gt;Horizontal (scale-out)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Transactions&lt;/td&gt;
&lt;td&gt;ACID&lt;/td&gt;
&lt;td&gt;BASE (eventual consistency)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Use Case Fit&lt;/td&gt;
&lt;td&gt;Financial, inventory, ERP&lt;/td&gt;
&lt;td&gt;Real-time, IoT, big data&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;h2&gt;
  
  
  💡 Final Tip
&lt;/h2&gt;

&lt;p&gt;🛠️ &lt;strong&gt;Modern systems often use both&lt;/strong&gt;:  &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;SQL for core business data
&lt;/li&gt;
&lt;li&gt;NoSQL for speed, flexibility, or caching&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Don’t choose based on trend—choose based on &lt;strong&gt;need&lt;/strong&gt;.&lt;br&gt;&lt;br&gt;
That’s smart engineering. 🚀&lt;/p&gt;




&lt;p&gt;&lt;em&gt;Written for devs who want to architect better systems.&lt;/em&gt;&lt;/p&gt;

</description>
      <category>sql</category>
      <category>nosql</category>
      <category>database</category>
      <category>systemdesign</category>
    </item>
    <item>
      <title>🧠 Understanding the CAP Theorem – Through Alice’s Distributed Adventure 🚀</title>
      <dc:creator>Sajidur Rahman Shajib</dc:creator>
      <pubDate>Sat, 12 Jul 2025 21:26:44 +0000</pubDate>
      <link>https://dev.to/sajidurshajib/understanding-the-cap-theorem-through-alices-distributed-adventure-pmp</link>
      <guid>https://dev.to/sajidurshajib/understanding-the-cap-theorem-through-alices-distributed-adventure-pmp</guid>
      <description>&lt;p&gt;Distributed systems are everywhere — from your favorite social media platforms to online banking. But making them work reliably isn’t easy. One foundational concept every backend engineer or system designer needs to understand is the &lt;strong&gt;CAP Theorem&lt;/strong&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  📚 What is the CAP Theorem?
&lt;/h2&gt;

&lt;p&gt;CAP stands for &lt;strong&gt;Consistency&lt;/strong&gt;, &lt;strong&gt;Availability&lt;/strong&gt;, and &lt;strong&gt;Partition Tolerance&lt;/strong&gt;. Proposed by Eric Brewer in 2000, the CAP Theorem states that:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;In any distributed data system, &lt;strong&gt;you can only guarantee two out of the following three&lt;/strong&gt; properties at the same time:&lt;/p&gt;
&lt;/blockquote&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Consistency (C)&lt;/strong&gt;: Every node sees the same data at the same time.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Availability (A)&lt;/strong&gt;: Every request gets a response — success or failure.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Partition Tolerance (P)&lt;/strong&gt;: The system continues to function even if network issues split it into disconnected parts.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;When a network partition occurs (and it &lt;strong&gt;will&lt;/strong&gt;, eventually), you’re forced to choose between &lt;strong&gt;Consistency&lt;/strong&gt; and &lt;strong&gt;Availability&lt;/strong&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  🧵 Alice and the CAP Dilemma: A Distributed Tale
&lt;/h2&gt;

&lt;p&gt;Meet &lt;strong&gt;Alice&lt;/strong&gt;, a backend engineer working at a startup called &lt;strong&gt;BDGrocer&lt;/strong&gt;, which delivers groceries in real-time using microservices.&lt;/p&gt;

&lt;p&gt;One day, Alice was tasked with designing a distributed order system that would sync between the &lt;strong&gt;Dhaka&lt;/strong&gt; and &lt;strong&gt;CTG&lt;/strong&gt; servers. Simple? Not quite.&lt;/p&gt;

&lt;h3&gt;
  
  
  🔧 Round 1: The Ideal World
&lt;/h3&gt;

&lt;p&gt;Alice dreams of a perfect system where:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;All users always see the most recent order status (&lt;strong&gt;Consistency&lt;/strong&gt;).&lt;/li&gt;
&lt;li&gt;Every request is responded to immediately (&lt;strong&gt;Availability&lt;/strong&gt;).&lt;/li&gt;
&lt;li&gt;And of course, the system survives any network failure (&lt;strong&gt;Partition Tolerance&lt;/strong&gt;).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;But then her senior smiles and says:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;“Alice, welcome to CAP. You can only pick two.”&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  ⚖️ Option 1: Consistency + Partition Tolerance (CP)
&lt;/h3&gt;

&lt;p&gt;Alice thinks, &lt;em&gt;“Let’s make sure data is always accurate, even if servers get partitioned.”&lt;/em&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;If Dhaka and CTG servers can't talk due to a network glitch, she decides to &lt;strong&gt;block requests&lt;/strong&gt; to avoid stale data.&lt;/li&gt;
&lt;li&gt;Customers might &lt;strong&gt;wait&lt;/strong&gt; a bit longer, but they'll get the &lt;strong&gt;right&lt;/strong&gt; info.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;📉 &lt;strong&gt;Trade-off&lt;/strong&gt;: The system isn't always available. Some users might get errors or timeouts.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Use case&lt;/strong&gt;: Financial systems like banks — better to fail than show wrong balance.&lt;/p&gt;




&lt;h3&gt;
  
  
  ⚡ Option 2: Availability + Partition Tolerance (AP)
&lt;/h3&gt;

&lt;p&gt;Now Alice thinks, &lt;em&gt;“Speed is key. Let’s answer all requests, even if the servers are split.”&lt;/em&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;If there's a partition, both servers still serve requests.&lt;/li&gt;
&lt;li&gt;But data might temporarily be &lt;strong&gt;inconsistent&lt;/strong&gt; (e.g., one user sees their order canceled, the other sees it confirmed).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;📉 &lt;strong&gt;Trade-off&lt;/strong&gt;: Some temporary inconsistency, but system is always &lt;strong&gt;responsive&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Use case&lt;/strong&gt;: Messaging apps — better to let users keep chatting and sync later.&lt;/p&gt;




&lt;h3&gt;
  
  
  ✅ Option 3: Consistency + Availability (CA)
&lt;/h3&gt;

&lt;p&gt;Alice likes this. No data mismatch, and always responsive! But then...&lt;/p&gt;

&lt;p&gt;🚨 &lt;strong&gt;Oops&lt;/strong&gt;: It only works &lt;strong&gt;if there's no network partition&lt;/strong&gt;. Not realistic in distributed systems.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Conclusion&lt;/strong&gt;: CA works only in &lt;strong&gt;single-node&lt;/strong&gt; or &lt;strong&gt;non-partitioned&lt;/strong&gt; setups. In real distributed systems, you &lt;strong&gt;must&lt;/strong&gt; tolerate partitions — so this combo isn’t practical.&lt;/p&gt;




&lt;h2&gt;
  
  
  🧠 What Did Alice Learn?
&lt;/h2&gt;

&lt;p&gt;In the real world, &lt;strong&gt;network partitions are inevitable&lt;/strong&gt;. So most distributed systems must pick between &lt;strong&gt;C or A&lt;/strong&gt; — they can’t have both when the network fails.&lt;/p&gt;

&lt;p&gt;Alice wisely chooses different trade-offs for different services:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;For &lt;strong&gt;payments&lt;/strong&gt;, she picks &lt;strong&gt;CP&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;For &lt;strong&gt;live delivery tracking&lt;/strong&gt;, she goes with &lt;strong&gt;AP&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  🎯 Final Thought
&lt;/h2&gt;

&lt;p&gt;Understanding CAP isn't about memorizing acronyms — it's about &lt;strong&gt;making smart trade-offs&lt;/strong&gt;. Each choice fits a different context. Like Alice, you should always ask:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;“What matters most here — accuracy or availability — when the network goes wrong?”&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;That’s how real-world systems are built. 🚀&lt;/p&gt;

</description>
      <category>cap</category>
      <category>theorem</category>
      <category>systemdesign</category>
      <category>softwareengineering</category>
    </item>
    <item>
      <title>🚀 A Better Way to Seed Data Using SQLAlchemy (Async-friendly)</title>
      <dc:creator>Sajidur Rahman Shajib</dc:creator>
      <pubDate>Tue, 01 Jul 2025 20:32:18 +0000</pubDate>
      <link>https://dev.to/sajidurshajib/a-better-way-to-seed-data-using-sqlalchemy-async-friendly-4k31</link>
      <guid>https://dev.to/sajidurshajib/a-better-way-to-seed-data-using-sqlalchemy-async-friendly-4k31</guid>
      <description>&lt;p&gt;In modern backend projects, especially with FastAPI and async SQLAlchemy, seeding initial data like (e.g.,&lt;code&gt;roles&lt;/code&gt;) is an important part. &lt;/p&gt;

&lt;p&gt;Here’s a practical and scalable approach we used to seed data smoothly:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;✅ 1. Organized Seeders&lt;/strong&gt;&lt;br&gt;
Each seeder reads data from &lt;code&gt;JSON&lt;/code&gt; files and checks if the entry already exists in the DB. If not, it creates it — avoiding duplicates.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"role"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"admin"&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"role"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"manager"&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"role"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"developer"&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;},&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="nl"&gt;"role"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"user"&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# roles_seeder.py
&lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;json&lt;/span&gt;
&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;os&lt;/span&gt;

&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;sqlalchemy.ext.asyncio&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;AsyncSession&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;sqlalchemy.future&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;select&lt;/span&gt;

&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;app.models.roles&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;Role&lt;/span&gt;


&lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;seed_roles&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;session&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;AsyncSession&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="k"&gt;try&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="n"&gt;json_path&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;path&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;join&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
            &lt;span class="n"&gt;os&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;path&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;dirname&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;__file__&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;data&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;roles.json&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;
        &lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;with&lt;/span&gt; &lt;span class="nf"&gt;open&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;json_path&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;r&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="nb"&gt;file&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;roles_to_seed&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;json&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;load&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;file&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

        &lt;span class="k"&gt;for&lt;/span&gt; &lt;span class="n"&gt;role_data&lt;/span&gt; &lt;span class="ow"&gt;in&lt;/span&gt; &lt;span class="n"&gt;roles_to_seed&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="n"&gt;role_name&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;role_data&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;role&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

            &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="n"&gt;role_name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;[-] Skipping invalid role data: missing &lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;role&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;.&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
                &lt;span class="k"&gt;continue&lt;/span&gt;

            &lt;span class="n"&gt;existing_role_query&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="n"&gt;session&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;execute&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;
                &lt;span class="nf"&gt;select&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Role&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;where&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Role&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;role&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="n"&gt;role_name&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="p"&gt;)&lt;/span&gt;
            &lt;span class="n"&gt;existing_role&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;existing_role_query&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;scalars&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nf"&gt;first&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

            &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="ow"&gt;not&lt;/span&gt; &lt;span class="n"&gt;existing_role&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
                &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;[+] Creating new role &lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;role_name&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;.&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
                &lt;span class="n"&gt;new_role&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;Role&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;role&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="n"&gt;role_name&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
                &lt;span class="n"&gt;session&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;new_role&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;session&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;commit&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
        &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;[+] Roles seeded or updated successfully.&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;except&lt;/span&gt; &lt;span class="nb"&gt;Exception&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;e&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;session&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;rollback&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
        &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sa"&gt;f&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;[-] Error while seeding or updating roles: &lt;/span&gt;&lt;span class="si"&gt;{&lt;/span&gt;&lt;span class="n"&gt;e&lt;/span&gt;&lt;span class="si"&gt;}&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
        &lt;span class="k"&gt;raise&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; Your code might be different based on your requirements. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;✅ 2. Shared Async Context&lt;/strong&gt;&lt;br&gt;
We centralize DB session logic using &lt;code&gt;sessionmanager&lt;/code&gt; to handle init/close properly with async SQLAlchemy.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="c1"&gt;# cli.py
&lt;/span&gt;&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;asyncio&lt;/span&gt;

&lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;typer&lt;/span&gt;

&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;app.seed.articles_seeder&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;seed_articles&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;app.seed.categories_seeder&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;seed_categories&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;app.seed.roles_seeder&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;seed_roles&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;app.services.config&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;config&lt;/span&gt;
&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;app.services.connection&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="n"&gt;sessionmanager&lt;/span&gt;

&lt;span class="n"&gt;cli&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;typer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;Typer&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;


&lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;run_seed&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;func&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="n"&gt;sessionmanager&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;init&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;config&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;db_dsn&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="k"&gt;with&lt;/span&gt; &lt;span class="n"&gt;sessionmanager&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;session&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="k"&gt;as&lt;/span&gt; &lt;span class="n"&gt;session&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
        &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;func&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;session&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;session&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;commit&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;sessionmanager&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;close&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;


&lt;span class="nd"&gt;@cli.command&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;roles&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
    &lt;span class="n"&gt;asyncio&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;run&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;run_seed&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;seed_roles&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;


&lt;span class="nd"&gt;@cli.command&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;categories&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
    &lt;span class="n"&gt;asyncio&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;run&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;run_seed&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;seed_categories&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;


&lt;span class="nd"&gt;@cli.command&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;articles&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt;
    &lt;span class="n"&gt;asyncio&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;run&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;run_seed&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;seed_articles&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt;


&lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;__name__&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;__main__&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="nf"&gt;cli&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;✅ 3. CLI with Typer&lt;/strong&gt;&lt;br&gt;
Typer gives us a clean CLI to run seed commands like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;python3 cli.py roles
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  ✉️ Conclusion:
&lt;/h3&gt;

&lt;p&gt;I didn’t go into too much detail here—just shared the core code for you to copy and use. Hopefully, you’re already familiar with Python and SQLAlchemy.&lt;/p&gt;

</description>
      <category>sqlalchemy</category>
      <category>python</category>
      <category>fastapi</category>
      <category>seed</category>
    </item>
    <item>
      <title>🐍 Don't Need to Create requirements.txt and .venv Manually [UV]</title>
      <dc:creator>Sajidur Rahman Shajib</dc:creator>
      <pubDate>Sun, 22 Jun 2025 11:47:01 +0000</pubDate>
      <link>https://dev.to/sajidurshajib/dont-need-to-create-requirementstxt-and-venv-manually-uv-mdd</link>
      <guid>https://dev.to/sajidurshajib/dont-need-to-create-requirementstxt-and-venv-manually-uv-mdd</guid>
      <description>&lt;p&gt;We need something better than &lt;code&gt;pip&lt;/code&gt; — and that's where &lt;a href="https://docs.astral.sh/uv/getting-started/features/" rel="noopener noreferrer"&gt;uv&lt;/a&gt; comes in. It’s a fast Python package manager and task runner that replaces &lt;code&gt;pip&lt;/code&gt;, &lt;code&gt;venv&lt;/code&gt;, and even parts of &lt;code&gt;poetry&lt;/code&gt;, without the extra overhead.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Though previously I wrote &lt;a href="https://dev.to/sajidurshajib/do-not-use-pip-freeze-1ikc"&gt;Do not use 'pip freeze'&lt;/a&gt; and &lt;a href="https://dev.to/sajidurshajib/best-way-to-create-requirementstxt-5co9"&gt;Best way to create requirements.txt&lt;/a&gt;. You can read them...&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h3&gt;
  
  
  🏁 First install &lt;code&gt;uv&lt;/code&gt;
&lt;/h3&gt;

&lt;p&gt;You can find the installation instructions for &lt;code&gt;uv&lt;/code&gt; &lt;a href="https://docs.astral.sh/uv/getting-started/installation/" rel="noopener noreferrer"&gt;here&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  🔧 &lt;code&gt;uv init&lt;/code&gt;: Instant Project Setup
&lt;/h3&gt;



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

&lt;/div&gt;



&lt;p&gt;This command creates a boilerplate &lt;code&gt;pyproject.toml&lt;/code&gt; and sets up your &lt;code&gt;.venv&lt;/code&gt; — no manual steps needed. It automatically detects your Python version and prepares a minimal project environment.&lt;/p&gt;




&lt;h3&gt;
  
  
  ➕ uv add: Add Dependencies Instantly
&lt;/h3&gt;

&lt;p&gt;Need a package like rich?&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;uv add rich
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This adds it to your &lt;code&gt;pyproject.toml&lt;/code&gt;, installs it, and updates your &lt;code&gt;uv.lock&lt;/code&gt;. No need to touch &lt;code&gt;requirements.txt&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Example usage with rich:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="kn"&gt;from&lt;/span&gt; &lt;span class="n"&gt;rich&lt;/span&gt; &lt;span class="kn"&gt;import&lt;/span&gt; &lt;span class="k"&gt;print&lt;/span&gt;

&lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;[bold green]Hello from UV-powered project![/bold green]&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  🚀 uv run: Run with Environment
&lt;/h3&gt;

&lt;p&gt;Instead of manually activating &lt;code&gt;.venv&lt;/code&gt;, use:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;uv run main.py
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This runs your app inside the managed environment automatically.&lt;/p&gt;

&lt;p&gt;Yes, you can still run with &lt;code&gt;python main.py&lt;/code&gt;, but that means you'll have to activate &lt;code&gt;.venv&lt;/code&gt; manually:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;&lt;span class="nb"&gt;source&lt;/span&gt; .venv/bin/activate
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  🔄 After Clone/Pull a UV based project
&lt;/h3&gt;

&lt;p&gt;First run&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;uv venv
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;and then install all packages from &lt;code&gt;pyproject.toml&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;uv &lt;span class="nb"&gt;sync&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  📚 Want More?
&lt;/h3&gt;

&lt;p&gt;There’s more you can do: &lt;code&gt;uv pip&lt;/code&gt;, &lt;code&gt;uv pip freeze&lt;/code&gt;, &lt;code&gt;uv sync --update&lt;/code&gt;, and more. You can even change &lt;strong&gt;Python versions&lt;/strong&gt; or set a specific version in &lt;code&gt;.python-version&lt;/code&gt; — check it out in their &lt;a href="https://docs.astral.sh/uv/getting-started/features/" rel="noopener noreferrer"&gt;docs&lt;/a&gt;.&lt;/p&gt;

</description>
      <category>python</category>
      <category>pip</category>
      <category>uv</category>
      <category>requirements</category>
    </item>
    <item>
      <title>🧠 What are Pages (in OS/memory)?</title>
      <dc:creator>Sajidur Rahman Shajib</dc:creator>
      <pubDate>Mon, 09 Jun 2025 03:31:06 +0000</pubDate>
      <link>https://dev.to/sajidurshajib/what-are-pages-in-osmemory-46gc</link>
      <guid>https://dev.to/sajidurshajib/what-are-pages-in-osmemory-46gc</guid>
      <description>&lt;p&gt;A &lt;strong&gt;page&lt;/strong&gt; is a fixed-length block of virtual memory. When discussing threads, processes, and system memory, &lt;strong&gt;paging&lt;/strong&gt; is a memory management scheme that eliminates the need for contiguous memory allocation.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;🔹 Key Points:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Size:&lt;/strong&gt; Typically 4 KB (can be 2 MB or more in modern systems).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Virtual Memory:&lt;/strong&gt; Programs access memory using virtual addresses, which the OS maps to physical memory using pages.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Page Table:&lt;/strong&gt; Maintains the mapping between virtual pages and physical frames.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Swapping:&lt;/strong&gt; When RAM is full, the OS can move pages to disk (swap space), making room for active data.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Benefits:&lt;/strong&gt; Prevents fragmentation and allows efficient use of memory.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;*** 📦 Real-world analogy:&lt;br&gt;
Think of memory as a book (RAM) and each page in the book is… a page. Programs don't care which physical page they're using; they just read "Page 5", and the OS finds the right actual page in the book.&lt;/p&gt;

&lt;p&gt;If you meant something else by “pages” (e.g., web pages), let me know. But in this HLD/fundamentals context, it's almost certainly &lt;strong&gt;memory pages&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>memory</category>
      <category>pages</category>
      <category>os</category>
      <category>swap</category>
    </item>
    <item>
      <title>🧪 Understanding the ACID Properties in Databases</title>
      <dc:creator>Sajidur Rahman Shajib</dc:creator>
      <pubDate>Mon, 09 Jun 2025 02:50:36 +0000</pubDate>
      <link>https://dev.to/sajidurshajib/understanding-the-acid-properties-in-databases-m2i</link>
      <guid>https://dev.to/sajidurshajib/understanding-the-acid-properties-in-databases-m2i</guid>
      <description>&lt;h2&gt;
  
  
  🔍 What is ACID?
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;ACID&lt;/strong&gt; stands for &lt;strong&gt;Atomicity, Consistency, Isolation, Durability&lt;/strong&gt; — four key properties that ensure reliable, safe, and predictable database transactions.&lt;br&gt;&lt;br&gt;
Together, they guarantee that your data remains accurate and stable, even in the face of errors or system crashes.&lt;/p&gt;




&lt;h2&gt;
  
  
  📖 A Short Story to Explain ACID
&lt;/h2&gt;

&lt;p&gt;Imagine a user named &lt;em&gt;Alice&lt;/em&gt; is signing up on your website. Here's what happens behind the scenes:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;A row is added to the &lt;code&gt;users&lt;/code&gt; table.&lt;/li&gt;
&lt;li&gt;A matching row is created in the &lt;code&gt;profile&lt;/code&gt; table with default info.&lt;/li&gt;
&lt;li&gt;A welcome product is added for her in the &lt;code&gt;products&lt;/code&gt; table.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Now let’s walk through ACID using this scenario:&lt;/p&gt;




&lt;h3&gt;
  
  
  🧩 A - &lt;strong&gt;Atomicity&lt;/strong&gt;
&lt;/h3&gt;

&lt;blockquote&gt;
&lt;p&gt;All or nothing. Either the entire operation completes, or nothing does.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;💡 If Alice's &lt;code&gt;users&lt;/code&gt; entry is created but something fails while inserting into the &lt;code&gt;profile&lt;/code&gt; table, &lt;strong&gt;Atomicity&lt;/strong&gt; ensures that the entire signup is rolled back — no partial data!&lt;/p&gt;




&lt;h3&gt;
  
  
  🛡️ C - &lt;strong&gt;Consistency&lt;/strong&gt;
&lt;/h3&gt;

&lt;blockquote&gt;
&lt;p&gt;Data must move from one valid state to another, maintaining all rules and constraints.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;💡 Suppose your app ensures every &lt;code&gt;profile&lt;/code&gt; must have a linked &lt;code&gt;user_id&lt;/code&gt; from the &lt;code&gt;users&lt;/code&gt; table. &lt;strong&gt;Consistency&lt;/strong&gt; makes sure this rule is never broken — if a &lt;code&gt;profile&lt;/code&gt; is created, the related &lt;code&gt;user&lt;/code&gt; must exist.&lt;/p&gt;




&lt;h3&gt;
  
  
  🔒 I - &lt;strong&gt;Isolation&lt;/strong&gt;
&lt;/h3&gt;

&lt;blockquote&gt;
&lt;p&gt;Transactions don’t interfere with each other; each feels like it's running alone.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;💡 While Alice is signing up, Bob is updating his &lt;code&gt;profile&lt;/code&gt;. &lt;strong&gt;Isolation&lt;/strong&gt; ensures these actions don’t clash — Bob doesn’t see Alice’s half-complete signup, and vice versa.&lt;/p&gt;




&lt;h3&gt;
  
  
  💾 D - &lt;strong&gt;Durability&lt;/strong&gt;
&lt;/h3&gt;

&lt;blockquote&gt;
&lt;p&gt;Once committed, the transaction stays committed — even if the system crashes.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;💡 After Alice completes her signup, even if the server crashes right after, the new entries in &lt;code&gt;users&lt;/code&gt;, &lt;code&gt;profile&lt;/code&gt;, and &lt;code&gt;products&lt;/code&gt; remain safe and saved. That's &lt;strong&gt;Durability&lt;/strong&gt;.&lt;/p&gt;




&lt;p&gt;✅ So next time you're working with databases, remember:&lt;br&gt;&lt;br&gt;
&lt;strong&gt;ACID = Trustworthy Transactions&lt;/strong&gt; 💡&lt;br&gt;&lt;br&gt;
They silently keep your app stable, safe, and smart.&lt;/p&gt;

</description>
      <category>database</category>
      <category>acid</category>
      <category>webdev</category>
      <category>softwaredevelopment</category>
    </item>
    <item>
      <title>🏛️ 5 Pillars of SOLID</title>
      <dc:creator>Sajidur Rahman Shajib</dc:creator>
      <pubDate>Fri, 06 Jun 2025 16:10:16 +0000</pubDate>
      <link>https://dev.to/sajidurshajib/5-pillars-of-solid-15gn</link>
      <guid>https://dev.to/sajidurshajib/5-pillars-of-solid-15gn</guid>
      <description>&lt;p&gt;When it comes to writing clean and maintainable code, the SOLID principles are essential tools every developer should know. But here’s the truth: it's not just about memorizing five fancy terms — it's about recognizing when and how to apply them in real code. You don’t need to recite the definitions — you need to practice them.&lt;br&gt;
The more you apply these principles, the more they become second nature, improving your design decisions over time. Keep this guide handy, and focus on using SOLID whenever you see the opportunity.&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Letter&lt;/th&gt;
&lt;th&gt;Principle Name&lt;/th&gt;
&lt;th&gt;Abbreviation&lt;/th&gt;
&lt;th&gt;Key Idea&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;S&lt;/td&gt;
&lt;td&gt;Single Responsibility Principle&lt;/td&gt;
&lt;td&gt;SRP&lt;/td&gt;
&lt;td&gt;One class = One responsibility&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;O&lt;/td&gt;
&lt;td&gt;Open/Closed Principle&lt;/td&gt;
&lt;td&gt;OCP&lt;/td&gt;
&lt;td&gt;Open to extension, closed to modification&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;L&lt;/td&gt;
&lt;td&gt;Liskov Substitution Principle&lt;/td&gt;
&lt;td&gt;LSP&lt;/td&gt;
&lt;td&gt;Subtypes must be substitutable for base types&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;I&lt;/td&gt;
&lt;td&gt;Interface Segregation Principle&lt;/td&gt;
&lt;td&gt;ISP&lt;/td&gt;
&lt;td&gt;No forcing of unused methods; favor small, focused interfaces&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;D&lt;/td&gt;
&lt;td&gt;Dependency Inversion Principle&lt;/td&gt;
&lt;td&gt;DIP&lt;/td&gt;
&lt;td&gt;Depend on abstractions, not concrete implementations&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

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

&lt;p&gt;✅ A class should have only one reason to change. Each class should handle a single part of the functionality.&lt;/p&gt;

&lt;h3&gt;
  
  
  🔥 Bad Example:
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;UserManager&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;add_user&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;user&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="c1"&gt;# Add user to database
&lt;/span&gt;        &lt;span class="k"&gt;pass&lt;/span&gt;

    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;send_email&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;user&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;message&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="c1"&gt;# Send welcome email
&lt;/span&gt;        &lt;span class="k"&gt;pass&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  ✅ Good Example:
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;UserManager&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;add_user&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;user&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="c1"&gt;# Add user to database
&lt;/span&gt;        &lt;span class="k"&gt;pass&lt;/span&gt;

&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;EmailService&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;send_email&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;user&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;message&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="c1"&gt;# Send email
&lt;/span&gt;        &lt;span class="k"&gt;pass&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  🎯 When &amp;amp; Why:
&lt;/h3&gt;

&lt;p&gt;Use SRP to make your code easier to understand, test, and modify. Changes in one responsibility won't break others.&lt;/p&gt;

&lt;h2&gt;
  
  
  🧱 O — Open/Closed Principle (OCP)
&lt;/h2&gt;

&lt;p&gt;✅ Software should be open for extension but closed for modification.&lt;/p&gt;

&lt;h3&gt;
  
  
  🔥 Bad Example:
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Discount&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;get_discount&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;customer_type&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="n"&gt;customer_type&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;regular&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="mf"&gt;0.1&lt;/span&gt;
        &lt;span class="k"&gt;elif&lt;/span&gt; &lt;span class="n"&gt;customer_type&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;vip&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
            &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="mf"&gt;0.2&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  ✅ Good Example:
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Discount&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;get_discount&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="mf"&gt;0.0&lt;/span&gt;

&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;RegularDiscount&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="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;get_discount&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="mf"&gt;0.1&lt;/span&gt;

&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;VIPDiscount&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="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;get_discount&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="mf"&gt;0.2&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  🎯 When &amp;amp; Why:
&lt;/h3&gt;

&lt;p&gt;Use it when you expect requirements to evolve. This allows you to add new behavior with new classes without touching existing tested code.&lt;/p&gt;

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

&lt;p&gt;✅ Subclasses should be replaceable for their parent classes without altering program behavior.&lt;/p&gt;

&lt;h3&gt;
  
  
  🔥 Bad Example:
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Bird&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;fly&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Flying&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Penguin&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Bird&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;fly&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="k"&gt;raise&lt;/span&gt; &lt;span class="nc"&gt;Exception&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Penguins can&lt;/span&gt;&lt;span class="sh"&gt;'&lt;/span&gt;&lt;span class="s"&gt;t fly&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  ✅ Good Example:
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Bird&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;pass&lt;/span&gt;

&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;FlyingBird&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Bird&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;fly&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Flying&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Penguin&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Bird&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;swim&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="s"&gt;Swimming&lt;/span&gt;&lt;span class="sh"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  🎯 When &amp;amp; Why:
&lt;/h3&gt;

&lt;p&gt;The Liskov Substitution Principle (LSP) applies when using inheritance. It ensures that a subclass can stand in for its parent class without breaking the program.&lt;/p&gt;

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

&lt;p&gt;✅ Clients should not be forced to depend on methods they do not use.&lt;/p&gt;

&lt;h3&gt;
  
  
  🔥 Bad Example:
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Machine&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="k"&gt;pass&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;scan&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="k"&gt;pass&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;fax&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="k"&gt;pass&lt;/span&gt;

&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;OldPrinter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Machine&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="k"&gt;pass&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;scan&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="k"&gt;raise&lt;/span&gt; &lt;span class="nc"&gt;NotImplementedError&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;fax&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="k"&gt;raise&lt;/span&gt; &lt;span class="nc"&gt;NotImplementedError&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  ✅ Good Example:
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Printer&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="k"&gt;pass&lt;/span&gt;

&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Scanner&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;scan&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="k"&gt;pass&lt;/span&gt;

&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Fax&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;fax&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="k"&gt;pass&lt;/span&gt;

&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;OldPrinter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Printer&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;print&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="k"&gt;pass&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  🎯 When &amp;amp; Why:
&lt;/h3&gt;

&lt;p&gt;Use ISP to keep interfaces lean and focused. This avoids forcing classes to implement irrelevant functionality.&lt;/p&gt;

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

&lt;p&gt;✅ High-level modules should depend on abstractions, not on low-level modules.&lt;/p&gt;

&lt;h3&gt;
  
  
  🔥 Bad Example:
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;MySQLDatabase&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;connect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="k"&gt;pass&lt;/span&gt;

&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;DataService&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;__init__&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;db&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nc"&gt;MySQLDatabase&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  ✅ Good Example:
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight python"&gt;&lt;code&gt;&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;Database&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;connect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="k"&gt;pass&lt;/span&gt;

&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;MySQLDatabase&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;Database&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;connect&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="k"&gt;pass&lt;/span&gt;

&lt;span class="k"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;DataService&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="k"&gt;def&lt;/span&gt; &lt;span class="nf"&gt;__init__&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="n"&gt;db&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;Database&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt;
        &lt;span class="n"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="n"&gt;db&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="n"&gt;db&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  🎯 When &amp;amp; Why:
&lt;/h3&gt;

&lt;p&gt;Use DIP to make your code more testable and flexible. It allows you to swap out implementations (e.g., use a mock DB during tests).&lt;/p&gt;

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

&lt;p&gt;The SOLID principles are timeless guidelines for writing clean, modular, and maintainable object-oriented code. By following:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;SRP — keep responsibilities focused,&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;OCP — allow easy feature expansion,&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;LSP — ensure consistent behavior in subclasses,&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;ISP — build focused and usable interfaces,&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;DIP — depend on abstractions for flexibility,&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;you create software that is easier to test, scale, and adapt to change. Applying SOLID isn't about rigid rules — it's about writing thoughtful, future-proof code.&lt;/p&gt;

</description>
      <category>programming</category>
      <category>cleancode</category>
      <category>solid</category>
      <category>softwaredevelopment</category>
    </item>
    <item>
      <title>🧵 Thread vs Process in a nutshell</title>
      <dc:creator>Sajidur Rahman Shajib</dc:creator>
      <pubDate>Thu, 05 Jun 2025 01:33:46 +0000</pubDate>
      <link>https://dev.to/sajidurshajib/thread-vs-process-in-a-nutshell-5bjp</link>
      <guid>https://dev.to/sajidurshajib/thread-vs-process-in-a-nutshell-5bjp</guid>
      <description>&lt;p&gt;Understanding the difference between a &lt;strong&gt;thread&lt;/strong&gt; and a &lt;strong&gt;process&lt;/strong&gt; is fundamental to building scalable and efficient systems.&lt;/p&gt;




&lt;h3&gt;
  
  
  🔸 What is a Process?
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;A &lt;strong&gt;process&lt;/strong&gt; is an independent &lt;strong&gt;program in execution&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;It has its own &lt;strong&gt;memory space&lt;/strong&gt;, including code, data, and system resources.&lt;/li&gt;
&lt;li&gt;Starting an application (like a browser or server) creates a new process.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  🔸 What is a Thread?
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;A &lt;strong&gt;thread&lt;/strong&gt; is a &lt;strong&gt;smaller unit of execution&lt;/strong&gt; within a process.&lt;/li&gt;
&lt;li&gt;All threads in a process &lt;strong&gt;share the same memory space and resources&lt;/strong&gt;, but each has its own &lt;strong&gt;call stack&lt;/strong&gt; and &lt;strong&gt;program counter&lt;/strong&gt;.&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  🧠 Analogy
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Concept&lt;/th&gt;
&lt;th&gt;Analogy&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Process&lt;/td&gt;
&lt;td&gt;A house&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Thread&lt;/td&gt;
&lt;td&gt;People living in the house&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Shared memory&lt;/td&gt;
&lt;td&gt;Rooms and furniture (shared by all)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Stack&lt;/td&gt;
&lt;td&gt;Each person's backpack (private)&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;h3&gt;
  
  
  🧪 Real-World Example: Web Browser
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Process&lt;/strong&gt;: Running the Chrome browser.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Threads&lt;/strong&gt;: 

&lt;ul&gt;
&lt;li&gt;One for the user interface,&lt;/li&gt;
&lt;li&gt;One for each tab,&lt;/li&gt;
&lt;li&gt;One for rendering,&lt;/li&gt;
&lt;li&gt;One for background tasks.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;




&lt;h3&gt;
  
  
  📊 Key Differences
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Feature&lt;/th&gt;
&lt;th&gt;Process&lt;/th&gt;
&lt;th&gt;Thread&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Memory&lt;/td&gt;
&lt;td&gt;Has its own memory space&lt;/td&gt;
&lt;td&gt;Shares memory with other threads&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Overhead&lt;/td&gt;
&lt;td&gt;Higher (more OS resources)&lt;/td&gt;
&lt;td&gt;Lower (lightweight)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Communication&lt;/td&gt;
&lt;td&gt;Requires IPC&lt;/td&gt;
&lt;td&gt;Can use shared memory&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Fault Isolation&lt;/td&gt;
&lt;td&gt;Crash in one doesn’t affect others&lt;/td&gt;
&lt;td&gt;Crash in one can crash the whole process&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Creation Time&lt;/td&gt;
&lt;td&gt;Slower&lt;/td&gt;
&lt;td&gt;Faster&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;h3&gt;
  
  
  🔧 Why It Matters in System Design
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Threads enable &lt;strong&gt;concurrency&lt;/strong&gt;, improving responsiveness and throughput.&lt;/li&gt;
&lt;li&gt;Processes provide &lt;strong&gt;isolation&lt;/strong&gt;, which is safer for unstable or critical tasks.&lt;/li&gt;
&lt;li&gt;Choose based on:

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Speed&lt;/strong&gt; vs. &lt;strong&gt;Safety&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;Available &lt;strong&gt;memory/CPU&lt;/strong&gt;
&lt;/li&gt;
&lt;li&gt;Need to &lt;strong&gt;share or isolate data&lt;/strong&gt;
&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;




&lt;p&gt;Understanding threads and processes helps you make better choices when designing everything from web servers to distributed systems.&lt;/p&gt;

</description>
      <category>thread</category>
      <category>process</category>
      <category>systemdesign</category>
      <category>nutshell</category>
    </item>
    <item>
      <title>🛠️ Functional and Non-Functional Requirements: Explained</title>
      <dc:creator>Sajidur Rahman Shajib</dc:creator>
      <pubDate>Wed, 28 May 2025 19:42:06 +0000</pubDate>
      <link>https://dev.to/sajidurshajib/functional-and-non-functional-requirements-explained-5gf9</link>
      <guid>https://dev.to/sajidurshajib/functional-and-non-functional-requirements-explained-5gf9</guid>
      <description>&lt;p&gt;When building a software system, requirements are usually classified into two main categories:&lt;/p&gt;

&lt;h3&gt;
  
  
  🛠️ Functional Requirements
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Definition:&lt;/strong&gt; Functional requirements specify what the system should do. They describe the core features, functions, and behaviors of the system.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Examples:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A user can register with their email and password.&lt;/li&gt;
&lt;li&gt;The system should send a confirmation email after registration.&lt;/li&gt;
&lt;li&gt;The admin can delete user accounts.&lt;/li&gt;
&lt;li&gt;The search bar should return results based on keywords.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These are user-facing behaviors or operations that define how the system reacts to inputs.&lt;/p&gt;

&lt;h3&gt;
  
  
  🧱 Non-Functional Requirements
&lt;/h3&gt;

&lt;p&gt;&lt;strong&gt;Definition:&lt;/strong&gt; Non-functional requirements describe how the system performs under certain conditions. They are about quality attributes like performance, security, reliability, usability, etc.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Examples:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The system should load the dashboard within 2 seconds (Performance).&lt;/li&gt;
&lt;li&gt;The system must support up to 10,000 concurrent users (Scalability).&lt;/li&gt;
&lt;li&gt;All user data should be encrypted in transit and at rest (Security).&lt;/li&gt;
&lt;li&gt;The app should have 99.9% uptime (Reliability).&lt;/li&gt;
&lt;li&gt;The UI should be mobile-friendly and accessible (Usability).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These are not directly related to a specific function but rather to the overall system behavior.&lt;/p&gt;

&lt;h3&gt;
  
  
  🎯 Key Differences
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Feature&lt;/th&gt;
&lt;th&gt;Functional Requirements&lt;/th&gt;
&lt;th&gt;Non-Functional Requirements&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Focus&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;What the system should do&lt;/td&gt;
&lt;td&gt;How the system should perform&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Examples&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Login, search, upload image&lt;/td&gt;
&lt;td&gt;Performance, security, usability&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Direct User Interaction&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;td&gt;Often indirectly noticed&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Measurable By&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Pass/fail test cases&lt;/td&gt;
&lt;td&gt;Metrics (e.g., response time, uptime)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;strong&gt;Type of Requirement&lt;/strong&gt;&lt;/td&gt;
&lt;td&gt;Business logic/features&lt;/td&gt;
&lt;td&gt;System attributes or quality factors&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h3&gt;
  
  
  ✅ Conclusion
&lt;/h3&gt;

&lt;p&gt;Functional requirements define what a system should do, while non-functional requirements define how well it should perform. Both are crucial for delivering a complete and reliable software product.&lt;/p&gt;

</description>
      <category>systemdesign</category>
      <category>webdev</category>
      <category>programming</category>
      <category>softwaredevelopment</category>
    </item>
    <item>
      <title>🧠 Understanding HLD and LLD in System Design: A Developer's Guide</title>
      <dc:creator>Sajidur Rahman Shajib</dc:creator>
      <pubDate>Wed, 28 May 2025 19:16:07 +0000</pubDate>
      <link>https://dev.to/sajidurshajib/understanding-hld-and-lld-in-system-design-a-developers-guide-22j6</link>
      <guid>https://dev.to/sajidurshajib/understanding-hld-and-lld-in-system-design-a-developers-guide-22j6</guid>
      <description>&lt;p&gt;In the world of software engineering, designing systems that are scalable, maintainable, and robust is just as important as writing clean code. That’s where System Design comes in — and within system design, two foundational concepts stand out: &lt;strong&gt;High-Level Design (HLD)&lt;/strong&gt; and &lt;strong&gt;Low-Level Design (LLD)&lt;/strong&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  🧩 What is High-Level Design (HLD)?
&lt;/h2&gt;

&lt;p&gt;High-Level Design is the architectural blueprint of a system. It focuses on what the system should do and how major components interact with each other.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;🧱 Key Characteristics:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Describes the overall architecture&lt;/li&gt;
&lt;li&gt;Focuses on major modules and data flow&lt;/li&gt;
&lt;li&gt;Identifies external interfaces&lt;/li&gt;
&lt;li&gt;Helps in choosing the tech stack&lt;/li&gt;
&lt;li&gt;Think in terms of services, databases, queues, APIs&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;🗂️ Typical Artifacts:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;System architecture diagram&lt;/li&gt;
&lt;li&gt;Component diagrams&lt;/li&gt;
&lt;li&gt;ER diagrams (basic database design)&lt;/li&gt;
&lt;li&gt;Deployment diagrams (cloud setup, containerization)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;🔍 Example:&lt;/strong&gt;&lt;br&gt;
In an e-commerce system, HLD would define separate services for:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;User Authentication&lt;/li&gt;
&lt;li&gt;Product Catalog&lt;/li&gt;
&lt;li&gt;Order Management&lt;/li&gt;
&lt;li&gt;Payment Processing&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It would also define how these services interact, and what technologies (e.g., PostgreSQL, Redis, Kafka) will be used.&lt;/p&gt;

&lt;h2&gt;
  
  
  🔧 What is Low-Level Design (LLD)?
&lt;/h2&gt;

&lt;p&gt;Low-Level Design dives into the implementation details. It defines how each module or component will work internally.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;⚙️ Key Characteristics:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Describes class structures, methods, and relationships&lt;/li&gt;
&lt;li&gt;Defines database schema in detail (tables, indexes, keys)&lt;/li&gt;
&lt;li&gt;Specifies API request/response formats&lt;/li&gt;
&lt;li&gt;Documents business logic and algorithms&lt;/li&gt;
&lt;li&gt;Highlights design patterns (e.g., Singleton, Strategy)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;🗂️ Typical Artifacts:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Class diagrams (UML)&lt;/li&gt;
&lt;li&gt;Sequence diagrams&lt;/li&gt;
&lt;li&gt;Detailed database schema&lt;/li&gt;
&lt;li&gt;Pseudocode or function definitions&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;🔍 Example:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;For the Order Management service, LLD would define:&lt;/li&gt;
&lt;li&gt;A &lt;code&gt;OrderService&lt;/code&gt; class with methods like &lt;code&gt;createOrder()&lt;/code&gt;, &lt;code&gt;cancelOrder()&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;DB tables: &lt;code&gt;orders&lt;/code&gt;, &lt;code&gt;order_items&lt;/code&gt;, with constraints&lt;/li&gt;
&lt;li&gt;Use of design patterns (e.g., Repository for DB access)&lt;/li&gt;
&lt;li&gt;Detailed API contract:
&lt;code&gt;POST /orders&lt;/code&gt; with &lt;code&gt;request/response&lt;/code&gt; structure&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  🆚 HLD vs LLD – Key Differences
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Feature&lt;/th&gt;
&lt;th&gt;HLD&lt;/th&gt;
&lt;th&gt;LLD&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Level of Detail&lt;/td&gt;
&lt;td&gt;Abstract / Architectural&lt;/td&gt;
&lt;td&gt;Detailed / Code-level&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Focus&lt;/td&gt;
&lt;td&gt;What the system does &amp;amp; interacts with&lt;/td&gt;
&lt;td&gt;How the system works internally&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Audience&lt;/td&gt;
&lt;td&gt;Architects, leads, stakeholders&lt;/td&gt;
&lt;td&gt;Developers and implementers&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Artifacts&lt;/td&gt;
&lt;td&gt;Component diagrams, tech stack&lt;/td&gt;
&lt;td&gt;Class diagrams, DB schema, APIs&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Timing&lt;/td&gt;
&lt;td&gt;Early in design phase&lt;/td&gt;
&lt;td&gt;Right before development starts&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;h3&gt;
  
  
  🧠 Why Both Are Important
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;HLD&lt;/strong&gt; helps align the vision of the system across teams and stakeholders.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;LLD&lt;/strong&gt; ensures developers have a clear path to start building the system.&lt;/li&gt;
&lt;li&gt;Together, they bridge the gap from idea to implementation.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;🏁 Conclusion&lt;/strong&gt;&lt;br&gt;
Whether you’re preparing for a system design interview or planning a real-world application, understanding both HLD and LLD is crucial. Start with the big picture (HLD), then dive deep into the building blocks (LLD).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;📌 Pro Tip:&lt;/strong&gt; Always validate your HLD before jumping into LLD. A shaky foundation can break the entire system!&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;💬 What’s your experience with HLD and LLD?&lt;/strong&gt;&lt;br&gt;
Have you worked on a project where skipping one of them caused problems later?&lt;br&gt;
Let’s discuss in the comments 👇&lt;/p&gt;

</description>
      <category>system</category>
      <category>design</category>
      <category>developers</category>
      <category>programming</category>
    </item>
  </channel>
</rss>
