<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Muhammad Bilal Khalid on Medium]]></title>
        <description><![CDATA[Stories by Muhammad Bilal Khalid on Medium]]></description>
        <link>https://medium.com/@mbkhalid23?source=rss-1aca216d88a4------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*punC2F8FeMpv1jcHQVUbEA.png</url>
            <title>Stories by Muhammad Bilal Khalid on Medium</title>
            <link>https://medium.com/@mbkhalid23?source=rss-1aca216d88a4------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 23 Nov 2026 15:51:27 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@mbkhalid23/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Courage Before Certainty: Leadership Begins Long Before Recognition]]></title>
            <link>https://medium.com/@mbkhalid23/courage-before-certainty-leadership-begins-long-before-recognition-4e6b539e2efb?source=rss-1aca216d88a4------2</link>
            <guid isPermaLink="false">https://medium.com/p/4e6b539e2efb</guid>
            <category><![CDATA[leadership]]></category>
            <category><![CDATA[personal-development]]></category>
            <category><![CDATA[self-improvement]]></category>
            <category><![CDATA[life-lessons]]></category>
            <category><![CDATA[personal-growth]]></category>
            <dc:creator><![CDATA[Muhammad Bilal Khalid]]></dc:creator>
            <pubDate>Sun, 24 May 2026 15:33:09 GMT</pubDate>
            <atom:updated>2026-05-24T15:33:09.650Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*8J3giJLQSIBRnkoZ" /><figcaption>Photo by <a href="https://unsplash.com/@nayanbhalotia?utm_source=medium&amp;utm_medium=referral">Nayan Bhalotia</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a></figcaption></figure><p>Time and again, history has seen people who changed the course of the world.</p><p>And interestingly, they were rarely the most brilliant minds or the most powerful people in existence.</p><p>There have always been people who were smarter, more connected, more powerful and far more qualified on paper.</p><p>Yet most of them were forgotten.</p><p>So what did these people have that others didn’t?</p><p>What made them the kind of leaders the world remembers centuries later?</p><p>I have often found myself thinking about that question.</p><p>And while leadership is far too deep a topic to be contained in a single piece of writing, here are some of the things I have consistently observed in great leaders throughout history.</p><h3>Leaders Inspire Action, They Don’t Motivate</h3><p>John Quincy Adams once said:</p><blockquote><em>“If your actions inspire others to dream more, learn more, do more and become more, you are a leader.”</em></blockquote><p>There is a very important word in what Adams has said, <strong>inspire</strong>.</p><p>People often confuse motivation with inspiration. But I think they are very different things.</p><p>Motivation is external, fades quickly and is never there when you need it.</p><p>Inspiration, on the other hand, is internal. It is the thing that wakes you up in the morning and keeps you moving even when nobody is watching.</p><p>When someone is truly inspired, they no longer need constant reminders, rewards or motivational speeches. Their purpose becomes their fuel.</p><p>One of my favorite stories on this topic is the Wright brothers.</p><p>When the Wright brothers were trying to build the first airplane, they had almost everything working against them.</p><p>They had no formal engineering degrees, no government funding and no large research teams backing them.</p><p>At the same time, some of the brightest minds in America, backed by serious money and institutions, were trying to solve the exact same problem.</p><p>Yet the Wright brothers succeeded first.</p><p>Why?</p><p>Because many of the others were motivated by rewards, fame and recognition.</p><p>The Wright brothers were inspired by the idea itself.</p><p>They genuinely believed human beings were meant to fly.</p><p>And when people are truly inspired by something, they continue long after motivation would have died.</p><p>Great leaders understand this deeply.</p><p>They do not push people with pressure alone. They create belief. They make people feel capable of more than they originally thought possible.</p><p>That kind of influence lasts much longer than motivation ever can.</p><h3>Leadership Begins the Moment Someone Steps Forward</h3><p>History gives us one of the clearest examples of this.</p><p>During the Muslim campaign against the Sassanid Empire, reinforcements were requested from Madinah.</p><p>The Caliph Umar ibn Al-Khattab gathered the Muslims and informed them about the situation. He spoke about the victories, the urgency and the need for people to join the army.</p><p>But after he finished speaking, the gathering fell silent.</p><p>Nobody moved.</p><p>Until one man stood up.</p><p>It was Abu Ubaid al-Thaqafi.</p><p>He was not from the great Qurayshi aristocratic families. He was not among the companions. His legacy was not inherited from status or lineage.</p><p>It was built by his own courage.</p><p>He simply said:</p><blockquote><em>“I will go.”</em></blockquote><p>The silence broke.</p><p>That courage became contagious.</p><p>One by one people started stepping forward. Then dozens. Then hundreds. Then thousands.</p><p>A Muslim army was assembled and the Caliph appointed Abu Ubaid as the leader of the army even over prominent companions.</p><p>When asked, why did he not appoint one of the companions as the leader of the army, the Caliph relied:</p><blockquote><em>“I will appoint over you the first to respond when his brothers needed him. The honor of precedence in faith belongs to the companions. But the command of the army belongs to the man who steps forward when others went silent.”</em></blockquote><p>Abu Ubaid had no titles, no authority, and no seniority. Yet he was recognized as the leader of the army.</p><p>Leadership often begins in moments like these where someone chooses courage while everyone else waits for certainty.</p><p>Most people think leaders are created after recognition.</p><p>I think true leadership appears much earlier than that.</p><p>It appears the moment someone takes responsibility before anyone asks them to.</p><h3>Leaders Give Vision, Not Instructions</h3><p>One of the most powerful leadership figures in history is Martin Luther King Jr.</p><p>Thousands of people gathered in Washington DC to hear him speak during one of the most difficult periods in American history.</p><p>His speech became immortal because of one sentence:</p><blockquote><em>“I have a dream…”</em></blockquote><p>Not,</p><p>“I have a plan!”</p><p>That difference matters more than we realize.</p><p>A plan tells people what to do. A vision tells people why it matters.</p><p>Great leaders make people feel connected to something bigger than themselves. They help people see a future that feels meaningful enough to struggle for.</p><p>People were not standing there just for Martin Luther King. They were standing there for a future they could finally imagine.</p><p>They were standing for themselves!</p><p>That is the power of vision.</p><p>Leadership is not waiting until you have the title, the authority or the perfect moment.</p><p>It is the willingness to step forward before any of that arrives.</p><p>Abu Ubaid did not wait for rank or recognition.</p><p>The Wright brothers did not wait for belief or approval.</p><p>Martin Luther King didn’t just plan. He dreamed.</p><p>The people who move history are rarely the most qualified. They are the ones willing to step forward first.</p><p>And maybe that’s what leadership truly is.</p><p>Not status.<br>Not seniority.<br>Not control.</p><p>Just the courage to step forward while everyone else waits for certainty.</p><p>That step is available to all of us.</p><p>The only question is whether we’ll take it.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4e6b539e2efb" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Stop Adding Unnecessary Abstractions: My 3-Question Kill-Switch for Over-Engineering]]></title>
            <link>https://blog.stackademic.com/stop-overengineering-the-3-question-test-that-saves-weeks-of-wasted-work-ea072304df9a?source=rss-1aca216d88a4------2</link>
            <guid isPermaLink="false">https://medium.com/p/ea072304df9a</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[software-architecture]]></category>
            <category><![CDATA[clean-code]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[clean-architecture]]></category>
            <dc:creator><![CDATA[Muhammad Bilal Khalid]]></dc:creator>
            <pubDate>Mon, 27 Oct 2025 09:09:52 GMT</pubDate>
            <atom:updated>2025-11-02T15:11:58.748Z</atom:updated>
            <content:encoded><![CDATA[<h4>Here’s how to ship faster by knowing when NOT to build something.</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3-X3b-Cw7uVOKmyJriZYdg.png" /><figcaption>Stop Overengineering — The 3-Question Test Every Developer Needs</figcaption></figure><blockquote><em>Not a member? You can read the </em><a href="https://open.substack.com/pub/mbkhalid/p/stop-adding-unnecessary-abstractions?r=2b7m03&amp;utm_campaign=post&amp;utm_medium=web&amp;showWelcomeOnShare=false"><em>full story on Substack for free!</em></a></blockquote><p>Here’s something nobody tells you when you’re learning to code: <strong>more projects fail from overengineering than from bad code.</strong></p><p>I learned this the hard way. Three years into my career, I was that developer who obsessed over abstractions, built elaborate design patterns, and could justify every architectural decision with textbook precision. I felt <em>good</em> about my work.</p><p>Then I started noticing the pattern. Features that should’ve taken days were taking weeks. All that “future-proofing” I’d built? Most of those future scenarios never happened.</p><p>I was shipping slower, building for problems that didn’t exist, while real user needs waited.</p><p>That’s when I realized: <strong>knowing when NOT to build something is just as critical as knowing how to build it well.</strong></p><h3>Why Smart Developers Overengineer</h3><p>We do it because we care. We want scalable systems, clean architecture, code that won’t need rewrites six months from now. We’re following best practices, doing things “the right way.”</p><p>But here’s the uncomfortable truth I’ve discovered: <strong>most of the future we design for never actually arrives.</strong></p><p>And here’s the thing: <strong>it doesn’t feel wrong while you’re doing it.</strong> You’re learning, applying solid principles, building professional-grade systems. Everyone’s happy.</p><p>But there’s a hidden cost accumulating beneath the surface.</p><h3>The Real Cost Nobody Talks About</h3><p>The problem with overengineering isn’t dramatic failure. It’s <strong>quiet inefficiency</strong> that compounds over time.</p><p><strong>You spend more time maintaining abstractions than solving actual problems.</strong> That “flexible” system becomes rigid because changing it means updating five interconnected pieces.</p><p><strong>You’re shipping slower than you need to.</strong> Every extra abstraction is another decision point, another layer to think through. That feature that could’ve taken two days now takes a week because you’re “doing it right.”</p><p><strong>Technical debt accumulates in disguise.</strong> Those flexible abstractions? They become rigid constraints. You thought you were preventing technical debt, but you were creating a different kind.</p><p><strong>Performance takes hidden hits.</strong> All those layers, all that flexibility, it’s not free. Your app is carrying weight it doesn’t need, running code for scenarios that will never happen.</p><p><strong>And here’s the kicker:</strong> Most of the flexibility you build for? Those future use cases you’re preparing for? <strong>They never actually arrive.</strong></p><p>Requirements change. The product pivots. That “definitely coming” feature gets canceled. You spent time and added complexity for a future that didn’t happen.</p><p>Meanwhile, you could’ve shipped faster, simpler, and been ready to adapt when you <em>actually</em> knew what was needed.</p><h3>The Mindset Shift That Changed Everything</h3><p>Good code solves today’s problems and leaves room to evolve tomorrow. That’s it.</p><p>It doesn’t try to predict every scenario. It doesn’t build for imaginary scale. It doesn’t create abstractions just because they’re “proper.”</p><p><strong>Simplicity isn’t laziness, it’s discipline.</strong> Every line of code is a liability until it proves its value. Every abstraction is overhead until it earns its keep.</p><p>The best engineers I’ve worked with? They don’t build perfect systems. They build <em>sensible</em> ones. They know complexity is easy, simplicity takes thought.</p><h3>My “Now / Later / Never” Filter</h3><p>Over the years, I’ve developed a three-question sanity check I run before adding any new abstraction, pattern, or architectural layer. It’s saved me countless hours and kept my codebases actually maintainable.</p><h4>🟢 Question 1: Does this solve a problem we have right now?</h4><p>If yes — build it. If no — stop.</p><p>This is your primary filter. Be ruthlessly honest here.</p><p><strong>Ask yourself:</strong></p><ul><li>What actually breaks if I don’t add this today?</li><li>Is anyone blocked by the current simple solution?</li><li>Am I solving a real pain point or an imaginary one?</li></ul><p><strong>If the answer is “nothing breaks”, it’s not a “now” problem.</strong> And “now” problems are the only ones worth solving today.</p><h4>🟡 Question 2: If not now, will it definitely be needed later?</h4><p>Sometimes you actually know what’s coming. A confirmed roadmap item. A pattern you’ve seen emerge three times already. A specific requirement from stakeholders with a hard deadline.</p><p>Notice the word “definitely.” Not “might.” Not “could.” <strong>Definitely.</strong></p><p><strong>The test:</strong></p><ul><li>Can you point to a concrete, scheduled future use case?</li><li>Has this exact need appeared multiple times already?</li><li>Do you have actual data suggesting this will matter?</li></ul><p>If you’re building based on “what if” or “just in case”, you’re guessing. And engineering based on guesses is expensive.</p><p>Here’s what I’ve learned: <strong>You can’t future-proof what you don’t understand yet.</strong> The future becomes clear after you’ve lived it once. That’s when you know exactly what abstraction you need.</p><p>Until then? You’re probably building the wrong thing anyway.</p><h4>🔴 Question 3: If neither, why am I really adding it?</h4><p>This is your stop sign.</p><p>Be honest with yourself. If it’s not solving a current problem and not clearly needed soon, why are you building it?</p><p>Usually, it’s one of these:</p><ul><li><strong>Habit: </strong>“This is how we’re supposed to architect things”</li><li><strong>Fear: </strong>“What if we need to change this later?”</li><li><strong>Resume-driven development: </strong>“This pattern will look great in my portfolio”</li><li><strong>Intellectual curiosity: </strong>“This would be fun to build”</li></ul><p>All of these are valid feelings. None of them justify adding complexity to production code.</p><p><strong>If your abstraction exists mainly to look smart or feel sophisticated, it’s already technical debt.</strong></p><p>Delete it. Ship simpler. You’ll move faster, your team will thank you, and you’ll actually sleep better.</p><h3>The Real Skill: Knowing When to Stop</h3><p>After a few years in this industry, I’ve realized the most valuable developers aren’t the ones who can build the most complex systems. They’re the ones who know when not to.</p><p>They ship working code instead of perfect architecture. They write clear solutions instead of clever ones. They build for today’s problems while staying ready to evolve.</p><p>That’s not being lazy or short-sighted. That’s being efficient. That’s being practical.</p><p><strong>You can always add complexity later when you actually need it. Removing unnecessary complexity costs many times more.</strong></p><h3>Your Challenge</h3><p>Next time you’re about to add a new layer, abstraction, or pattern, pause. Run it through the filter:</p><p><strong>Now?</strong> Build it.<br><strong>Later?</strong> Prepare for it specifically.<br><strong>Never?</strong> Delete it.</p><p>You’ll be amazed how much faster you move when you stop carrying weight you don’t need.</p><p><strong>What’s your experience with overengineering?</strong> I’d love to hear your stories, both the times you got burned by too much architecture and the times you successfully kept things simple. Drop a comment below! 👇</p><p>Hi, I’m Bilal, a .NET developer sharing what I learn about building software, thinking in systems, and writing clean, practical code.</p><p>If you’re exploring similar ideas, <a href="https://www.linkedin.com/in/mbkhalid23?utm_source=share&amp;utm_campaign=share_via&amp;utm_content=profile&amp;utm_medium=android_app">let’s connect</a> and learn together.</p><h3>A message from our Founder</h3><p><strong>Hey, </strong><a href="https://linkedin.com/in/sunilsandhu"><strong>Sunil</strong></a><strong> here.</strong> I wanted to take a moment to thank you for reading until the end and for being a part of this community.</p><p>Did you know that our team run these publications as a volunteer effort to over 3.5m monthly readers? <strong>We don’t receive any funding, we do this to support the community. ❤️</strong></p><p>If you want to show some love, please take a moment to <strong>follow me on </strong><a href="https://linkedin.com/in/sunilsandhu"><strong>LinkedIn</strong></a><strong>, </strong><a href="https://tiktok.com/@messyfounder"><strong>TikTok</strong></a>, <a href="https://instagram.com/sunilsandhu"><strong>Instagram</strong></a>. You can also subscribe to our <a href="https://newsletter.plainenglish.io/"><strong>weekly newsletter</strong></a>.</p><p>And before you go, don’t forget to <strong>clap</strong> and <strong>follow</strong> the writer️!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ea072304df9a" width="1" height="1" alt=""><hr><p><a href="https://blog.stackademic.com/stop-overengineering-the-3-question-test-that-saves-weeks-of-wasted-work-ea072304df9a">Stop Adding Unnecessary Abstractions: My 3-Question Kill-Switch for Over-Engineering</a> was originally published in <a href="https://blog.stackademic.com/">Stackademic</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[3 Things Average Developers Do (That Good Developers Never Do)]]></title>
            <link>https://levelup.gitconnected.com/good-developers-vs-average-developers-64585f15e26b?source=rss-1aca216d88a4------2</link>
            <guid isPermaLink="false">https://medium.com/p/64585f15e26b</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[product-thinking]]></category>
            <category><![CDATA[mindset-shift]]></category>
            <category><![CDATA[software-architecture]]></category>
            <dc:creator><![CDATA[Muhammad Bilal Khalid]]></dc:creator>
            <pubDate>Tue, 14 Oct 2025 02:20:01 GMT</pubDate>
            <atom:updated>2025-10-16T17:00:16.388Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*7vCUUIStCEkL8qsN-_LYAQ.png" /><figcaption>Good Developers vs Average Developers — CEO’s Perspective</figcaption></figure><p>Ever wonder why two developers with the same technical skills end up in completely different places a few years later?</p><p>One becomes the go-to person everyone trusts for critical projects. The other keeps doing solid work but never seems to stand out.</p><p>I asked a CEO what separates the ones who grow fast from those who just stagnate.</p><p>His answer boiled down to three things, none of them technical, but all of them game-changing.</p><p>These are the quiet habits that consistently turn average developers into great ones.</p><h3><strong>So What Makes a Good Developer?</strong></h3><p>According to the CEO I spoke with, there are three main things he looks for in a developer.</p><h4>1. Asking Questions and Planning Before Starting Development</h4><p>A good developer takes time to properly review the requirements, designs, and flows before writing any code.</p><p>They don’t make assumptions. They ask questions, clarify doubts, and make sure they understand the complete picture before diving in.</p><p>An average developer, on the other hand, jumps straight into coding. They skip the review process and rely on their assumptions. And more often than not, those assumptions turn out to be wrong.</p><p>The result? Rework, wasted time, and frustration.</p><p>And this difference is easy for management to spot.</p><p>A <strong>good developer</strong> asks questions early, showing that they’ve done their homework.</p><p>An <strong>average developer</strong> asks questions on the go, signaling they didn’t study the requirements properly which naturally makes managers skeptical about the quality of their work.</p><h4>2. A Good Developer Tests Thoroughly Before Handing Over to QA</h4><p>Yes, testing isn’t just for QA. It’s part of a developer’s job.</p><p>QA exists to ensure that the final deliverable meets expectations, not to catch bugs caused by careless coding.</p><p>When you’re assigned a user story, your job isn’t just to “make it work.” You’re responsible for delivering a complete, functional, and stable feature.</p><p>That means testing every possible scenario, writing meaningful unit tests (not just for code coverage), and making sure everything works end to end.</p><p>By the time your feature reaches QA, it should already feel production-ready. QA is there to validate, not to clean up after you.</p><p>A <strong>good developer</strong> delivers code that rarely breaks. Their work often passes QA with minimal or no issues.</p><p>An <strong>average developer</strong> tests only the core flow and ignores edge cases, leaving QA to find what they should’ve caught themselves.</p><h4>3. Impact Analysis and Ownership</h4><p>This, according to the CEO, is the biggest differentiator. In this area, there’s no middle ground, only good and bad.</p><p>Imagine your app is used by multiple clients, each with their own view of the dashboard. Some components are shared across all clients, while others are client-specific.</p><p>Now, suppose you’re part of one client’s team and you’re tasked with building a new feature. You finish it, test it, and deliver it for QA.</p><p>But here’s the catch: because you’re working for a specific client, it’s expected (even if not explicitly stated) that the feature should only be available to that client.</p><p>A <strong>bad developer</strong> doesn’t take the time to understand the bigger picture.</p><p>They develop the feature and make it visible to everyone. Suddenly, all clients can see something that was meant for one.</p><p>A <strong>good developer</strong>, on the other hand, takes ownership.</p><p>They think beyond the ticket. They understand how the business operates and implement safeguards so that the feature only appears where it should, even if nobody specifically told them to.</p><p>Management can’t possibly document every small, “obvious” expectation. They rely on developers who care enough to understand the product and think like the business does.</p><h3>Final Thoughts</h3><p>As you see, none of the qualities that define a top developer are purely technical.</p><p>Being a great developer isn’t just about writing clean code or mastering frameworks, it’s about understanding the product, the business, and the impact of your work.</p><p>Coding is just one part of the puzzle. The moment you start thinking like a product builder, not just a coder, is when you move from <em>average</em> to <em>great.</em></p><p>I hope you liked the post. What would you add to this list? Let me know your thoughts in the comments below!</p><p>Hi, I’m Bilal, a .NET developer sharing what I learn about building software, thinking in systems, and writing clean, practical code.</p><p>If you’re exploring similar ideas, <a href="https://www.linkedin.com/in/mbkhalid23?utm_source=share&amp;utm_campaign=share_via&amp;utm_content=profile&amp;utm_medium=android_app">let’s connect</a> and learn together.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=64585f15e26b" width="1" height="1" alt=""><hr><p><a href="https://levelup.gitconnected.com/good-developers-vs-average-developers-64585f15e26b">3 Things Average Developers Do (That Good Developers Never Do)</a> was originally published in <a href="https://levelup.gitconnected.com/">Level Up Coding</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Why Your Code Feels Like a Prison — Master the art of Dependency Inversion]]></title>
            <link>https://levelup.gitconnected.com/dependency-inversion-principle-4126f1dca90f?source=rss-1aca216d88a4------2</link>
            <guid isPermaLink="false">https://medium.com/p/4126f1dca90f</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[clean-code]]></category>
            <category><![CDATA[software-architecture]]></category>
            <category><![CDATA[dotnet]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Muhammad Bilal Khalid]]></dc:creator>
            <pubDate>Mon, 04 Aug 2025 15:25:44 GMT</pubDate>
            <atom:updated>2025-08-04T15:25:44.734Z</atom:updated>
            <content:encoded><![CDATA[<blockquote><em>If swapping one piece makes everything collapse, you’re not building software, you’re stacking Jenga blocks.”—</em>Me, after learning Dependency Inversion the hard way</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*i0MV4QcNYFglxOve5EomWQ.png" /></figure><p>If you’ve been following this series on SOLID principles, you already know how brittle code can become when <a href="https://medium.com/gitconnected/single-responsibility-principle-demystified-e437a2454625">responsibilities blur</a>, <a href="https://medium.com/gitconnected/interface-segregation-principle-3e4cdc16a291">abstractions swell</a>, or <a href="https://medium.com/gitconnected/liskov-substitution-principle-b02ec8556cb4">behaviors diverge unexpectedly</a>.</p><p>The final principle, Dependency Inversion, isn’t just about abstractions. It’s about controlling the direction of your dependencies, so your higher-level logic doesn’t crumble when lower-level modules change.</p><p><strong>Dependency Inversion is often what allows all the other principles to scale.</strong> It helps modules evolve independently, encourages testable architecture, and makes your system feel like it’s built from Lego blocks instead of concrete slabs.</p><p>Let’s unpack what this principle really means, what pain it solves, and how to make it a habit in your designs.</p><h3>What is the Dependency Inversion Principle?</h3><p>At its core, Dependency Inversion flips the usual relationship between high-level and low-level modules.</p><p>Traditionally, a high-level module (say, a controller or service) might directly depend on a lower-level module (like a file system or database class). That means your business logic is tightly coupled to implementation details.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Zb0ggmuhxfP5MYo-hrBRnA.png" /><figcaption>❌ <strong>Problem</strong>: Business logic depends on the UI and Data implementations. This violates the <strong>direction of dependency</strong> and makes the core untestable and tightly coupled to external concerns.</figcaption></figure><p><strong>DIP says this is backward.</strong></p><blockquote><em>High-level modules should not depend on low-level modules.<br>Both should depend on abstractions.<br>And those abstractions should not depend on details.</em></blockquote><p>It’s called <em>inversion</em> because it inverts the natural tendency of code to lean on specific implementations. Instead, everything leans on contracts or interfaces.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hbQ3pLsrHym7BZuryJ-3qw.png" /><figcaption>✅ <strong>Fix</strong>: Now <strong>UI and Data</strong> depend on <strong>abstractions defined in the core</strong>. Core logic owns the interfaces and remains independent of any external implementation.</figcaption></figure><h3>A Realistic Example</h3><p>Imagine you’re building a notification system. Here’s your NotificationService:</p><pre>public class NotificationService<br>{<br>    public void SendWelcomeEmail(string email)<br>    {<br>        var smtp = new SmtpClient();<br>        smtp.Send(email, &quot;Welcome!&quot;, &quot;Thanks for signing up!&quot;);<br>    }<br>}</pre><p>What’s wrong with this?</p><ul><li>The high-level logic (NotificationService) depends directly on SmtpClient.</li><li>You can’t test it easily.</li><li>If you switch to SendGrid or some other provider, you have to crack open your service.</li></ul><p>Let’s invert this.</p><pre>public interface IEmailSender<br>{<br>    void Send(string to, string subject, string body);<br>}<br><br>public class SmtpEmailSender : IEmailSender<br>{<br>    public void Send(string to, string subject, string body)<br>    {<br>        // Implementation using SmtpClient<br>    }<br>}<br><br>public class NotificationService<br>{<br>    private readonly IEmailSender emailSender;<br>    <br>    public NotificationService(IEmailSender emailSender)<br>    {<br>        this.emailSender = emailSender;<br>    }<br><br>    public void SendWelcomeEmail(string email)<br>    {<br>        emailSender.Send(email, &quot;Welcome!&quot;, &quot;Thanks for signing up!&quot;);<br>    }<br>}</pre><p>Now the service doesn’t care <em>how</em> the email is sent. That’s someone else’s job. You’ve separated the logic (sending welcome emails) from the infrastructure (SMTP, SendGrid, etc.).</p><h3>Why This Matters</h3><ol><li><strong>Easier to Test: </strong>You can mock or stub IEmailSender in unit tests. No need to spin up a real SMTP server.</li><li><strong>Flexible to Change: </strong>Switching to a new provider? Just swap the implementation. The service stays untouched.</li><li><strong>Follows Other SOLID Principles:</strong> You’ll notice how this setup also follows the <a href="https://medium.com/gitconnected/open-closed-principle-709e2653be61">Open/Closed Principle</a>. You’re open to adding more implementations without modifying existing code.</li></ol><h3>Common Mistakes</h3><ul><li><strong>Defining abstractions too early: </strong>Don’t create interfaces just for the sake of following DIP. If you have only one implementation and no real need for substitution or testing, skip it for now.</li><li><strong>Wrong layer owns the abstraction: </strong>The abstraction should usually belong to the high-level policy module, not the low-level detail. That keeps the contract focused on what the business logic actually needs.</li><li><strong>Too many abstractions: </strong>Dependency Inversion helps decouple things, but if you overdo it, you’ll end up with abstraction soup.</li></ul><h3>Where to Apply It</h3><ul><li>Repositories (invert away from EF Core or Dapper specifics)</li><li>External services (email, payment, auth providers)</li><li>Logging, caching, and storage layers</li><li>Anything that changes often or depends on third-party tools</li></ul><h3>How .NET Makes This Easier</h3><p>In .NET, we implement Dependency Inversion through <strong>Dependency Injection, </strong>a technique baked right into the framework.</p><p>You define interfaces, register them in the DI container, and let .NET resolve dependencies at runtime. For example:</p><pre>builder.Services.AddScoped&lt;IEmailSender, SmtpEmailSender&gt;();</pre><p>This line tells .NET to inject SmtpEmailSender wherever IEmailSender is required.</p><p>You can also control the <strong>lifecycle</strong> of your dependencies:</p><ul><li>AddTransient — new instance every time</li><li>AddScoped — one instance per request</li><li>AddSingleton — one instance for the application&#39;s lifetime</li></ul><p>While this is a feature of the framework, it’s deeply tied to <strong>how you practice Dependency Inversion</strong>. It lets your system stay decoupled, flexible, and testable without manual plumbing.</p><p>But remember: the <strong>principle comes first</strong>, the container just makes it easier to implement.</p><h3>Final Thoughts</h3><p>Dependency Inversion isn’t about using interfaces everywhere. It’s about protecting the core of your application from details that are likely to change.</p><p>It helps you write code that’s flexible, testable, and less painful to refactor. And when combined with the other SOLID principles, it helps you build systems that can grow without breaking down.</p><p>So the next time you find a service directly instantiating a low-level class, ask yourself: <strong>What will break if I need to change this implementation tomorrow?</strong></p><p>If the answer is “a lot,” it’s time to invert that dependency.</p><h3>Wrapping Up the SOLID Series</h3><p>With Dependency Inversion, we’ve come full circle.</p><p>Each principle in SOLID aims to reduce friction, whether in change, testing, or understanding. They’re not laws. They’re design heuristics. And they work best when applied <strong>together</strong>.</p><p>You’ll break them. That’s fine. The key is knowing when, and why.</p><p>Thanks for following along with this series. I hope it helped you see SOLID not as academic theory, but as a practical toolkit to build software that’s less fragile, more understandable, and easier to grow.</p><p>Keep shipping, keep learning.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4126f1dca90f" width="1" height="1" alt=""><hr><p><a href="https://levelup.gitconnected.com/dependency-inversion-principle-4126f1dca90f">Why Your Code Feels Like a Prison — Master the art of Dependency Inversion</a> was originally published in <a href="https://levelup.gitconnected.com/">Level Up Coding</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Interface Segregation Principle: How Specialized Interfaces Prevent Hidden Bugs]]></title>
            <link>https://levelup.gitconnected.com/interface-segregation-principle-3e4cdc16a291?source=rss-1aca216d88a4------2</link>
            <guid isPermaLink="false">https://medium.com/p/3e4cdc16a291</guid>
            <category><![CDATA[software-architecture]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[clean-code]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[dotnet]]></category>
            <dc:creator><![CDATA[Muhammad Bilal Khalid]]></dc:creator>
            <pubDate>Mon, 28 Jul 2025 01:50:45 GMT</pubDate>
            <atom:updated>2025-07-28T01:50:45.682Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="Banner Image: Interface Segregation Principle: How Specialized Interfaces Prevent Hidden Bugs" src="https://cdn-images-1.medium.com/max/1024/1*GxV8_GnGzwHpmzIjrDlIkQ.png" /></figure><blockquote>“Fat interfaces don’t just bloat your code. They quietly make it fragile over time.” — Me, after untangling a bug in a repository base class</blockquote><p>If you read my <a href="https://medium.com/gitconnected/liskov-substitution-principle-b02ec8556cb4"><em>Liskov Substitution Principle article</em></a>, you’ve seen how code can look clean and still fail when a subtype doesn’t behave as expected.</p><p>Interface Segregation is often the next fix you need when abstractions grow too broad, and implementations drift away from shared behavior.</p><h3>🔍 What is the Interface Segregation Principle?</h3><p>The idea is simple:</p><blockquote>Interfaces should describe only what an implementation genuinely supports.</blockquote><p>If a class must implement methods it does not need, you do not have a shared behavior. You have a catch‑all contract that forces unrelated responsibilities into one place.</p><p>Over time, this leads to empty methods, NotImplementedExceptions, and runtime surprises instead of predictable, focused code.</p><h3>🤔 Where Teams Break ISP in Real Projects</h3><p>Let’s take a situation I have seen repeatedly in many .NET apps:</p><p>You start with a <strong>generic repository interface</strong>:</p><pre>public interface IRepository&lt;T&gt;<br>{<br>    T GetById(int id);<br>    IEnumerable&lt;T&gt; GetAll();<br>    void Add(T entity);<br>    void Update(T entity);<br>    void Delete(int id);<br>}</pre><p>It feels right. Most of your entities like Product, Customer, and Order support full CRUD, and this single interface makes your codebase look consistent.</p><p>Your service layer happily uses it:</p><pre>var order = orderRepository.GetById(10);<br>orderRepository.Update(order);</pre><p>Everything works. Life is good.</p><h4>📌 Then reality shows up</h4><p>At some point, new requirements arrive. Your application needs to handle <strong>read‑only data</strong>:</p><ul><li>ISO country codes stored in a database table</li><li>A table of tax rates synced from a government API</li><li>SQL views that represent aggregated reports</li></ul><p>These are not things you ever modify. They exist for lookup and reporting, not for writes.</p><p>But because you want to “reuse your pattern,” you still implement the same repository interface:</p><pre>public class CountryRepository : IRepository&lt;Country&gt;<br>{<br>    public Country GetById(int id) { /* ... */ }<br>    public IEnumerable&lt;Country&gt; GetAll() { /* ... */ }<br>    <br>    public void Add(Country entity)<br>    {<br>        throw new NotSupportedException(&quot;Countries cannot be added.&quot;);<br>    }<br>    public void Update(Country entity)<br>    {<br>        throw new NotSupportedException(&quot;Countries cannot be updated.&quot;);<br>    }<br>    public void Delete(int id)<br>    {<br>        throw new NotSupportedException(&quot;Countries cannot be deleted.&quot;);<br>    }<br>}</pre><p>It compiles. Your tests might even pass unless you specifically test those write methods.</p><p>Let’s suppose a new intern joins the team. While experimenting with the code, somewhere they try to remove an entry from the Country table they feel is no longer needed.</p><pre>countryRepository.Delete(1); // 💥 throws NotSupportedException</pre><p>Suddenly your supposedly “safe” abstraction fails in production.</p><h3>🛠️ How ISP Fixes the Problem</h3><p>The core issue: your <strong>interface described more than the class could actually do</strong>.</p><p>ISP fixes that by splitting the interface into <strong>specific behavioral units.</strong></p><pre>public interface IReadOnlyRepository&lt;T&gt;<br>{<br>    T GetById(int id);<br>    IEnumerable&lt;T&gt; GetAll();<br>}<br><br>public interface IWritableRepository&lt;T&gt; : IReadOnlyRepository&lt;T&gt;<br>{<br>    void Add(T entity);<br>    void Update(T entity);<br>    void Delete(int id);<br>}</pre><p>Now, when you build a repository for country codes, you can simple extend the IReadOnlyRepositoryinterface.</p><pre>public class CountryRepository : IReadOnlyRepository&lt;Country&gt;<br>{<br>    public Country GetById(int id) { /* ... */ }<br>    public IEnumerable&lt;Country&gt; GetAll() { /* ... */ }<br>}</pre><p>It implements exactly what it supports. No fake methods. No runtime exceptions. No broken promises.</p><p>For entities that allow writes, you can simply extend the IWriteableRepository interface.</p><pre>public class ProductRepository : IWritableRepository&lt;Product&gt;<br>{<br>    public Product GetById(int id) { /* ... */ }<br>    public IEnumerable&lt;Product&gt; GetAll() { /* ... */ }<br>    public void Add(Product entity) { /* ... */ }<br>    public void Update(Product entity) { /* ... */ }<br>    public void Delete(int id) { /* ... */ }<br>}</pre><h4>✅ The Benefits</h4><ul><li><strong>Callers know what to expect.</strong> If they get an IReadOnlyRepository, they will not try to call Delete.</li><li><strong>Fewer runtime surprises.</strong> No more NotSupportedException traps.</li><li><strong>Cleaner design.</strong> Your abstractions match real capabilities, not theoretical ones.</li></ul><h3>💭 Final Thoughts</h3><p>Whenever you see a class throwing NotImplementedException just to satisfy an interface, it is a sign something is off.</p><p>The Interface Segregation Principle helps you avoid those “catch‑all” abstractions that feel DRY but cause runtime headaches later.</p><p>Design contracts around <strong>actual behavior</strong>, and your code will be safer, clearer, and easier to extend without breaking existing features.</p><p>Have you run into ISP violations in production lately?</p><p>Do share with us your real‑world experiences where a generic interface caused unexpected issues. It is always interesting to see how these principles show up beyond theory.</p><p>Next up: <strong>Dependency Inversion Principle. </strong>Why tightly coupled code makes your system harder to change than it needs to be.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3e4cdc16a291" width="1" height="1" alt=""><hr><p><a href="https://levelup.gitconnected.com/interface-segregation-principle-3e4cdc16a291">Interface Segregation Principle: How Specialized Interfaces Prevent Hidden Bugs</a> was originally published in <a href="https://levelup.gitconnected.com/">Level Up Coding</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[When Polymorphism Backfires: A Real Look at the Liskov Substitution Principle]]></title>
            <link>https://levelup.gitconnected.com/liskov-substitution-principle-b02ec8556cb4?source=rss-1aca216d88a4------2</link>
            <guid isPermaLink="false">https://medium.com/p/b02ec8556cb4</guid>
            <category><![CDATA[coding]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[software-engineering]]></category>
            <dc:creator><![CDATA[Muhammad Bilal Khalid]]></dc:creator>
            <pubDate>Mon, 21 Jul 2025 03:14:13 GMT</pubDate>
            <atom:updated>2025-07-21T03:14:13.935Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="Banner Image: Understanding the Liskov Substitution Principle." src="https://cdn-images-1.medium.com/max/1024/1*TIw8xst4_AVnk6v7pJqEJw.png" /></figure><blockquote><em>“Polymorphism isn’t magic, it’s a contract. Break the behavior, and you break the trust.” </em>— Me, wondering why my ‘working’ subclass broke checkout.</blockquote><p>If you’ve read my <a href="https://medium.com/gitconnected/open-closed-principle-709e2653be61"><em>Open Closed Principle article</em></a>, you know how easy it is to let code “just work” in the beginning, only to watch it break the moment something needs extending.</p><p>LSP is the next principle that helps prevent those sneaky runtime failures, even when code looks clean and compiles just fine.</p><h3>🔍 What is the Liskov Substitution Principle?</h3><p>At its core, LSP states:</p><blockquote><strong><em>“If a piece of code expects a parent type, it should work with any of its subtypes </em>without altering correct behavior<em>. ”</em></strong><em><br> — Liskov Substitution Principle (LSP)</em></blockquote><p>In short, <strong>behavior matters more than type definitions</strong>. Your abstractions aren’t just about sharing method signatures, they’re about promising behavior.</p><p>When a new subtype silently changes that promise, existing code starts failing in production, not during compilation or code review.</p><h3>🤔 What Happens When You don’t Follow LSP?</h3><p>Before getting into the how of LSP, it is important to understand why we need it in the first place, and what might happen if we don’t follow LSP.</p><p>Let’s understand it with the help of an example. Imagine you’re building an e‑commerce project and your task is to integrate different payment methods.</p><h4>Your First Payment Processor — Credit Cards</h4><p>As the primary mode of payment you need to add payments via <strong>“credit cards.” </strong>So, you start by defining a simple interface:</p><pre>interface IPaymentProcessor<br>{<br>    void Charge(decimal amount);<br>}</pre><p>Then you implement a CreditCardProcessor that calls your gateway of choice—Stripe or Braintree, whatever your team prefers.</p><pre>class CreditCardProcessor : IChargeable<br>{<br>    public void Charge(decimal amount)<br>    {<br>        // immediate charge logic<br>    }<br>}</pre><p>You wire it up in dependency injection, write a Checkout method that looks like this…</p><pre>void Checkout(IPaymentProcessor processor, Order order)<br>{<br>    processor.Charge(order.Total);<br>    ShipOrder(order);<br>}</pre><p>…and it just works. You write unit tests, you run integration tests, and you deploy. Orders flow through, credit cards are charged, products ship, the world is good.</p><h4>Another Payment Processor — Official Stripe Support</h4><p>A few weeks later, your roadmap adds <strong>“Use Stripe.NET SDK directly so we can access new features.”</strong> So, you introduce a StripeProcessor:</p><pre>class StripeProcessor : IPaymentProcessor<br>{<br>    public void Charge(decimal amount)<br>    {<br>        //Stripe SDK logic here.<br>    }<br>}</pre><p>You swap out the DI registration, re‑run tests, and everything still passes. Whether it’s CreditCardProcessor or StripeProcessor, your Checkout logic remains oblivious, and that’s exactly what LSP promises.</p><p>If a subtype behaves as the interface specifies, you never have to change the calling code.</p><h4>Yet Another Request — Support Cash on Delivery</h4><p>Now comes a highly requested feature: <strong>“Our customers want Cash on Delivery (COD).”</strong></p><p>Again, you may think, “Easy, I’ll just another payment processor.” Since COD doesn’t charge at checkout, you create a dummy Charge method just to satisfy the interface.</p><pre>class CashOnDeliveryProcessor : IPaymentProcessor<br>{<br>    public void Charge(decimal amount)<br>    {<br>        // COD doesn’t charge at checkout; payment happens upon delivery<br>        throw new InvalidOperationException(&quot;COD requires manual payment at delivery time.&quot;);<br>    }<br>}</pre><p>You register it, you deploy, and you wait for COD orders. But on the first COD transaction, your app throws:</p><blockquote><em>InvalidOperationException: COD requires manual payment at delivery time.</em></blockquote><p>Your checkout method never reaches ShipOrder, the customer’s order status stays “Pending,” and support tickets pile up. You stare at your logs, and think, “But it implements Charge!”</p><p>The interface is honored, yet the behavior is broken.</p><h3>How LSP Ensures the Expected Behavior</h3><p>The above example is a classic LSP voilation. You didn’t get a compilation error or a failed test, your code was syntactically correct.</p><p>The problem is behavioral: your Checkout method assumed <strong>every</strong> IPaymentProcessor could actually process payment immediately.</p><p>By forcing COD into that same contract, you violated the principle:</p><blockquote>A subtype must be substitutable for its base type without altering the correctness of the program.</blockquote><p>In your case, substituting CashOnDeliveryProcessor for IPaymentProcessor altered program correctness.</p><p>Now let’s use LSP to fix your app.</p><h4>🛠️ How to fix Behavioral Discrepancies with LSP</h4><p>To fix this, you need to <strong>model behavior</strong>, not just signatures. You need to pull apart the responsibilities.</p><p>Since COD can’t process the payments immediately, it doesn’t make sense for it to implement the IPaymentProcessor interface. Let’s rename this to IChargeable for clarity.</p><pre>interface IChargeable<br>{<br>    void Charge(decimal amount);<br>}<br><br>class CreditCardProcessor : IChargeable<br>{<br>    public void Charge(decimal amount)<br>    {<br>        // immediate charge logic<br>    }<br>}<br><br>class StripeProcessor : IChargeable<br>{<br>    public void Charge(decimal amount)<br>    {<br>        // Stripe SDK logic<br>    }<br>}<br><br>class CashOnDeliveryHandler<br>{<br>    public void ScheduleCashOnDelivery(Order order)<br>    {<br>        // record COD order, notify logistics, collect later<br>    }<br>}</pre><p>Your Checkout method now becomes:</p><pre>void Checkout(Order order, object paymentHandler)<br>{<br>    if (paymentHandler is IChargeable charger)<br>    {<br>        charger.Charge(order.Total);<br>    }<br>    else if (paymentHandler is CashOnDeliveryHandler codHandler)<br>    {<br>        codHandler.ScheduleCashOnDelivery(order);<br>    }<br><br>    ShipOrder(order);<br>}</pre><p>By splitting interfaces and handlers, you eliminate the false assumption that “every” payment method can charge immediately.</p><p>Your code is explicit, testable, and no longer surprises you at runtime.</p><h3>💭 Final Thoughts</h3><p>When you see a class throwing exceptions for “unsupported” operations, it’s often a sign that your abstraction is lying.</p><p>LSP teaches you to design your system so that every implementation truly lives up to its contract, or is never forced into one it can’t fulfill.</p><p>In practice, that usually means favoring small, capability‑focused interfaces over catch‑all abstractions.</p><p>Have you encountered LSP violations in production code? Feel free to share any real-world examples where a violation of LSP caused unexpected behavior or bugs. It’s interesting to see how these principles play out beyond theory.</p><p><strong>Next up:</strong> Interface Segregation Principle — why forcing classes to implement what they don’t need is a design debt trap.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b02ec8556cb4" width="1" height="1" alt=""><hr><p><a href="https://levelup.gitconnected.com/liskov-substitution-principle-b02ec8556cb4">When Polymorphism Backfires: A Real Look at the Liskov Substitution Principle</a> was originally published in <a href="https://levelup.gitconnected.com/">Level Up Coding</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Mastering the ‘O’ in SOLID — Applying the Open/Closed Principle in Real-World Code]]></title>
            <link>https://levelup.gitconnected.com/open-closed-principle-709e2653be61?source=rss-1aca216d88a4------2</link>
            <guid isPermaLink="false">https://medium.com/p/709e2653be61</guid>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[coding]]></category>
            <dc:creator><![CDATA[Muhammad Bilal Khalid]]></dc:creator>
            <pubDate>Mon, 07 Jul 2025 18:26:13 GMT</pubDate>
            <atom:updated>2025-07-21T09:06:15.208Z</atom:updated>
            <content:encoded><![CDATA[<h3>Mastering the ‘O’ in SOLID — Applying the Open/Closed Principle in Real-World Code</h3><blockquote>Adding features shouldn’t feel like defusing a bomb. Here’s how the Open/Closed Principle (OCP) helps you extend your code without changing what already works.</blockquote><figure><img alt="Featured Image: Open Closed Principle. Why adding features shouldn’t feel overwhelming and how OCP helps with that — by Bilal Khalid" src="https://cdn-images-1.medium.com/max/1024/1*Tma8T_hjdwwm0Y6ESdSPgQ.png" /></figure><p>You’ve probably done this before:</p><p>You needed to add a small feature so you end up opening a class and writing <em>yet another</em> if statement. A couple of weeks later, you had to add another one. And then another. And before you know it, the code that once felt clean turns into a mess of conditions.</p><p>That’s the kind of slow creep the <strong>Open/Closed Principle</strong> is meant to prevent.</p><p><em>(Side note: we explored the </em><a href="https://medium.com/gitconnected/single-responsibility-principle-demystified-e437a2454625"><strong><em>Single Responsibility Principle</em></strong></a><em> in the previous part of this series — worth checking out if you missed it!)</em></p><h3>What is the Open/Closed Principle?</h3><p>The Open/Closed Principle (OCP) is one of the five core principles of SOLID design. It states:</p><blockquote><strong><em>Software should be open for extension but closed for modification.</em></strong></blockquote><p>In simpler terms: you should be able to add new behavior without changing the existing code.</p><p>That doesn’t mean your code never changes. It means the parts that already work shouldn’t have to be touched every time something new is added.</p><h3>Why Apply the Open/Closed Principle?</h3><p>Because code that changes too often becomes risky — not just technically, but mentally too. You start avoiding updates, afraid of breaking something that already works. I’ve experienced this!</p><p>Even a small if in the wrong place can create bugs or unexpected behavior. That fear of touching code slows everything down.</p><p>OCP helps you avoid that by encouraging you to add new behavior without touching old logic. It keeps the stable parts of your code safe and untouched.</p><p>This leads to cleaner structure, easier testing, and a codebase that grows without becoming fragile.</p><h3>What Happens When You Don’t Apply OCP?</h3><p>Let’s say you’re building a discount engine for an e-commerce platform. Initially, you just support a flat discount:</p><pre>public class DiscountCalculator<br>{<br>    public decimal ApplyDiscount(string customerType, decimal amount)<br>    {<br>        if (customerType == &quot;Regular&quot;)<br>        {<br>            return amount * 0.95m; // 5% off<br>        }<br>        return amount;<br>    }<br>}</pre><p>Now marketing wants loyalty discounts. Then seasonal promos. Then discounts based on cart value, customer tier, or coupon codes. You start stacking conditions:</p><pre>if (customerType == &quot;Gold&quot;)<br>{<br>    // 15% off<br>}<br>else if (amount &gt; 1000)<br>{<br>    // 10% off<br>}<br>else if (couponCode == &quot;SUMMER2025&quot;)<br>{<br>    // 20% off<br>}</pre><p>Before you know it, logic starts overlapping. You need flags to apply or skip certain discounts. And the order of these conditions becomes critical. One bug, and you end up giving 3 discounts instead of 1.</p><p>All you wanted was a clean way to apply business rules. Instead, you built a tightly-coupled maze.</p><h3>How to Apply the OCP?</h3><p>You make your code extensible by introducing <strong>abstractions</strong>.</p><p>Instead of hardcoding every rule into the DiscountCalculator with if statements, we shift the responsibility of applying individual discounts to their own dedicated classes. Each rule implements a shared interface, IDiscountRule, which defines when the rule applies and how it calculates the discount.</p><pre>public interface IDiscountRule<br>{<br>    bool IsMatch(Customer customer, Cart cart);<br>    decimal Apply(decimal amount);<br>}</pre><p>This means each rule is completely self-contained. It knows when it should run and how to apply its logic. The calculator doesn’t care about what the rules are, it just loops through them and applies what matches.</p><pre>public class LoyaltyDiscount : IDiscountRule<br>{<br>    public bool IsMatch(Customer customer, Cart cart) =&gt; customer.Type == &quot;Gold&quot;;<br>    public decimal Apply(decimal amount) =&gt; amount * 0.85m;<br>}<br><br>public class HighValueCartDiscount : IDiscountRule<br>{<br>    public bool IsMatch(Customer customer, Cart cart) =&gt; cart.Total &gt; 1000;<br>    public decimal Apply(decimal amount) =&gt; amount * 0.9m;<br>}</pre><p>The DiscountCalculator now becomes a simple orchestrator. It doesn’t contain any discount rules itself. It just loops through all available rules and applies them if they match.</p><pre>public class DiscountCalculator<br>{<br>    private readonly IEnumerable&lt;IDiscountRule&gt; _rules;<br>    <br>    public DiscountCalculator(IEnumerable&lt;IDiscountRule&gt; rules)<br>    {<br>        _rules = rules;<br>    }<br><br>    public decimal ApplyDiscount(Customer customer, Cart cart)<br>    {<br>        var amount = cart.Total;<br>        foreach (var rule in _rules)<br>        {<br>            if (rule.IsMatch(customer, cart))<br>            {<br>                amount = rule.Apply(amount);<br>            }<br>        }<br>        return amount;<br>    }<br>}</pre><p>Want to support a new type of discount next month? Just create a new class that implements IDiscountRule, register it with your dependency injection container, and you’re done. You never touch the DiscountCalculator class again.</p><h3>When Is It Okay to Skip OCP?</h3><p>Not every situation calls for this level of abstraction.</p><p>If the code is unlikely to change or grow, applying OCP too early might just create unnecessary layers. Why solve a problem you don’t have yet? Keep things simple when they genuinely are.</p><p>But when your code deals with rules, workflows, or business logic that could evolve — that’s when OCP shines. It helps you balance simplicity today with flexibility tomorrow.</p><p>Remember, OCP is just one tool in your design toolbox. It’s not a silver bullet. Use it when it makes sense — not every problem needs it, and sometimes the problem doesn’t even exist yet.</p><p>What about you — where have you seen the Open/Closed Principle make the biggest impact in your own codebase? Or maybe where you wish it had been applied?</p><p><strong>Next up:</strong> <a href="https://medium.com/gitconnected/liskov-substitution-principle-b02ec8556cb4"><em>Liskov Substitution Principle</em></a> — when polymorphism quietly breaks your code.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=709e2653be61" width="1" height="1" alt=""><hr><p><a href="https://levelup.gitconnected.com/open-closed-principle-709e2653be61">Mastering the ‘O’ in SOLID — Applying the Open/Closed Principle in Real-World Code</a> was originally published in <a href="https://levelup.gitconnected.com/">Level Up Coding</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The Single Responsibility Principle, Demystified]]></title>
            <link>https://levelup.gitconnected.com/single-responsibility-principle-demystified-e437a2454625?source=rss-1aca216d88a4------2</link>
            <guid isPermaLink="false">https://medium.com/p/e437a2454625</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[coding]]></category>
            <dc:creator><![CDATA[Muhammad Bilal Khalid]]></dc:creator>
            <pubDate>Mon, 30 Jun 2025 01:31:33 GMT</pubDate>
            <atom:updated>2025-07-07T18:49:02.163Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="Title Image: Single Responsibility principle" src="https://cdn-images-1.medium.com/max/1024/1*9g9uuewyNZHcJ_QRDfyHpQ.png" /></figure><blockquote>“Clean code is not overengineering. It’s making sure small changes actually feel small when the time comes.” — Me, after wrestling with my own code</blockquote><p>It honestly pains me when I see developers skipping SOLID principles. Not because I’m a purist or some design pattern evangelist — but because I’ve seen firsthand what happens when we ignore them. Code gets rigid, fragile, and incredibly frustrating to change.</p><p>I get it, though.</p><p>I used to think some of these principles were just academic theory. <em>Overengineering</em>, I called it.</p><p>The first SOLID principle I came across was SRP. At the time, it felt abstract and hard to apply, so I dismissed it as one of those things that sounds great in theory but rarely works in real projects.</p><p>But the truth is, I didn’t really understand SRP back then. Even when I <em>wanted</em> to follow it, I had no idea what it meant practically.</p><ul><li>What exactly counts as a “responsibility”?</li><li>How do you break up a class in a meaningful way?</li><li>When does it become too much?</li></ul><p>It took me a while to get there. So in this article, I want to make it easier for you to understand SRP — not with definitions, but through an actual example.</p><h3>The Setup: Let’s Build a Report Generator</h3><p>Imagine you just joined a logistics company as a .NET developer. Your first task is to <em>Build a simple shipment report generator.</em></p><p>Let’s say you come up with this (very realistic) piece of code:</p><pre>public class ReportGenerator<br>{<br>    public void GenerateReport()<br>    {<br>        // 1. Fetch data from the database<br>        var shipments = FetchShipmentsFromDb();<br><br>        // 2. Convert to report format<br>        var report = FormatAsTextReport(shipments);<br>        <br>        // 3. Save report to disk<br>        SaveToFile(report, &quot;shipment_report.txt&quot;);<br>        <br>        // 4. Send email to manager<br>        SendEmail(report);<br>    }<br><br>    private List&lt;Shipment&gt; FetchShipmentsFromDb()<br>    {<br>        // Simulated DB call<br>        return new List&lt;Shipment&gt; { new Shipment { Id = 1, Description = &quot;Cargo A&quot; } };<br>    }<br><br>    private string FormatAsTextReport(List&lt;Shipment&gt; shipments)<br>    {<br>        var builder = new StringBuilder();<br>        foreach (var shipment in shipments)<br>        {<br>            builder.AppendLine($&quot;ID: {shipment.Id}, Description: {shipment.Description}&quot;);<br>        }<br>        return builder.ToString();<br>    }<br><br>    private void SaveToFile(string content, string filename)<br>    {<br>        File.WriteAllText(filename, content);<br>    }<br><br>    private void SendEmail(string content)<br>    {<br>        Console.WriteLine(&quot;Sending email to manager...&quot;);<br>        // Imagine SMTP logic here<br>    }<br>}<br><br>public class Shipment<br>{<br>    public int Id { get; set; }<br>    public string Description { get; set; }<br>}</pre><p>Looks good, right? Everything’s working. It fetches data, formats it, saves a file, and even emails it.</p><p>And maybe at this point, someone tells you: <em>“This class violates SRP.”</em></p><p>You look at them like: <em>Why break this when it works?</em></p><h3>Uh Oh: The Business Wants More</h3><p>So, everything has been going great. People at your company love the system you built, and you even get some well-deserved praise for solving a real business problem.</p><p>Fast forward six months — the business is growing, and so are the demands on your report generator. A new set of feature requests rolls in:</p><ul><li>Support multiple report formats (Text, PDF, CSV)</li><li>Save reports to cloud storage instead of the local disk</li><li>Send emails only if a specific flag is set</li><li>Allow other teams to use the shipment data <em>without generating reports</em>.</li></ul><p>And that’s when the pain begins.</p><p>To accommodate these changes, you keep going back to the same GenerateReport() method… over and over again.</p><p>Now you have to:</p><ul><li>Add conditional logic to skip sending emails — so you introduce flags</li><li>Tweak the FormatAsTextReport() method to support CSV — which breaks your clean text formatting</li><li>Replace local file saving with cloud storage — which means pulling in an Azure SDK right inside your ReportGenerator</li></ul><p>Each “small change” feels like surgery. What was once a clean, simple method has now turned into a tangled mess.</p><p>You change one thing and something unrelated breaks.</p><p>That’s when it hits you: the problem isn’t with the new features — it’s with how tightly everything is packed into one class.</p><h3>Let’s Try Again — This Time With SRP</h3><p>Time to break this up. SRP says: <em>a class should have only one reason to change.</em></p><p>Let’s translate that to this problem:</p><ul><li>If the way we <strong>fetch data</strong> changes — that’s one reason.</li><li>If the way we <strong>format reports</strong> changes — second reason.</li><li>If we <strong>save</strong> somewhere else — third.</li><li>If we want to <strong>notify someone differently</strong> — fourth.</li></ul><p>So, let’s split it up.</p><h3>Step 1: Define the Responsibilities</h3><p>We’ll create:</p><ul><li>ShipmentFetcher → Gets the data</li><li>IReportFormatter and implementations like TextReportFormatter</li><li>IReportSaver and implementations like DiskReportSaver</li><li>INotifier and implementations like EmailNotifier</li><li>And finally, a ReportGenerator that just <em>orchestrates</em> the process.</li></ul><h3>Step 2: Refactored Code</h3><h4>The Interfaces</h4><pre>public interface IShipmentFetcher<br>{<br>    List&lt;Shipment&gt; Fetch();<br>}<br><br>public interface IReportFormatter<br>{<br>    string Format(List&lt;Shipment&gt; shipments);<br>}<br><br>public interface IReportSaver<br>{<br>    void Save(string content, string filename);<br>}<br><br>public interface INotifier<br>{<br>    void Notify(string content);<br>}</pre><h4>The Implementations</h4><pre>public class ShipmentFetcher : IShipmentFetcher<br>{<br>    public List&lt;Shipment&gt; Fetch()<br>    {<br>        return new List&lt;Shipment&gt; { new Shipment { Id = 1, Description = &quot;Cargo A&quot; } };<br>    }<br>}<br><br>public class TextReportFormatter : IReportFormatter<br>{<br>    public string Format(List&lt;Shipment&gt; shipments)<br>    {<br>        var builder = new StringBuilder();<br>        foreach (var shipment in shipments)<br>        {<br>            builder.AppendLine($&quot;ID: {shipment.Id}, Description: {shipment.Description}&quot;);<br>        }<br>        return builder.ToString();<br>    }<br>}<br><br>public class DiskReportSaver : IReportSaver<br>{<br>    public void Save(string content, string filename)<br>    {<br>        File.WriteAllText(filename, content);<br>    }<br>}<br><br>public class EmailNotifier : INotifier<br>{<br>    public void Notify(string content)<br>    {<br>        Console.WriteLine(&quot;Sending email to manager...&quot;);<br>    }<br>}</pre><h4>The Coordinator</h4><pre>public class ReportGenerator<br>{<br>    private readonly IShipmentFetcher _fetcher;<br>    private readonly IReportFormatter _formatter;<br>    private readonly IReportSaver _saver;<br>    private readonly INotifier? _notifier;<br>    <br>    public ReportGenerator(<br>        IShipmentFetcher fetcher,<br>        IReportFormatter formatter,<br>        IReportSaver saver,<br>        INotifier? notifier = null)<br>    {<br>        _fetcher = fetcher;<br>        _formatter = formatter;<br>        _saver = saver;<br>        _notifier = notifier;<br>    }<br>    <br>    public void Generate(string filename)<br>    {<br>        var data = _fetcher.Fetch();<br>        var report = _formatter.Format(data);<br>        _saver.Save(report, filename);<br>        _notifier?.Notify(report);<br>    }<br>}</pre><h3>What Changed?</h3><p>Suddenly, everything became easier:</p><ul><li>Want to support CSV? Just inject a new CsvReportFormatter. No need to touch the existing text logic.</li><li>Saving to S3? Create an S3ReportSaver — no rewiring or breaking file code.</li><li>Don’t want to send an email? Pass null or a NoOpNotifier. No flags needed.</li><li>Need shipment data elsewhere? Reuse ShipmentFetcher without dragging along reporting logic.</li></ul><p>Now each component does one thing and does it well. No ripples, no tangled dependencies — just clean, safe extensibility.</p><h3>Why SRP Is Not Overengineering</h3><p>At first glance, the refactored version might feel like overkill — “That’s a lot of classes for a simple task.”</p><p>But here’s the thing: the complexity was always there. You were just stuffing it into one class and hoping no one would notice.</p><p>SRP doesn’t add complexity — it <em>manages</em> it.</p><p>What it really gives you is freedom. The freedom to:</p><ul><li>Extend behavior without fear of breaking something else</li><li>Reuse logic across different workflows</li><li>Write meaningful, focused unit tests for each piece</li></ul><p>And when someone new joins the team? They don’t have to dig through a giant GenerateReport() method just to figure out what&#39;s going on.</p><p>Everything has a place. Everything has a purpose. That’s not overengineering — that’s clarity.</p><h3>TL;DR</h3><p>If you’re still skeptical about SOLID, I get it. I was you.</p><p>But try writing real code that doesn’t follow SRP. Then try to change it six months later. You’ll feel it.</p><p><strong>The pain of not following SRP shows up not when you write the code — but when you maintain it.</strong></p><p>So the next time you think “this works just fine as one class,” pause.</p><p>And ask yourself: <em>When this changes — what else will I have to touch?</em></p><p>That’s your answer.</p><p><strong>Next Up</strong>: The “O” in SOLID —<em> </em><a href="https://levelup.gitconnected.com/open-closed-principle-709e2653be61"><em>Open/Closed Principle</em></a>. Where we’ll dive into how adding a new feature shouldn’t mean rewriting old code (but it often does).</p><p><em>Let’s keep our code boring to maintain, even if it’s fun to write. See you in the next post.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e437a2454625" width="1" height="1" alt=""><hr><p><a href="https://levelup.gitconnected.com/single-responsibility-principle-demystified-e437a2454625">The Single Responsibility Principle, Demystified</a> was originally published in <a href="https://levelup.gitconnected.com/">Level Up Coding</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understanding the Clean Architecture]]></title>
            <link>https://levelup.gitconnected.com/clean-architecture-86c4f03e4771?source=rss-1aca216d88a4------2</link>
            <guid isPermaLink="false">https://medium.com/p/86c4f03e4771</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[software-architecture]]></category>
            <category><![CDATA[clean-architecture]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Muhammad Bilal Khalid]]></dc:creator>
            <pubDate>Tue, 23 Jan 2024 17:58:23 GMT</pubDate>
            <atom:updated>2025-10-26T18:01:55.396Z</atom:updated>
            <content:encoded><![CDATA[<h3>Understanding Clean Architecture</h3><h4>Discover the Essentials of Clean Architecture Through This Beginner-Friendly Guide</h4><p>Clean Architecture is one of the most popular software architectures to help organize your source code.</p><p>Here is everything you need to get started with Clean Architecture!</p><p>Proposed by Robert C Martin, aka Uncle Bob, the Clean Architecture offers some significant advantages:</p><ol><li><strong>Independent of Frameworks:</strong> The architecture does not require some external libraries to work. It can stand on its own.</li><li><strong>Testability:</strong> The business logic is independent of the web UI, Databases, and external sources so that it can be tested independently.</li><li><strong>Separation of Concerns: </strong>Web UI, Databases, and Business logic are all separated into different layers, making the system modular and less interdependent.</li><li><strong>High Cohesion and Low Coupling:</strong> All the layers specialize in their own domain and are not coupled to each other. Thus, any change in UI or databases will not affect the business logic and so on.</li></ol><blockquote><strong>So, what is it that makes this architecture so powerful?</strong></blockquote><p>The answer to this question is the <em>Dependency Inversion Principle.</em></p><p>The Dependency Inversion Principle is the main engine or the driving force behind any Layered Architecture.</p><h3>Dependency Inversion Principle</h3><p>The Dependency Inversion Principle basically states that:</p><blockquote>High-level modules should not depend on low-level implementation details. Instead, they should depend on abstractions that are implemented by the low-level modules. Thus, inverting the direction of the dependencies.</blockquote><p>Consider a traditional Asp.Net Webforms application. In such applications, business logic is strongly tied to the User Interface and Database.</p><p>Thus, any changes in the UI or database logic would force changes in the business logic as well.</p><figure><img alt="Fig 1: Business Layer Tightly Coupled with UI and Data" src="https://cdn-images-1.medium.com/max/660/1*YYtKXNN0BUO9aZOEexJsYw.png" /><figcaption>Fig 1: Business Layer Tightly Coupled with UI and Data</figcaption></figure><p>However, with dependency inversion, we can separate the business logic from the user interface and database by separating them into individual layers.</p><p>These layers, instead of depending on each other, depend on abstractions. Thus, any change in one layer does not affect any other layer.</p><figure><img alt="Fig 2: Business Layer Depends on the Interface and Independent of UI and Data" src="https://cdn-images-1.medium.com/max/914/1*9vkm2TmvRT4b-O5kdbkdTA.png" /><figcaption>Fig 2: Business Layer Depends on the Interface and Independent of UI and Data</figcaption></figure><p>So far, there have been multiple implementations of Layered Architecture, including Hexagonal, Onion, Clean Architecture, and more.</p><p>Let’s dive deep into the Clean Architecture now.</p><h3>Clean Architecture</h3><p>If you google the term Clean Architecture, you will see a diagram somewhat like this one.</p><figure><img alt="Layer Diagram of Clean Architecture" src="https://cdn-images-1.medium.com/max/339/1*JWzL8VcHl13x0J5rDUZWzA.png" /><figcaption>Fig-3: Layers in Clean Architecture</figcaption></figure><p>The diagram consists of concentric circles representing the different layers of the system.</p><p>As you get closer to the center, you will find high-level abstract details like the Domain Entities.</p><p>Moving outwards, you will encounter low-level implementation details like services, databases, etc.</p><p>Let’s have a look at what is inside each of these layers.</p><h4>Domain Layer</h4><p>At the heart of the system is the Domain Layer. The domain layer consists of the core business entities.</p><p>All the other layers in the system depend on the Domain layer and are there to support the Domain Layer.</p><p>Domain Layer itself does not depend on any other Layer.</p><h4>Application Layer</h4><p>Neighboring the Domain Layer is the Application Layer.</p><p>The Application layer is where all the magic happens. This is where your business logic resides.</p><p>Based on the business rules and regulations, this layer controls the flow of data to and from your business entities.</p><p>Generally, this layer consists of all your services, commands, queries, exceptions, logs, etc.</p><h4>Infrastructure Layer</h4><p>Next, we have the Infrastructure Layer. This is where all your external services and database logic are located.</p><p>All your external services, like email service, storage solutions, message queues, third-party API calls, etc., are handled by this layer.</p><p>Besides, it is also a common practice to separate database logic into its own Persistence Layer. This is where your DbContext and migrations, etc., will go.</p><h4>Presentation Layer</h4><p>Lastly, we have the presentation layer. This is the gateway or the entry point to your application.</p><p>This layer is responsible for presenting data to the end user in an easily understandable manner.</p><p>You will probably implement this layer as a Web or API project consisting of controllers defining the Action Methods or API endpoints.</p><p>So, these are the four layers in the Clean Architecture. But, now the question is:</p><blockquote><strong>Will there always be 4 layers?</strong></blockquote><p>The answer to that question is<em> “No”.</em></p><p>You can always add more layers according to your requirements. The point of the layers is to organize and manage the source code.</p><p>For example, you may add a Common Layer at the center for storing static data like enums, magic strings, etc.</p><p>Or add a Storage Layer at the outermost to manage your storage in case you are using multiple storage solutions.</p><p>In short, there is no restriction on the number of layers you can add.</p><p>However, there is one principle that you must always follow. That is the <em>Rule of Dependencies</em>.</p><h4>Rule of Dependencies</h4><p>The rule of dependencies gives clear instructions about the direction of dependencies. It states:</p><blockquote>Source code dependencies can only point from outside towards inside of the circle.</blockquote><figure><img alt="Flow of Dependencies in Clean Architecture" src="https://cdn-images-1.medium.com/max/339/1*dyEEkN3GHQeg7sA6v22EHw.png" /><figcaption>Fig-4: Flow of Dependencies in Clean Architecture</figcaption></figure><p>That means that no inner layer can know anything about the outer layers. Anything defined in an outer layer should not be visible to any inner layer.</p><blockquote><strong>So, how do the layers interact then?</strong></blockquote><p>It&#39;s simple. An inner layer defines an abstraction or an interface. The implementation of this interface is then provided by an outer layer.</p><p>That way, the inner layer doesn’t have to know about the outer layer and thus becomes independent of the implementation details.</p><p>Sounds good. But there is one more question remaining.</p><blockquote><strong>How do we transfer data between the layers?</strong></blockquote><p>Remember, we can not violate the Rule of Dependencies.</p><p>This implies we cannot directly pass data to and from layers using our domain entities.</p><p>Doing so would require the inner layer (Domain Layer) to know about the outer layers, violating the Rule of Dependencies.</p><p>So, instead of domain entities, we can create special Data Transfer Objects called DTOs to transfer the data between different layers.</p><p>DTOs must be simple data structures or objects containing the data required for an inner layer. You can also use immutable types like records for DTOs.</p><p>That’s it for this article!</p><p>Remember that software architectures are opinionated and very subjective. They are not a set of hard rules that must be followed.</p><p>Therefore, experiment with different architectures and feel free to make modifications to best suit your application.</p><p>After all, the goal of any architecture is to make clean, maintainable, testable, and scalable applications.</p><p>I hope you enjoyed this article. Let me know how you would structure your project for Clean Architecture. Feel free to share any insights!</p><p>PS: Check out my implementation of the Clean Architecture on my <a href="https://github.com/mbkhalid23/dotnet-clean-arch">Github repo</a>.</p><p>For now, it’s just the basic structure. Over the next few weeks, I will add different services and features to this project, like logging, dependency Injection, Authentication, CQRS, Emails, and more.</p><p>My goal is to make it into a starter template that is configured with all the necessary features that are a must in any modern application.</p><p>Feel free to follow along and share your suggestions.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=86c4f03e4771" width="1" height="1" alt=""><hr><p><a href="https://levelup.gitconnected.com/clean-architecture-86c4f03e4771">Understanding the Clean Architecture</a> was originally published in <a href="https://levelup.gitconnected.com/">Level Up Coding</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Electrostatic Adhesion: Making Wall Climbing Robots a Reality!]]></title>
            <link>https://medium.datadriveninvestor.com/https-medium-com-datadriveninvestor-electrostatic-adhesion-wall-climbing-robots-6be4c9ed772b?source=rss-1aca216d88a4------2</link>
            <guid isPermaLink="false">https://medium.com/p/6be4c9ed772b</guid>
            <category><![CDATA[innovation]]></category>
            <category><![CDATA[robotics]]></category>
            <category><![CDATA[adhesion]]></category>
            <category><![CDATA[industry]]></category>
            <category><![CDATA[technology]]></category>
            <dc:creator><![CDATA[Muhammad Bilal Khalid]]></dc:creator>
            <pubDate>Fri, 28 Dec 2018 18:37:55 GMT</pubDate>
            <atom:updated>2019-09-13T14:45:41.885Z</atom:updated>
            <content:encoded><![CDATA[<figure><a href="http://www.track.datadriveninvestor.com/1B9E"><img alt="" src="https://cdn-images-1.medium.com/max/700/0*69HYXiv7iu-QIINx" /></a></figure><p>Do an experiment! Take a balloon and try to attach it to a wall. Obviously, the balloon won’t stick. Now take the same balloon and rub it against a towel. Now again try to attach it to a nearby wall. This time the balloon magically sticks to the wall.</p><blockquote><strong>How did this happen!</strong></blockquote><p>Well, when you rubbed the balloon against the towel, due to friction, the electric charge transferred from the towel onto the balloon. Since the balloon is an insulator, the electric charge cannot move and stays there.</p><p>This charged balloon, when brought near the wall, induced an equal and opposite charge on the wall. The law <em>‘opposite charges attract each other’ </em>came into play, and the balloon got attached to the wall.</p><p>This charge that stays there on the surface of an insulator is called <strong>static charge</strong>, and their study is called <strong>Electrostatics</strong>.</p><p>While this whole phenomenon of adhesion between objects based on the electrostatic principles is called <strong>Electrostatic Adhesion</strong> or simply <strong>Electroadhesion.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*anxEL5H81R3z4JlxHw96TQ.jpeg" /><figcaption>Tesla Coil: Demonstrating Electrostatic Force</figcaption></figure><h3>Basis of Electroadhesive Phenomenon:</h3><p>The electrostatic phenomenon was first considered by the Greeks. They observed that when two pieces of wool were rubbed together, light objects like feathers were attracted towards them.</p><p>Later on, in the <strong>late</strong> <strong>1700s</strong>, a French scientist <strong>Augustin de Coulomb</strong> tried to understand the force of the electric field. He found out that similar charges repel each other while opposite charges attract each other, also known as <strong>Coulomb’s law.</strong></p><p>This law provided the basis for the concept of electrostatic adhesion. If we can produce enough static charge on a surface, we can then attach any object to that surface.</p><h3><strong>Comparison Between Different Adhesion Techniques:</strong></h3><p>Up until now, several adhesion techniques have been employed, each with their own merits and demerits. Some of these techniques include chemical adhesion, suction cups, synthetic gecko feet, magnetic and mechanical grippers.</p><p>A brief comparison of different adhesion techniques is given in the table below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/897/1*dzqkNT-EdVvlUCT5EC2gOA.png" /><figcaption><a href="https://commons.erau.edu/cgi/viewcontent.cgi?article=1243&amp;context=edt">Advantages/Disadvantages of Various Adhesion Techniques</a></figcaption></figure><p>The key advantage of electrostatic adhesion, which makes it superior to other techniques, is its ability to provide adhesion on almost any surface rough or smooth, conductor or insulator, etc.</p><h3><strong>Electroadhesive Pads and Their Types:</strong></h3><p>To bring life to the phenomenon of electroadhesion, researchers and scientists have developed several kinds of electroadhesive pads. These pads are of various shapes and sizes depending upon their application.</p><p>Electroadhesive pads are classified into two types;<em> </em><strong><em>Unipolar</em></strong><em> </em>and <strong><em>Bipolar</em></strong><em>.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/608/1*P5YcqAwNEHT673fj_Be_LA.png" /><figcaption>Pad Designs: Bipolar(left) and Unipolar(right)</figcaption></figure><p><strong>Unipolar </strong>pads comprise of a single sheet of electrode laminated with a dielectric. These are easy to manufacture and use, but their adhesive force is relatively weaker than bipolar pads.</p><p><strong>Bipolar </strong>pads consist of two electrodes electrically insulated from each other. These electrodes are arranged in different arrangements; Concentric circles, square spiral, comb structure, etc. While researchers have found the comb arrangement the most effective.</p><h3><strong>Working Principle of Electroadhesive Pads:</strong></h3><p>The pads work on the model of a capacitor. A pad consists of a conductor (Aluminum etc.), which act as an electrode, laminated with a layer of dielectric (Mylar, Epoxy, etc.). The substrate (object to be attached) then acts as the second plate of the capacitor.</p><p>The pads are energized by a high voltage DC supply. Upon energizing, the static charges start accumulating on the adhesive pad. The object to be attached is brought near the pads. The object gets polarized due to electrostatic induction and thus, gets adhered to the pad.</p><h3><strong>Material Handling Applications of Electroadhesion:</strong></h3><p>Electroadhesive pads are widely used for material handling applications in industries. These industries range from micro component industries to heavy industries.</p><h4><strong>Microgrippers:</strong></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/620/1*oPft2D55WieisctO4VWT5Q.jpeg" /><figcaption><a href="https://spectrum.ieee.org/automaton/robotics/robotics-hardware/electrostatic-robot-grippers">Grabit Robotic Gripper</a></figcaption></figure><p>Small micro-level grippers are widely used in the semiconductor and optical industry. This is because these pads have a very useful feature i.e., they do not affect the object in any way.</p><p>This feature is very beneficial in the semiconductor and the optical industries as these industries deal with very sensitive components. Electronic sensors and optical lenses etc. are, therefore, safely handled by means of microgrippers.</p><h4><strong>Inclined Conveyor Belts:</strong></h4><p>Moving from the micro-industry to heavy industry the electroadhesive pads are equally useful. They are utilized in industries, like cement and fertilizer industry, etc., where the material is to be transported to a longer distance over a greater height.</p><p>The <strong>conveyor system</strong> used there can only be inclined to a specific degree. As soon as the angle of elevation is increased, the material can no longer move up.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/1*zUQUyDAqy1LuN9O6lEhA5g.jpeg" /><figcaption><a href="https://grabitinc.com/productivity-solutions/">Grabit Technology’s Conveyor System</a></figcaption></figure><p>Also, if the height is tall, then the conveyor belts would take a considerable distance horizontally as well. Thus, a larger area is occupied which is not an ideal thing to have.</p><p>In this scenario, the adhesive pad will take the place of the belt of the conveyor system. Now when the belt is energized the material gets attached to it. This enables the industry to increase the elevation which in turn would decrease the horizontal area occupied. Thus, saving a lot of space and making the system overall more efficient.</p><h3>Wall Climbing Robots Using Electroadhesion:</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/620/1*Q4gkGAqGWPkdKwwbM9GpdQ.jpeg" /><figcaption><a href="https://spectrum.ieee.org/automaton/robotics/robotics-hardware/electrostatic-robot-grippers">SRI International’s Wall Climbing Robot</a></figcaption></figure><p>Wall climbing robots have always been a hot topic for researchers. Several technologies have been implemented to achieve an absolute wall-climbing robot. These included suction cups, magnetic grippers, gecko feet, etc.</p><p>Each of these techniques had their limitations, and thus couldn’t be implemented for the purpose. For instance, suction cups and gecko feet worked only on smooth surfaces, while magnetic grippers worked only on ferromagnetic surfaces.</p><p>Meanwhile, electroadhesion beats all the other techniques. It works well on all surfaces whether rough or smooth, conductor or insulator, etc. Thus, enables climbing any kind of wall whether wooden, glass or metallic.</p><p>This is a remarkable discovery in the field of robotics. Wall climbing robots have tremendous value in general industry, security, military, and various other fields.</p><p>They can be used in industries for the transportation of materials and examining the areas where human involvement is not possible or very difficult. Also, in big shopping malls, they can be used for various purposes.</p><p>However, their most significant application is in the military where they are used for security purposes, monitoring areas under enemy control, surveillance, and during military operations.</p><h3><strong>Conclusion:</strong></h3><p>Electroadhesive technology does promise many opportunities in industrial and military applications. However, they are still in the research, and their applications in real life are yet to be seen.</p><p>Researchers and scientists are working hard in optimizing these pads according to their various applications. They have still a lot to work to introduce these applications in the market.</p><p>While we cannot say how close they are in achieving the optimal electroadhesive technology. One thing is sure, according to today’s speed of scientific advancements, it would not take much longer.</p><h3>References:</h3><ol><li><a href="https://commons.erau.edu/cgi/viewcontent.cgi?article=1243&amp;context=edt">Saravia, Walter, “Design, Fabrication, and Testing of a Proprioceptive Electroadhesion Pad for Space Applications” (2015).</a></li><li><a href="http://iopscience.iop.org/article/10.1088/0022-3727/49/41/415304/meta">J Guo et al 2016 J. Phys. D: Appl. Phys. 49 415304</a></li><li><a href="http://iopscience.iop.org/article/10.1088/0022-3727/49/3/035303/meta">J Guo et al 2016 J. Phys. D: Appl. Phys. 49 035303</a></li></ol><iframe src="https://cdn.embedly.com/widgets/media.html?src=https%3A%2F%2Fupscri.be%2Fb2a0d6%3Fas_embed%3Dtrue&amp;dntp=1&amp;display_name=Upscribe&amp;url=https%3A%2F%2Fupscri.be%2Fb2a0d6%2F&amp;key=a19fcc184b9711e1b4764040d3dc5c07&amp;type=text%2Fhtml&amp;schema=upscri" width="800" height="400" frameborder="0" scrolling="no"><a href="https://medium.com/media/0707f5c806284d01a4a13c7b13a91ce3/href">https://medium.com/media/0707f5c806284d01a4a13c7b13a91ce3/href</a></iframe><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6be4c9ed772b" width="1" height="1" alt=""><hr><p><a href="https://medium.datadriveninvestor.com/https-medium-com-datadriveninvestor-electrostatic-adhesion-wall-climbing-robots-6be4c9ed772b">Electrostatic Adhesion: Making Wall Climbing Robots a Reality!</a> was originally published in <a href="https://medium.datadriveninvestor.com/">DataDrivenInvestor</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>