<?xml version="1.0" encoding="utf-8"?>
<rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/">
    <channel>
        <title>Chai Biscuit Blog</title>
        <link>https://chaibiscuit.rajivy.me/blog</link>
        <description>Chai Biscuit Blog</description>
        <lastBuildDate>Fri, 03 Jan 2025 00:00:00 GMT</lastBuildDate>
        <docs>https://validator.w3.org/feed/docs/rss2.html</docs>
        <generator>https://github.com/jpmonette/feed</generator>
        <language>en</language>
        <item>
            <title><![CDATA[How much does it cost to build and run a personal site?]]></title>
            <link>https://chaibiscuit.rajivy.me/blog/build-your-site</link>
            <guid>https://chaibiscuit.rajivy.me/blog/build-your-site</guid>
            <pubDate>Fri, 03 Jan 2025 00:00:00 GMT</pubDate>
            <description><![CDATA[✨ The one thing every professional needs (and how to build it)! ✨]]></description>
            <content:encoded><![CDATA[<p>✨ <strong>The one thing every professional needs (and how to build it)!</strong> ✨</p>
<p>🚨 Imagine this: You’ve solved a tricky problem at work (feels good, right? 💪). Months later, the same issue pops up. But instead of panicking or Googling endlessly, you open your site – and BAM! 💥 There’s the solution, all documented and ready to go.</p>
<p>Sounds like magic? ✨ It’s not! you can create this for yourself – and it won’t cost you a fortune to run! Curious? Let’s break it down.</p>
<p><img decoding="async" loading="lazy" alt="thumbnail post" src="https://chaibiscuit.rajivy.me/assets/images/build-small-feb540a2d1e40ef8b2305185396169d9.jpg" width="827" height="412" class="img_ev3q"></p>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="why-setting-up-a-personal-site-is-a-game-changer">Why setting up a personal site is a game-changer?<a href="https://chaibiscuit.rajivy.me/blog/build-your-site#why-setting-up-a-personal-site-is-a-game-changer" class="hash-link" aria-label="Direct link to Why setting up a personal site is a game-changer?" title="Direct link to Why setting up a personal site is a game-changer?">​</a></h3>
<p>Setting up a personal site isn’t just about having a digital presence 🤓 – it’s about growth, learning, and creating opportunities. 🚀 Whether you’re a developer, designer, product manager, QA engineer, or in any other profession, a personal site can be a game-changer:</p>
<ul>
<li>💡 <strong>Catalog your knowledge</strong>: Document what you learn – solutions, best practices, and techniques. It’s like your personal knowledge base.</li>
<li>🛠 <strong>Build and showcase your skills</strong>: A personal site highlights creativity, initiative, and expertise. Whether coding, writing, or managing projects, your work will speak for itself.</li>
<li>📈 <strong>Boost your professional profile</strong>: A personal site = instant portfolio. Potential employers, collaborators, or clients will see your expertise.</li>
<li>✍️ <strong>Improve Communication</strong>: Writing posts or tutorials forces you to structure your thoughts clearly – a skill valued in every role.</li>
<li>🚀 <strong>Stand Out</strong>: Whether in interviews, networking, or collaborations, a personal site gives you an edge.</li>
</ul>
<p>For me, <strong>my site</strong> serves as an <strong>online notebook</strong>. It’s where I:</p>
<p>✅ Document problems I’ve solved.</p>
<p>✅ Share best practices and design patterns.</p>
<p>✅ Reinforce my learning by writing (teaching is the best way to learn, right? 👨‍🏫).</p>
<p>✅ Improve my writing skills (a huge plus for career growth).</p>
<p>And honestly? Seeing my work live online is SO satisfying. 💻✨</p>
<p>💡 Note: Setting up your site might feel daunting initially – especially if you’re new to these tools. But trust me, every challenge you overcome is a step toward growth, and the payoff is worth it! 🙌</p>
<h2 class="anchor anchorWithStickyNavbar_LWe7" id="how-i-built-my-site-on-a-budget-">How I built my site (on a budget 💰)<a href="https://chaibiscuit.rajivy.me/blog/build-your-site#how-i-built-my-site-on-a-budget-" class="hash-link" aria-label="Direct link to How I built my site (on a budget 💰)" title="Direct link to How I built my site (on a budget 💰)">​</a></h2>
<p>Let me spill the beans 🫘 on how I built and run my site. While I’ll share my choices, you can pick what works best for you!</p>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="1-building-the-site-">1. Building the site 🦖<a href="https://chaibiscuit.rajivy.me/blog/build-your-site#1-building-the-site-" class="hash-link" aria-label="Direct link to 1. Building the site 🦖" title="Direct link to 1. Building the site 🦖">​</a></h3>
<p>Several tools can help you create your site. Here’s few of them for a quick comparison to help you decide:</p>
<table><thead><tr><th><strong>Tool</strong></th><th><strong>Ease of Use</strong></th><th><strong>Customization</strong></th><th><strong>Best For</strong></th><th><strong>Drawbacks</strong></th></tr></thead><tbody><tr><td><strong>Docusaurus</strong></td><td>Beginner-friendly</td><td>Moderate</td><td>Blogs, documentation, knowledge bases.</td><td>Limited design flexibility.</td></tr><tr><td><strong>Gatsby</strong></td><td>Intermediate (requires React)</td><td>High</td><td>High-performance, dynamic sites.</td><td>Steeper learning curve.</td></tr><tr><td><strong>WordPress</strong></td><td>Easy to Moderate</td><td>Very High</td><td>Dynamic websites with extensive plugins.</td><td>Can feel overwhelming for beginners.</td></tr></tbody></table>
<p>I chose <strong>Docusaurus</strong> because I wanted a no-frills, Markdown-based solution for documenting my learnings. Writing a blog post in plain text and seeing it transformed into a polished webpage feels like magic! ✨</p>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="2-hosting-it-️">2. Hosting it 🌩️<a href="https://chaibiscuit.rajivy.me/blog/build-your-site#2-hosting-it-%EF%B8%8F" class="hash-link" aria-label="Direct link to 2. Hosting it 🌩️" title="Direct link to 2. Hosting it 🌩️">​</a></h3>
<p>You’ll need to host your site somewhere reliable and cost-effective. Here’s what I looked for:</p>
<ul>
<li><strong>Managed SSL Certificates</strong>: For secure browsing without the hassle of manual renewals.</li>
<li><strong>Global CDN</strong>: To ensure fast load times for visitors across the globe.</li>
<li><strong>Scalability</strong>: Affordable for small projects but able to handle increased traffic as needed.</li>
</ul>
<p>I chose <strong>Microsoft Azure Blob Storage</strong> for my site, but other great options include:</p>
<ul>
<li><strong>AWS S3</strong>: Flexible and widely used.</li>
<li><strong>Google Cloud</strong>: Ideal for small-scale hosting.</li>
<li><strong>GitHub Pages or Netlify</strong>: Free or low-cost solutions for static sites.</li>
</ul>
<p>💡 <strong>Pro-tip</strong>: If you’re just starting, GitHub Pages or Netlify are great free options to experiment with before committing to paid services.</p>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="3-setting-up-a-dev-environment-">3. Setting up a Dev environment 🛠<a href="https://chaibiscuit.rajivy.me/blog/build-your-site#3-setting-up-a-dev-environment-" class="hash-link" aria-label="Direct link to 3. Setting up a Dev environment 🛠" title="Direct link to 3. Setting up a Dev environment 🛠">​</a></h3>
<p>To keep things consistent and frustration-free, I used <strong>Dev Containers</strong>. This ensures my environment works the same way every time – no more “It works on my machine” excuses. 😅</p>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="4-the-costs-">4. The costs 💸<a href="https://chaibiscuit.rajivy.me/blog/build-your-site#4-the-costs-" class="hash-link" aria-label="Direct link to 4. The costs 💸" title="Direct link to 4. The costs 💸">​</a></h3>
<p>Okay, here’s the part you’ve been waiting for – how much does this cost?</p>
<ul>
<li><strong>Domain</strong>: ~$50/year (because having yourname.com feels super pro 🔥).</li>
<li><strong>Hosting + SSL + CDN</strong>: ~$0.70 to $1 monthly.</li>
</ul>
<p>That’s it. About the cost of a cup of coffee ☕, I have a site that’s up and running 24/7. Not bad, huh? 😁</p>
<p>💡 <strong>Optional add-ons</strong>: Premium themes, plugins, or advanced hosting features can increase costs, but these aren’t necessary for getting started.</p>
<p>💡 <strong>Note</strong>: These costs are approximate and in New Zealand dollars ($). They may vary depending on your hosting provider and features. Start small, and you can scale up as needed!</p>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="whats-in-it-for-you">What’s in it for you?<a href="https://chaibiscuit.rajivy.me/blog/build-your-site#whats-in-it-for-you" class="hash-link" aria-label="Direct link to What’s in it for you?" title="Direct link to What’s in it for you?">​</a></h3>
<p>Still thinking, “Why should I bother?” 🤔 let me convince you:</p>
<ul>
<li>🧠 <strong>Organize and preserve knowledge</strong>: Whether it’s code snippets, solutions, or ideas, a personal site keeps everything in one place.</li>
<li>📒 <strong>Your knowledge base</strong>: Save yourself future headaches by documenting your solutions.</li>
<li>🎤 <strong>Stand out in interviews</strong>: Pull up your site and say, <strong>“I built this.”</strong> Employers LOVE seeing initiative.</li>
<li>✍️ <strong>Become a better writer</strong>: Explaining concepts improves your communication skills – a win in ANY job.</li>
<li>🌐 <strong>Create opportunities</strong>: Your site could attract potential employers, collaborators, or clients.</li>
<li>📚 <strong>Your ultimate interview prep tool</strong>: Turn your site into a go-to resource for brushing up before interviews—perfect for last-minute prep on your way there!</li>
</ul>
<p>And here’s the thing – your site doesn’t need to be fancy or perfect. Start small, keep learning, and improve as you go.</p>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="common-challenges-and-how-to-overcome-them">Common Challenges (and How to Overcome Them)<a href="https://chaibiscuit.rajivy.me/blog/build-your-site#common-challenges-and-how-to-overcome-them" class="hash-link" aria-label="Direct link to Common Challenges (and How to Overcome Them)" title="Direct link to Common Challenges (and How to Overcome Them)">​</a></h3>
<p>💡✨ <strong>What should I write about?</strong><br>
<!-- -->Start with what you know! ✅ problems you’ve solved, tips for others in your role 🎯, or even tools you love using 🛠️. Your everyday work is a treasure trove of inspiration 🌟—what seems routine to you might be life-changing for someone else! 💡🚀✨</p>
<p>✍️📚 <strong>What if my writing isn’t good enough?</strong><br>
<!-- -->Don’t worry—everyone starts somewhere! 🌱🏋️‍♂️ writing is like a muscle 💪—the more you practice, the stronger it gets. Each post helps you grow 📈 and boosts your confidence 🌟. Plus, explaining things helps you understand them better 🧠💡. Double win! 🎉</p>
<p>🔄⏳ <strong>How do I keep my site updated?</strong><br>
<!-- -->Consistency is key! 🔑 Set aside a tiny chunk of time ⌛ each month 📅 to add fresh content ✨ or tweak old posts. Think of it like watering your plant 🌱—a little effort keeps it thriving 🌸 and growing 🌳!</p>
<p>⏳📝 <strong>What if I don’t have time to write?</strong><br>
<!-- -->No time? No problem! 🕒 Start small 🪶—jot down quick ideas 💭 or notes 🗒️ and expand them later. Even short posts can be gold ✨—small steps lead to big wins 🏆🚀.</p>
<p>🌐📢 <strong>What if no one visits my site?</strong><br>
<!-- -->Sharing is caring! 🤝 Post your content on LinkedIn 🔗, Twitter 🐦, or forums where your audience hangs out 💬. Don’t forget to share it with colleagues 👩‍💻👨‍💻, friends 👋, or anyone who might find it helpful.</p>
<p>Take this post, for example: you probably found it scrolling through LinkedIn 📜 or heard about it from a friend 🤩. That’s the magic of putting yourself out there! 🚀🌟✨</p>
<p>🎨🌟 <strong>What if I run out of ideas?</strong><br>
<!-- -->Inspiration is everywhere! 🌍 look for lessons you’ve learned 🎓, mistakes you’ve fixed 🛠️, or new skills you’re exploring 🚀.</p>
<p>✨🛠️ <strong>Pro tip:</strong> Saw an interesting tweet 🐦, post 📃, or blog 🖋️? Perfect! 👍 share your take on it. Don’t just copy-paste—add your unique spin 🎨, your voice 🎙️, and your story 📖. That’s what makes it <em>yours</em>! 🌟💫✨</p>
<p>🖌️💻 <strong>How do I make it look good?</strong><br>
<!-- -->Keep it simple and clean! 🖼️ start with a minimal theme or template 🎨—focus on the content ✍️ first, and let the design evolve as you go 🚀. Minimal effort, maximum impact! 🎯✨</p>
<p>🛠️🤔 <strong>What if I get stuck on technical setup?</strong><br>
<!-- -->Don’t sweat it! 😅 There are tons of free resources and tutorials online 🎥📘. ccsheck out YouTube 🎬, forums 💬, or communities 🌐 for help. And remember—asking for help 🤝 is a sign of strength 💪, not weakness! 🌟✨</p>
<h2 class="anchor anchorWithStickyNavbar_LWe7" id="real-results-from-my-experience-">Real results (from my experience 💯✨)<a href="https://chaibiscuit.rajivy.me/blog/build-your-site#real-results-from-my-experience-" class="hash-link" aria-label="Direct link to Real results (from my experience 💯✨)" title="Direct link to Real results (from my experience 💯✨)">​</a></h2>
<p>Here’s what I’ve gained since launching my site:</p>
<p>👓 <strong>Deeper understanding</strong>: Writing forces you to truly understand concepts 🧠📚. There’s no better way to master a topic than to explain it! 💡</p>
<p>🚀 <strong>Career growth</strong>: It’s a great talking point in interviews 🎤 and networking events 🤝—showcasing your initiative always impresses! 🌟</p>
<p>⚡ <strong>Time-saver</strong>: I can quickly reference my notes 🗒️ instead of Googling the same things over and over 🔁. It’s like having my own personal knowledge base! 📖✨</p>
<p>🎉 <strong>And the best part?</strong> It’s FUN! Seeing your work online 💻 and helping others feels incredibly rewarding 🥰🙌. There’s nothing like the satisfaction of making an impact! 🌟✨</p>
<hr>
<h2 class="anchor anchorWithStickyNavbar_LWe7" id="advanced-growth-tips-">Advanced growth tips 🔥📈<a href="https://chaibiscuit.rajivy.me/blog/build-your-site#advanced-growth-tips-" class="hash-link" aria-label="Direct link to Advanced growth tips 🔥📈" title="Direct link to Advanced growth tips 🔥📈">​</a></h2>
<p>Once your site is up and running, take it to the next level with these enhancements:</p>
<p>📊 <strong>Analytics</strong>: Use tools like Google Analytics 📈 to understand your audience—what they love, where they’re from 🌎, and how they’re engaging with your content. 🧠✨</p>
<p>✉️ <strong>Newsletters</strong>: Build a deeper connection by adding a subscription option! 📬 Send out updates, share exclusive content, and keep your readers coming back for more. 🚀💌</p>
<p>🔍 <strong>SEO Optimization</strong>: Make sure your site shines on search engines! 🌟 Use keywords, meta descriptions, and proper formatting to increase visibility 📢. Your audience is out there—help them find you! 🎯✨</p>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="tldr">TL;DR<a href="https://chaibiscuit.rajivy.me/blog/build-your-site#tldr" class="hash-link" aria-label="Direct link to TL;DR" title="Direct link to TL;DR">​</a></h3>
<p>Setting up a personal site is an affordable and impactful way to:</p>
<ul>
<li>Catalogue your learnings and solutions.</li>
<li>Showcase your skills and boost your professional profile.</li>
<li>Improve your communication skills through writing.</li>
<li>Create new opportunities and stand out in your field.</li>
</ul>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="your-next-steps-lets-do-this-">Your next steps (let’s do this! 👏)<a href="https://chaibiscuit.rajivy.me/blog/build-your-site#your-next-steps-lets-do-this-" class="hash-link" aria-label="Direct link to Your next steps (let’s do this! 👏)" title="Direct link to Your next steps (let’s do this! 👏)">​</a></h3>
<p>💥 Ready to set up your site? Here’s what to do:</p>
<ol>
<li><strong>Choose a platform</strong>: Tools like Docusaurus, Gatsby, or WordPress simplify it.</li>
<li><strong>Pick a hosting provider</strong>: Look for one that balances affordability and reliability.</li>
<li><strong>Start writing</strong>: Begin with topics you know well or problems you’ve solved.</li>
<li><strong>Go live</strong>: Share your site with the world and enjoy the benefits! 🌍</li>
</ol>
<p>You’ll be amazed at how much you grow as a professional and creative thinker.</p>
<h2 class="anchor anchorWithStickyNavbar_LWe7" id="conclusion-go-crush-it-">Conclusion (go crush it! 🦸)<a href="https://chaibiscuit.rajivy.me/blog/build-your-site#conclusion-go-crush-it-" class="hash-link" aria-label="Direct link to Conclusion (go crush it! 🦸)" title="Direct link to Conclusion (go crush it! 🦸)">​</a></h2>
<p>A personal site isn’t just a digital space – it’s a reflection of your growth, passion, and expertise.
Keep building, keep learning, and most importantly, have FUN! 🎉</p>
<p>Don’t forget: <strong>chai ☕ in one hand, biscuit 🍪 in the other, and your keyboard ready for action 💻.</strong></p>
<p><strong>🎉Happy coding!!🎉</strong></p>
<div class="theme-admonition theme-admonition-info admonition_xJq3 alert alert--info"><div class="admonitionHeading_Gvgb"><span class="admonitionIcon_Rf37"><svg viewBox="0 0 14 16"><path fill-rule="evenodd" d="M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"></path></svg></span>🔥 Keep the Chai Brewing!</div><div class="admonitionContent_BuS1"><p>Every <strong><a href="https://buymeacoffee.com/rajivy" target="_blank" rel="noopener noreferrer">coffee ☕ (or chai 🍵)</a></strong> you buy fuels another idea, another post, and another smile. Thank you for supporting my work!</p></div></div>]]></content:encoded>
            <category>101</category>
            <category>learning</category>
        </item>
        <item>
            <title><![CDATA[Magic strings—cool name, annoying problem.!]]></title>
            <link>https://chaibiscuit.rajivy.me/blog/magic-strings-cool-name-annoying-problem</link>
            <guid>https://chaibiscuit.rajivy.me/blog/magic-strings-cool-name-annoying-problem</guid>
            <pubDate>Sat, 21 Dec 2024 00:00:00 GMT</pubDate>
            <description><![CDATA[✨ Taming Magic strings in your code: clean, safe, and maintainable solutions! ✨]]></description>
            <content:encoded><![CDATA[<p>✨ <strong>Taming Magic strings in your code: clean, safe, and maintainable solutions!</strong> ✨</p>
<p>Magic strings—cool name, annoying problem. 😤 These hardcoded strings (like <code>"Paid"</code> or <code>"Failed"</code>) can sneakily break your code, cause typos, and make debugging a nightmare.</p>
<p>Imagine this:</p>
<p>You’re working on a payment system, and a single typo—<code>"faild"</code> instead of <code>"Failed"</code>—slips through. Suddenly, payments are misclassified, users are misinformed, and the system behaves unpredictably.</p>
<p>Sound familiar? You’re not alone. Magic strings like these are everywhere, but you don’t have to put up with them. 🚫 There are better, safer ways to handle these strings.</p>
<p><img decoding="async" loading="lazy" alt="thumbnail post" src="https://chaibiscuit.rajivy.me/assets/images/mistake_thumb-6387d56821d38ad29d94a7ce14fd92c4.jpg" width="600" height="600" class="img_ev3q"></p>
<p>I’ll walk you through practical approaches to replace magic strings with safer, centralized alternatives. Whether you need type safety, flexibility, or extensibility, there’s a solution for you.</p>
<p>These are just a few effective ways to handle the issue of magic strings; there are certainly many more solutions available. ✨</p>
<p>In this post, I’ll walk you through three practical approaches to replace magic strings:</p>
<ul>
<li>Enums (type safety 🏆)</li>
<li>Static classes with constants (flexibility 🧰)</li>
<li>Records with readonly static fields (modern and extensible ⚡)</li>
</ul>
<p>Along the way, I’ll share:</p>
<ul>
<li>Real-world examples where each solution shines 🌟.</li>
<li>I’ll compare their performance(very briefly)</li>
<li>A quick decision table to help you pick the right approach.</li>
<li>When magic strings are actually okay.</li>
</ul>
<p>Each approach has its strengths, and the choice of which to use depends on the specific situation. And as a bonus, I’ll throw in some handy .NET tricks to simplify your code. Let’s dive in! ✨</p>
<h2 class="anchor anchorWithStickyNavbar_LWe7" id="the-problem-with-magic-strings-">The Problem with Magic Strings 🪄<a href="https://chaibiscuit.rajivy.me/blog/magic-strings-cool-name-annoying-problem#the-problem-with-magic-strings-" class="hash-link" aria-label="Direct link to The Problem with Magic Strings 🪄" title="Direct link to The Problem with Magic Strings 🪄">​</a></h2>
<p>Hardcoding strings like <code>"Pending"</code>, <code>"Paid"</code>, or <code>"Failed"</code> may seem harmless, but they come with hidden dangers: 😫</p>
<ul>
<li><strong>Typos</strong>: <code>"faild"</code> instead of <code>"Failed"</code> silently breaks the logic.</li>
<li><strong>Debugging Nightmares</strong>: Strings scattered across the codebase make errors hard to track.</li>
<li><strong>Poor Maintainability</strong>: Updating a string means hunting through your entire codebase. e.g. If <code>"Paid"</code> is renamed to <code>"Completed"</code>, you’ll spend hours hunting it down in 20 different files.</li>
</ul>
<p><strong>Real-world example: Payment statuses in a payment system 💳</strong></p>
<p>Consider this: You’re handling payment statuses like <code>"Pending"</code>, <code>"Paid"</code>, <code>"Failed"</code>, and <code>"Refunded"</code>. Here’s what magic strings might look like:</p>
<div class="tabs-container tabList__CuJ"><ul role="tablist" aria-orientation="horizontal" class="tabs"><li role="tab" tabindex="0" aria-selected="true" class="tabs__item tabItem_LNqP tabs__item--active">C#</li></ul><div class="margin-top--md"><div role="tabpanel" class="tabItem_Ymn6"><div class="language-csharp codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#d6deeb;--prism-background-color:#011627"><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-csharp codeBlock_bY9V thin-scrollbar" style="color:#d6deeb;background-color:#011627"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:#d6deeb"><span class="token keyword" style="color:rgb(127, 219, 202)">if</span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token plain">paymentStatus </span><span class="token operator" style="color:rgb(127, 219, 202)">==</span><span class="token plain"> </span><span class="token string" style="color:rgb(173, 219, 103)">"Paid"</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"></span><span class="token punctuation" style="color:rgb(199, 146, 234)">{</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">    Console</span><span class="token punctuation" style="color:rgb(199, 146, 234)">.</span><span class="token function" style="color:rgb(130, 170, 255)">WriteLine</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token string" style="color:rgb(173, 219, 103)">"Payment successful. Order will be shipped."</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span><span class="token plain"> </span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"></span><span class="token punctuation" style="color:rgb(199, 146, 234)">}</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"></span><span class="token keyword" style="color:rgb(127, 219, 202)">else</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">if</span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token plain">paymentStatus </span><span class="token operator" style="color:rgb(127, 219, 202)">==</span><span class="token plain"> </span><span class="token string" style="color:rgb(173, 219, 103)">"Failed"</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"></span><span class="token punctuation" style="color:rgb(199, 146, 234)">{</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">    Console</span><span class="token punctuation" style="color:rgb(199, 146, 234)">.</span><span class="token function" style="color:rgb(130, 170, 255)">WriteLine</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token string" style="color:rgb(173, 219, 103)">"Payment failed. Notify the user."</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"></span><span class="token punctuation" style="color:rgb(199, 146, 234)">}</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"></span><span class="token keyword" style="color:rgb(127, 219, 202)">else</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">if</span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token plain">paymentStatus </span><span class="token operator" style="color:rgb(127, 219, 202)">==</span><span class="token plain"> </span><span class="token string" style="color:rgb(173, 219, 103)">"Refunded"</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"></span><span class="token punctuation" style="color:rgb(199, 146, 234)">{</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">    Console</span><span class="token punctuation" style="color:rgb(199, 146, 234)">.</span><span class="token function" style="color:rgb(130, 170, 255)">WriteLine</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token string" style="color:rgb(173, 219, 103)">"Payment has been refunded."</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"></span><span class="token punctuation" style="color:rgb(199, 146, 234)">}</span><br></span></code></pre></div></div></div></div></div>
<p><strong>Problems:</strong></p>
<ol>
<li>Typos like <code>"faild"</code> can break the logic.</li>
<li>If <code>"Paid"</code> is renamed to <code>"Completed"</code>, you need to manually update it everywhere.</li>
<li>Integrating with third-party APIs that use <code>"PAID"</code> or <code>"failed"</code> requires extra checks.</li>
</ol>
<p>The solution? Replace magic strings with centralized, type-safe alternatives. 🚀</p>
<hr>
<h2 class="anchor anchorWithStickyNavbar_LWe7" id="three-key-approaches-to-handle-magic-strings-️">Three key approaches to handle Magic Strings 🛠️<a href="https://chaibiscuit.rajivy.me/blog/magic-strings-cool-name-annoying-problem#three-key-approaches-to-handle-magic-strings-%EF%B8%8F" class="hash-link" aria-label="Direct link to Three key approaches to handle Magic Strings 🛠️" title="Direct link to Three key approaches to handle Magic Strings 🛠️">​</a></h2>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="1-enums-the-type-safe-champion-">1. Enums: The Type-safe champion 🏆<a href="https://chaibiscuit.rajivy.me/blog/magic-strings-cool-name-annoying-problem#1-enums-the-type-safe-champion-" class="hash-link" aria-label="Direct link to 1. Enums: The Type-safe champion 🏆" title="Direct link to 1. Enums: The Type-safe champion 🏆">​</a></h3>
<p>Enums give you compile-time validation and eliminate typos by limiting values to a predefined set. Enums are great for projects with predictable and stable values.</p>
<p><strong>Example:</strong></p>
<div class="tabs-container tabList__CuJ"><ul role="tablist" aria-orientation="horizontal" class="tabs"><li role="tab" tabindex="0" aria-selected="true" class="tabs__item tabItem_LNqP tabs__item--active">C#</li></ul><div class="margin-top--md"><div role="tabpanel" class="tabItem_Ymn6"><div class="language-csharp codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#d6deeb;--prism-background-color:#011627"><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-csharp codeBlock_bY9V thin-scrollbar" style="color:#d6deeb;background-color:#011627"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:#d6deeb"><span class="token keyword" style="color:rgb(127, 219, 202)">public</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">enum</span><span class="token plain"> </span><span class="token class-name" style="color:rgb(255, 203, 139)">PaymentStatus</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"></span><span class="token punctuation" style="color:rgb(199, 146, 234)">{</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">    Pending</span><span class="token punctuation" style="color:rgb(199, 146, 234)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">    Paid</span><span class="token punctuation" style="color:rgb(199, 146, 234)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">    Failed</span><span class="token punctuation" style="color:rgb(199, 146, 234)">,</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">    Refunded</span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"></span><span class="token punctuation" style="color:rgb(199, 146, 234)">}</span><br></span></code></pre></div></div></div></div></div>
<p>Refactor your logic:</p>
<div class="tabs-container tabList__CuJ"><ul role="tablist" aria-orientation="horizontal" class="tabs"><li role="tab" tabindex="0" aria-selected="true" class="tabs__item tabItem_LNqP tabs__item--active">C#</li></ul><div class="margin-top--md"><div role="tabpanel" class="tabItem_Ymn6"><div class="language-csharp codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#d6deeb;--prism-background-color:#011627"><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-csharp codeBlock_bY9V thin-scrollbar" style="color:#d6deeb;background-color:#011627"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:#d6deeb"><span class="token keyword" style="color:rgb(127, 219, 202)">if</span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token plain">paymentStatus </span><span class="token operator" style="color:rgb(127, 219, 202)">==</span><span class="token plain"> PaymentStatus</span><span class="token punctuation" style="color:rgb(199, 146, 234)">.</span><span class="token plain">Paid</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"></span><span class="token punctuation" style="color:rgb(199, 146, 234)">{</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">    Console</span><span class="token punctuation" style="color:rgb(199, 146, 234)">.</span><span class="token function" style="color:rgb(130, 170, 255)">WriteLine</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token string" style="color:rgb(173, 219, 103)">"Payment successful. Order will be shipped."</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"></span><span class="token punctuation" style="color:rgb(199, 146, 234)">}</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"></span><span class="token keyword" style="color:rgb(127, 219, 202)">else</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">if</span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token plain">paymentStatus </span><span class="token operator" style="color:rgb(127, 219, 202)">==</span><span class="token plain"> PaymentStatus</span><span class="token punctuation" style="color:rgb(199, 146, 234)">.</span><span class="token plain">Failed</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"></span><span class="token punctuation" style="color:rgb(199, 146, 234)">{</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">    Console</span><span class="token punctuation" style="color:rgb(199, 146, 234)">.</span><span class="token function" style="color:rgb(130, 170, 255)">WriteLine</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token string" style="color:rgb(173, 219, 103)">"Payment failed. Notify the user."</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"></span><span class="token punctuation" style="color:rgb(199, 146, 234)">}</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"></span><span class="token keyword" style="color:rgb(127, 219, 202)">else</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">if</span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token plain">paymentStatus </span><span class="token operator" style="color:rgb(127, 219, 202)">==</span><span class="token plain"> PaymentStatus</span><span class="token punctuation" style="color:rgb(199, 146, 234)">.</span><span class="token plain">Refunded</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"></span><span class="token punctuation" style="color:rgb(199, 146, 234)">{</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">    Console</span><span class="token punctuation" style="color:rgb(199, 146, 234)">.</span><span class="token function" style="color:rgb(130, 170, 255)">WriteLine</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token string" style="color:rgb(173, 219, 103)">"Payment has been refunded."</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"></span><span class="token punctuation" style="color:rgb(199, 146, 234)">}</span><br></span></code></pre></div></div></div></div></div>
<p>🎯 Why Use Enums?</p>
<ul>
<li>✅ Type Safety: Eliminates typos like <code>"faild"</code>.</li>
<li>✅ Readability: PaymentStatus.Paid is self-explanatory.</li>
<li>✅ Compile-Time Validation: Errors are caught before runtime.</li>
</ul>
<p>🔍 Use Case: When you have stable, finite values like payment statuses, order states, or user roles.</p>
<hr>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="2-static-class-with-constants-the-flexible-favorite-">2. Static class with constants: The flexible favorite 🧰<a href="https://chaibiscuit.rajivy.me/blog/magic-strings-cool-name-annoying-problem#2-static-class-with-constants-the-flexible-favorite-" class="hash-link" aria-label="Direct link to 2. Static class with constants: The flexible favorite 🧰" title="Direct link to 2. Static class with constants: The flexible favorite 🧰">​</a></h3>
<p>Need to stick with strings but avoid typos? Static classes with constants provide a middle ground. These centralize your constants and prevent typos while keeping the flexibility of using string values directly. They’re especially useful in scenarios where your values need to interact with external systems or configurations.</p>
<p><strong>Example:</strong></p>
<div class="tabs-container tabList__CuJ"><ul role="tablist" aria-orientation="horizontal" class="tabs"><li role="tab" tabindex="0" aria-selected="true" class="tabs__item tabItem_LNqP tabs__item--active">C#</li></ul><div class="margin-top--md"><div role="tabpanel" class="tabItem_Ymn6"><div class="language-csharp codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#d6deeb;--prism-background-color:#011627"><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-csharp codeBlock_bY9V thin-scrollbar" style="color:#d6deeb;background-color:#011627"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:#d6deeb"><span class="token keyword" style="color:rgb(127, 219, 202)">public</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">static</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">class</span><span class="token plain"> </span><span class="token class-name" style="color:rgb(255, 203, 139)">PaymentStatuses</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"></span><span class="token punctuation" style="color:rgb(199, 146, 234)">{</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">    </span><span class="token keyword" style="color:rgb(127, 219, 202)">public</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">const</span><span class="token plain"> </span><span class="token class-name keyword" style="color:rgb(127, 219, 202)">string</span><span class="token plain"> Pending </span><span class="token operator" style="color:rgb(127, 219, 202)">=</span><span class="token plain"> </span><span class="token string" style="color:rgb(173, 219, 103)">"Pending"</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">    </span><span class="token keyword" style="color:rgb(127, 219, 202)">public</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">const</span><span class="token plain"> </span><span class="token class-name keyword" style="color:rgb(127, 219, 202)">string</span><span class="token plain"> Paid </span><span class="token operator" style="color:rgb(127, 219, 202)">=</span><span class="token plain"> </span><span class="token string" style="color:rgb(173, 219, 103)">"Paid"</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">    </span><span class="token keyword" style="color:rgb(127, 219, 202)">public</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">const</span><span class="token plain"> </span><span class="token class-name keyword" style="color:rgb(127, 219, 202)">string</span><span class="token plain"> Failed </span><span class="token operator" style="color:rgb(127, 219, 202)">=</span><span class="token plain"> </span><span class="token string" style="color:rgb(173, 219, 103)">"Failed"</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">    </span><span class="token keyword" style="color:rgb(127, 219, 202)">public</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">const</span><span class="token plain"> </span><span class="token class-name keyword" style="color:rgb(127, 219, 202)">string</span><span class="token plain"> Refunded </span><span class="token operator" style="color:rgb(127, 219, 202)">=</span><span class="token plain"> </span><span class="token string" style="color:rgb(173, 219, 103)">"Refunded"</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"></span><span class="token punctuation" style="color:rgb(199, 146, 234)">}</span><br></span></code></pre></div></div></div></div></div>
<p>Refactor your logic:</p>
<div class="tabs-container tabList__CuJ"><ul role="tablist" aria-orientation="horizontal" class="tabs"><li role="tab" tabindex="0" aria-selected="true" class="tabs__item tabItem_LNqP tabs__item--active">C#</li></ul><div class="margin-top--md"><div role="tabpanel" class="tabItem_Ymn6"><div class="language-csharp codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#d6deeb;--prism-background-color:#011627"><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-csharp codeBlock_bY9V thin-scrollbar" style="color:#d6deeb;background-color:#011627"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:#d6deeb"><span class="token keyword" style="color:rgb(127, 219, 202)">if</span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token plain">paymentStatus </span><span class="token operator" style="color:rgb(127, 219, 202)">==</span><span class="token plain"> PaymentStatuses</span><span class="token punctuation" style="color:rgb(199, 146, 234)">.</span><span class="token plain">Paid</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"></span><span class="token punctuation" style="color:rgb(199, 146, 234)">{</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">    Console</span><span class="token punctuation" style="color:rgb(199, 146, 234)">.</span><span class="token function" style="color:rgb(130, 170, 255)">WriteLine</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token string" style="color:rgb(173, 219, 103)">"Payment successful. Order will be shipped."</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"></span><span class="token punctuation" style="color:rgb(199, 146, 234)">}</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"></span><span class="token keyword" style="color:rgb(127, 219, 202)">else</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">if</span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token plain">paymentStatus </span><span class="token operator" style="color:rgb(127, 219, 202)">==</span><span class="token plain"> PaymentStatuses</span><span class="token punctuation" style="color:rgb(199, 146, 234)">.</span><span class="token plain">Failed</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"></span><span class="token punctuation" style="color:rgb(199, 146, 234)">{</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">    Console</span><span class="token punctuation" style="color:rgb(199, 146, 234)">.</span><span class="token function" style="color:rgb(130, 170, 255)">WriteLine</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token string" style="color:rgb(173, 219, 103)">"Payment failed. Notify the user."</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"></span><span class="token punctuation" style="color:rgb(199, 146, 234)">}</span><br></span></code></pre></div></div></div></div></div>
<p>💡 Why Use Static constants?</p>
<ul>
<li>✅ Centralized Values: All statuses live in one place.</li>
<li>✅ Readability: Easy to reference and update.</li>
<li>✅ Integration-Friendly: Works well with APIs expecting strings.</li>
</ul>
<p>🔍 Use Case: When you need strings for external integrations or configurations.</p>
<hr>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="3-record-with-readonly-static-fields-the-modern-option-">3. Record with readonly static fields: The modern option ⚡<a href="https://chaibiscuit.rajivy.me/blog/magic-strings-cool-name-annoying-problem#3-record-with-readonly-static-fields-the-modern-option-" class="hash-link" aria-label="Direct link to 3. Record with readonly static fields: The modern option ⚡" title="Direct link to 3. Record with readonly static fields: The modern option ⚡">​</a></h3>
<p>This method is perfect for projects that need extensibility alongside type safety. Records provide a concise, immutable way to replace magic strings while benefiting from <strong>value-based equality</strong>. This makes them ideal for representing richer, data-centric objects.</p>
<p><strong>Example:</strong></p>
<div class="tabs-container tabList__CuJ"><ul role="tablist" aria-orientation="horizontal" class="tabs"><li role="tab" tabindex="0" aria-selected="true" class="tabs__item tabItem_LNqP tabs__item--active">C#</li></ul><div class="margin-top--md"><div role="tabpanel" class="tabItem_Ymn6"><div class="language-csharp codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#d6deeb;--prism-background-color:#011627"><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-csharp codeBlock_bY9V thin-scrollbar" style="color:#d6deeb;background-color:#011627"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:#d6deeb"><span class="token keyword" style="color:rgb(127, 219, 202)">public</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">record</span><span class="token plain"> </span><span class="token class-name" style="color:rgb(255, 203, 139)">PaymentStatus</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"></span><span class="token punctuation" style="color:rgb(199, 146, 234)">{</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">    </span><span class="token keyword" style="color:rgb(127, 219, 202)">public</span><span class="token plain"> </span><span class="token return-type class-name keyword" style="color:rgb(127, 219, 202)">string</span><span class="token plain"> Name </span><span class="token punctuation" style="color:rgb(199, 146, 234)">{</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">get</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(199, 146, 234)">}</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain" style="display:inline-block"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">    </span><span class="token keyword" style="color:rgb(127, 219, 202)">private</span><span class="token plain"> </span><span class="token function" style="color:rgb(130, 170, 255)">PaymentStatus</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token class-name keyword" style="color:rgb(127, 219, 202)">string</span><span class="token plain"> name</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"> </span><span class="token operator" style="color:rgb(127, 219, 202)">=&gt;</span><span class="token plain"> Name </span><span class="token operator" style="color:rgb(127, 219, 202)">=</span><span class="token plain"> name</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain" style="display:inline-block"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">    </span><span class="token keyword" style="color:rgb(127, 219, 202)">public</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">static</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">readonly</span><span class="token plain"> </span><span class="token class-name" style="color:rgb(255, 203, 139)">PaymentStatus</span><span class="token plain"> Pending </span><span class="token operator" style="color:rgb(127, 219, 202)">=</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">new</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token string" style="color:rgb(173, 219, 103)">"Pending"</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">    </span><span class="token keyword" style="color:rgb(127, 219, 202)">public</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">static</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">readonly</span><span class="token plain"> </span><span class="token class-name" style="color:rgb(255, 203, 139)">PaymentStatus</span><span class="token plain"> Paid </span><span class="token operator" style="color:rgb(127, 219, 202)">=</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">new</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token string" style="color:rgb(173, 219, 103)">"Paid"</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">    </span><span class="token keyword" style="color:rgb(127, 219, 202)">public</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">static</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">readonly</span><span class="token plain"> </span><span class="token class-name" style="color:rgb(255, 203, 139)">PaymentStatus</span><span class="token plain"> Failed </span><span class="token operator" style="color:rgb(127, 219, 202)">=</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">new</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token string" style="color:rgb(173, 219, 103)">"Failed"</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">    </span><span class="token keyword" style="color:rgb(127, 219, 202)">public</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">static</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">readonly</span><span class="token plain"> </span><span class="token class-name" style="color:rgb(255, 203, 139)">PaymentStatus</span><span class="token plain"> Refunded </span><span class="token operator" style="color:rgb(127, 219, 202)">=</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">new</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token string" style="color:rgb(173, 219, 103)">"Refunded"</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain" style="display:inline-block"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">    </span><span class="token keyword" style="color:rgb(127, 219, 202)">public</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">override</span><span class="token plain"> </span><span class="token return-type class-name keyword" style="color:rgb(127, 219, 202)">string</span><span class="token plain"> </span><span class="token function" style="color:rgb(130, 170, 255)">ToString</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"> </span><span class="token operator" style="color:rgb(127, 219, 202)">=&gt;</span><span class="token plain"> Name</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"></span><span class="token punctuation" style="color:rgb(199, 146, 234)">}</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain" style="display:inline-block"></span><br></span></code></pre></div></div></div></div></div>
<p>Refactor your logic:</p>
<div class="tabs-container tabList__CuJ"><ul role="tablist" aria-orientation="horizontal" class="tabs"><li role="tab" tabindex="0" aria-selected="true" class="tabs__item tabItem_LNqP tabs__item--active">C#</li></ul><div class="margin-top--md"><div role="tabpanel" class="tabItem_Ymn6"><div class="language-csharp codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#d6deeb;--prism-background-color:#011627"><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-csharp codeBlock_bY9V thin-scrollbar" style="color:#d6deeb;background-color:#011627"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:#d6deeb"><span class="token keyword" style="color:rgb(127, 219, 202)">if</span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token plain">paymentStatus </span><span class="token operator" style="color:rgb(127, 219, 202)">==</span><span class="token plain"> PaymentStatus</span><span class="token punctuation" style="color:rgb(199, 146, 234)">.</span><span class="token plain">Paid</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"></span><span class="token punctuation" style="color:rgb(199, 146, 234)">{</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">    Console</span><span class="token punctuation" style="color:rgb(199, 146, 234)">.</span><span class="token function" style="color:rgb(130, 170, 255)">WriteLine</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token string" style="color:rgb(173, 219, 103)">"Payment successful. Order will be shipped."</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"></span><span class="token punctuation" style="color:rgb(199, 146, 234)">}</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"></span><span class="token keyword" style="color:rgb(127, 219, 202)">else</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">if</span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token plain">paymentStatus </span><span class="token operator" style="color:rgb(127, 219, 202)">==</span><span class="token plain"> PaymentStatus</span><span class="token punctuation" style="color:rgb(199, 146, 234)">.</span><span class="token plain">Failed</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"></span><span class="token punctuation" style="color:rgb(199, 146, 234)">{</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">    Console</span><span class="token punctuation" style="color:rgb(199, 146, 234)">.</span><span class="token function" style="color:rgb(130, 170, 255)">WriteLine</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token string" style="color:rgb(173, 219, 103)">"Payment failed. Notify the user."</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"></span><span class="token punctuation" style="color:rgb(199, 146, 234)">}</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain" style="display:inline-block"></span><br></span></code></pre></div></div></div></div></div>
<p>🔧 Why use Records?</p>
<ul>
<li>✅ Value-Based Equality: Two records with the same value are considered equal.</li>
<li>✅ Extensibility: Add properties like Color or Description for richer status handling.</li>
<li>✅ Immutability: Reduces accidental bugs.</li>
</ul>
<p>🔍 Use Case: When you need extensible, type-safe objects with metadata.</p>
<hr>
<h2 class="anchor anchorWithStickyNavbar_LWe7" id="quick-reference-when-to-use-what-">Quick Reference: when to use what? 📊<a href="https://chaibiscuit.rajivy.me/blog/magic-strings-cool-name-annoying-problem#quick-reference-when-to-use-what-" class="hash-link" aria-label="Direct link to Quick Reference: when to use what? 📊" title="Direct link to Quick Reference: when to use what? 📊">​</a></h2>
<table><thead><tr><th>Use-case</th><th>Best solution</th><th>Why</th></tr></thead><tbody><tr><td>Fixed, finite values</td><td>Enums</td><td>Type-safe and compile-time validated</td></tr><tr><td>Interacting with APIs or configs</td><td>Static Class with Constants</td><td>Flexible and easy to use</td></tr><tr><td>Adding metadata or behavior</td><td>Records</td><td>Extensible, type-safe, and modern</td></tr></tbody></table>
<hr>
<h2 class="anchor anchorWithStickyNavbar_LWe7" id="performance-considerations-">Performance considerations 🚀<a href="https://chaibiscuit.rajivy.me/blog/magic-strings-cool-name-annoying-problem#performance-considerations-" class="hash-link" aria-label="Direct link to Performance considerations 🚀" title="Direct link to Performance considerations 🚀">​</a></h2>
<p>When deciding between these approaches, consider their performance impact:</p>
<table><thead><tr><th>Solution</th><th>Performance</th><th>When It matters</th></tr></thead><tbody><tr><td>Enums</td><td>Fastest. No object creation.</td><td>Best for high-frequency comparisons.</td></tr><tr><td>Static Class</td><td>Slightly slower than Enums.</td><td>Ideal for systems relying on external APIs.</td></tr><tr><td>Records</td><td>Minor overhead for instantiation.</td><td>Use when extensibility outweighs performance.</td></tr></tbody></table>
<p>🔍 Key Insight:</p>
<ul>
<li>Enums are lightweight and fast, making them ideal for performance-critical scenarios like loops or frequent comparisons.</li>
<li>Static classes are a close second, with no instantiation cost.</li>
<li>Records add flexibility but may incur slight overhead due to object creation. For most applications, this overhead is negligible.</li>
</ul>
<hr>
<h2 class="anchor anchorWithStickyNavbar_LWe7" id="other-ways-to-handle-magic-strings-">Other ways to handle magic strings 🎲<a href="https://chaibiscuit.rajivy.me/blog/magic-strings-cool-name-annoying-problem#other-ways-to-handle-magic-strings-" class="hash-link" aria-label="Direct link to Other ways to handle magic strings 🎲" title="Direct link to Other ways to handle magic strings 🎲">​</a></h2>
<ol>
<li><strong>Resource Files (.resx):</strong> Use resource files for centralizing strings, especially when localization is needed. 🌐</li>
<li><strong>Configuration Providers:</strong> Use <code>.json</code> files (like <code>appsettings.json</code>) or <code>IConfiguration</code> in ASP.NET Core to store values. 🗂️</li>
<li><strong><code>nameof</code> Operator:</strong> Use <code>nameof</code> to reference property or class names safely instead of hardcoding.</li>
</ol>
<div class="tabs-container tabList__CuJ"><ul role="tablist" aria-orientation="horizontal" class="tabs"><li role="tab" tabindex="0" aria-selected="true" class="tabs__item tabItem_LNqP tabs__item--active">C#</li></ul><div class="margin-top--md"><div role="tabpanel" class="tabItem_Ymn6"><div class="language-csharp codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#d6deeb;--prism-background-color:#011627"><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-csharp codeBlock_bY9V thin-scrollbar" style="color:#d6deeb;background-color:#011627"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:#d6deeb"><span class="token class-name keyword" style="color:rgb(127, 219, 202)">string</span><span class="token plain"> propName </span><span class="token operator" style="color:rgb(127, 219, 202)">=</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">nameof</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token plain">MyClass</span><span class="token punctuation" style="color:rgb(199, 146, 234)">.</span><span class="token plain">MyProperty</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span><span class="token plain"> </span><span class="token comment" style="color:rgb(99, 119, 119);font-style:italic">// Outputs "MyProperty"</span><br></span></code></pre></div></div></div></div></div>
<ol start="4">
<li><strong>CallerMemberName Attribute:</strong> Helps fetch member names automatically, reducing the need for magic strings. 🪄</li>
</ol>
<div class="tabs-container tabList__CuJ"><ul role="tablist" aria-orientation="horizontal" class="tabs"><li role="tab" tabindex="0" aria-selected="true" class="tabs__item tabItem_LNqP tabs__item--active">C#</li></ul><div class="margin-top--md"><div role="tabpanel" class="tabItem_Ymn6"><div class="language-csharp codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#d6deeb;--prism-background-color:#011627"><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-csharp codeBlock_bY9V thin-scrollbar" style="color:#d6deeb;background-color:#011627"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:#d6deeb"><span class="token keyword" style="color:rgb(127, 219, 202)">public</span><span class="token plain"> </span><span class="token return-type class-name keyword" style="color:rgb(127, 219, 202)">void</span><span class="token plain"> </span><span class="token function" style="color:rgb(130, 170, 255)">Log</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token class-name keyword" style="color:rgb(127, 219, 202)">string</span><span class="token plain"> message</span><span class="token punctuation" style="color:rgb(199, 146, 234)">,</span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(199, 146, 234)">[</span><span class="token attribute class-name" style="color:rgb(255, 203, 139)">CallerMemberName</span><span class="token punctuation" style="color:rgb(199, 146, 234)">]</span><span class="token plain"> </span><span class="token class-name keyword" style="color:rgb(127, 219, 202)">string</span><span class="token plain"> memberName </span><span class="token operator" style="color:rgb(127, 219, 202)">=</span><span class="token plain"> </span><span class="token string" style="color:rgb(173, 219, 103)">""</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"></span><span class="token punctuation" style="color:rgb(199, 146, 234)">{</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">    Console</span><span class="token punctuation" style="color:rgb(199, 146, 234)">.</span><span class="token function" style="color:rgb(130, 170, 255)">WriteLine</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token interpolation-string string" style="color:rgb(173, 219, 103)">$"</span><span class="token interpolation-string interpolation punctuation" style="color:rgb(199, 146, 234)">{</span><span class="token interpolation-string interpolation expression language-csharp">memberName</span><span class="token interpolation-string interpolation punctuation" style="color:rgb(199, 146, 234)">}</span><span class="token interpolation-string string" style="color:rgb(173, 219, 103)">: </span><span class="token interpolation-string interpolation punctuation" style="color:rgb(199, 146, 234)">{</span><span class="token interpolation-string interpolation expression language-csharp">message</span><span class="token interpolation-string interpolation punctuation" style="color:rgb(199, 146, 234)">}</span><span class="token interpolation-string string" style="color:rgb(173, 219, 103)">"</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"></span><span class="token punctuation" style="color:rgb(199, 146, 234)">}</span><br></span></code></pre></div></div></div></div></div>
<ol start="5">
<li><strong>Constants with string interpolation:</strong> Use constants and string interpolation to dynamically construct strings. 💻</li>
</ol>
<div class="tabs-container tabList__CuJ"><ul role="tablist" aria-orientation="horizontal" class="tabs"><li role="tab" tabindex="0" aria-selected="true" class="tabs__item tabItem_LNqP tabs__item--active">C#</li></ul><div class="margin-top--md"><div role="tabpanel" class="tabItem_Ymn6"><div class="language-csharp codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#d6deeb;--prism-background-color:#011627"><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-csharp codeBlock_bY9V thin-scrollbar" style="color:#d6deeb;background-color:#011627"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:#d6deeb"><span class="token keyword" style="color:rgb(127, 219, 202)">public</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">const</span><span class="token plain"> </span><span class="token class-name keyword" style="color:rgb(127, 219, 202)">string</span><span class="token plain"> EnvironmentPrefix </span><span class="token operator" style="color:rgb(127, 219, 202)">=</span><span class="token plain"> </span><span class="token string" style="color:rgb(173, 219, 103)">"ENV_"</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"></span><span class="token class-name keyword" style="color:rgb(127, 219, 202)">string</span><span class="token plain"> envKey </span><span class="token operator" style="color:rgb(127, 219, 202)">=</span><span class="token plain"> </span><span class="token interpolation-string string" style="color:rgb(173, 219, 103)">$"</span><span class="token interpolation-string interpolation punctuation" style="color:rgb(199, 146, 234)">{</span><span class="token interpolation-string interpolation expression language-csharp">EnvironmentPrefix</span><span class="token interpolation-string interpolation punctuation" style="color:rgb(199, 146, 234)">}</span><span class="token interpolation-string string" style="color:rgb(173, 219, 103)">Production"</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span><br></span></code></pre></div></div></div></div></div>
<hr>
<h2 class="anchor anchorWithStickyNavbar_LWe7" id="when-magic-strings-are-okay-️">When Magic strings are okay 🤷‍♂️<a href="https://chaibiscuit.rajivy.me/blog/magic-strings-cool-name-annoying-problem#when-magic-strings-are-okay-%EF%B8%8F" class="hash-link" aria-label="Direct link to When Magic strings are okay 🤷‍♂️" title="Direct link to When Magic strings are okay 🤷‍♂️">​</a></h2>
<p>Magic strings aren’t always bad. In prototypes or one-off scripts, replacing magic strings might add unnecessary complexity. It’s key to know when to keep things simple instead of getting caught up in making it all fancy and perfect.</p>
<p><strong>Rule of Thumb</strong>:</p>
<ul>
<li>Use magic strings if the code is short-lived, simple, or personal.</li>
<li>Avoid magic strings for production systems or codebases that require maintenance or collaboration.</li>
</ul>
<p><strong>Pragmatism over perfection</strong></p>
<p>Sometimes, the pursuit of “perfect code” leads to overengineering. Remember: pragmatism is key. If a magic string serves its purpose without causing confusion or errors, it’s a perfectly valid choice.</p>
<h2 class="anchor anchorWithStickyNavbar_LWe7" id="conclusion">Conclusion<a href="https://chaibiscuit.rajivy.me/blog/magic-strings-cool-name-annoying-problem#conclusion" class="hash-link" aria-label="Direct link to Conclusion" title="Direct link to Conclusion">​</a></h2>
<p>Magic strings are a small problem with big consequences. Whether you choose <code>enums</code>, <code>static constants</code>, or <code>record with readonly static fields</code>, centralizing your values will make your code safer and easier to maintain.</p>
<p>Combine these solutions with .NET features like <code>nameof</code> and resource files for extra power. 🚀</p>
<p>As always don’t forget - <strong>chai ☕ fuels the mind, biscuits 🍪 fuel the soul, and clean code fuels the future 🧼.</strong></p>
<p><strong>🎉Happy coding!!🎉</strong></p>
<div class="theme-admonition theme-admonition-info admonition_xJq3 alert alert--info"><div class="admonitionHeading_Gvgb"><span class="admonitionIcon_Rf37"><svg viewBox="0 0 14 16"><path fill-rule="evenodd" d="M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"></path></svg></span>☕ Fuel the Journey!</div><div class="admonitionContent_BuS1"><p>Loved this post? <strong><a href="https://buymeacoffee.com/rajivy" target="_blank" rel="noopener noreferrer">buying me a coffee ☕</a> (or chai 🍵!)</strong> is like sending me a high-five for a job well done. Your support means so much!</p></div></div>]]></content:encoded>
            <category>dotnet</category>
            <category>learning</category>
            <category>aspnet-core</category>
            <category>magic-strings</category>
            <category>clean-code</category>
        </item>
        <item>
            <title><![CDATA[That One line you missed that’s causing weird ASP.NET Core validation Issues!]]></title>
            <link>https://chaibiscuit.rajivy.me/blog/one-line-you-missed</link>
            <guid>https://chaibiscuit.rajivy.me/blog/one-line-you-missed</guid>
            <pubDate>Fri, 30 Aug 2024 00:00:00 GMT</pubDate>
            <description><![CDATA[✨ Forgot this line? Your ASP.NET Core app validation might act strange! ✨]]></description>
            <content:encoded><![CDATA[<p>✨ <strong>Forgot this line? Your ASP.NET Core app validation might act strange!</strong> ✨</p>
<p>Okay, confession time—I recently encountered a strange issue with my ASP.NET Core validation in an inherited codebase. After some digging, I realized that a simple but crucial step had been missed, causing some pretty frustrating errors. I wanted to share this information with you, and perhaps with my future self, to ensure that we never encounter this issue again.</p>
<p><img decoding="async" loading="lazy" alt="thumbnail post" src="https://chaibiscuit.rajivy.me/assets/images/mistake_thumb-6387d56821d38ad29d94a7ce14fd92c4.jpg" width="600" height="600" class="img_ev3q"></p>
<p>Stick with me for the next few minutes, and you’ll learn how to take full control of your model validation in ASP.NET Core, avoiding those annoying, unexpected validation errors that can really throw a wrench in your project.</p>
<p>So here's what happened. ASP.NET Core is really into using data annotations for validation. It's like a kid with a new toy. However, when using FluentValidation, you don't need or want those built-in validators to interfere with your setup. They can cause redundant checks or conflicts, leading to some pretty strange behaviour in your app.</p>
<p>While working on that bug in this inherited codebase the other day, I found that the original setup didn’t account for clearing out those default model validators, which is crucial to ensuring FluentValidation works without interference. Before fixing this, whenever a validation error occurred—like passing a null value for the username—the response would look something like this:</p>
<div class="language-json codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#d6deeb;--prism-background-color:#011627"><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-json codeBlock_bY9V thin-scrollbar" style="color:#d6deeb;background-color:#011627"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:#d6deeb"><span class="token plain">{</span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">  "type": "https://tools.ietf.org/html/rfc9110#section-15.5.1",</span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">  "title": "One or more validation errors occurred.",</span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">  "status": 400,</span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">  "errors": {</span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">    "UserName": [</span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">      "The UserName field is required."</span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">    ]</span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">  },</span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">  "traceId": "00-54173eba85492e9c17e12babf8c19ed3-f97dca20a4c12b47-00"</span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">}</span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain" style="display:inline-block"></span><br></span></code></pre></div></div>
<p>This error response was due to the default data annotation validators kicking in. It never even hit the controller during debugging, which made diagnosing the issue a bit tricky.</p>
<p>The fix is super simple, though. You just need to add this little line to your service configuration:</p>
<p>Here’s the code you need:</p>
<div class="language-csharp codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#d6deeb;--prism-background-color:#011627"><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-csharp codeBlock_bY9V thin-scrollbar" style="color:#d6deeb;background-color:#011627"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:#d6deeb"><span class="token plain">services</span><span class="token punctuation" style="color:rgb(199, 146, 234)">.</span><span class="token function" style="color:rgb(130, 170, 255)">AddControllers</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token plain">options </span><span class="token operator" style="color:rgb(127, 219, 202)">=&gt;</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"></span><span class="token punctuation" style="color:rgb(199, 146, 234)">{</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">    options</span><span class="token punctuation" style="color:rgb(199, 146, 234)">.</span><span class="token plain">ModelValidatorProviders</span><span class="token punctuation" style="color:rgb(199, 146, 234)">.</span><span class="token function" style="color:rgb(130, 170, 255)">Clear</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span><span class="token plain"> </span><span class="token comment" style="color:rgb(99, 119, 119);font-style:italic">// Removes all data annotation validation providers</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"></span><span class="token punctuation" style="color:rgb(199, 146, 234)">}</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain"></span><span class="token punctuation" style="color:rgb(199, 146, 234)">.</span><span class="token function" style="color:rgb(130, 170, 255)">AddFluentValidation</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token plain">fv </span><span class="token operator" style="color:rgb(127, 219, 202)">=&gt;</span><span class="token plain"> fv</span><span class="token punctuation" style="color:rgb(199, 146, 234)">.</span><span class="token generic-method function" style="color:rgb(130, 170, 255)">RegisterValidatorsFromAssemblyContaining</span><span class="token generic-method generic class-name punctuation" style="color:rgb(199, 146, 234)">&lt;</span><span class="token generic-method generic class-name" style="color:rgb(255, 203, 139)">Startup</span><span class="token generic-method generic class-name punctuation" style="color:rgb(199, 146, 234)">&gt;</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain" style="display:inline-block"></span><br></span></code></pre></div></div>
<p>This line basically says, “Hey, ASP.NET Core, thanks for the help, but we’ve got this covered.” It clears out all the data annotation validators, letting FluentValidation handle everything just the way you set it up. After adding this line, the validation errors became much more manageable and looked like this from the FluentValidation library:</p>
<div class="language-json codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#d6deeb;--prism-background-color:#011627"><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-json codeBlock_bY9V thin-scrollbar" style="color:#d6deeb;background-color:#011627"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:#d6deeb"><span class="token plain">{</span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">  "type": "Validation",</span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">  "title": "ValidationError",</span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">  "status": 400,</span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">  "detail": "A validation problem occurred.",</span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">  "Extension": [</span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">    {</span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">      "code": "request.UserName",</span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">      "message": "UserName field is required."</span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">    }</span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">  ]</span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">}</span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain" style="display:inline-block"></span><br></span></code></pre></div></div>
<p>No more surprises, just smooth sailing.</p>
<h2 class="anchor anchorWithStickyNavbar_LWe7" id="conclusion">Conclusion<a href="https://chaibiscuit.rajivy.me/blog/one-line-you-missed#conclusion" class="hash-link" aria-label="Direct link to Conclusion" title="Direct link to Conclusion">​</a></h2>
<p>So, for future me and everyone else, don't skip this step! Adding that line will make your validation life a whole lot easier. Let’s keep things clean and simple together!</p>
<p>As always, here’s to a productive day with warm chai ☕, crunchy biscuits 🍪, and bug-free code 🐞.</p>
<p><strong>🎉Happy coding!!🎉</strong></p>
<div class="theme-admonition theme-admonition-info admonition_xJq3 alert alert--info"><div class="admonitionHeading_Gvgb"><span class="admonitionIcon_Rf37"><svg viewBox="0 0 14 16"><path fill-rule="evenodd" d="M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"></path></svg></span>🔥 Keep the Chai Brewing!</div><div class="admonitionContent_BuS1"><p>If this post added value to your day,consider adding value to mine with a <strong><a href="https://buymeacoffee.com/rajivy" target="_blank" rel="noopener noreferrer">coffee ☕</a> (or chai 🍵!)</strong>. Every sip counts—thank you for your support!</p></div></div>]]></content:encoded>
            <category>dotnet</category>
            <category>learning</category>
            <category>aspnet-core</category>
        </item>
        <item>
            <title><![CDATA[Master screen sharing like a Pro with this simple tool]]></title>
            <link>https://chaibiscuit.rajivy.me/blog/screen-sharing-like-pro</link>
            <guid>https://chaibiscuit.rajivy.me/blog/screen-sharing-like-pro</guid>
            <pubDate>Fri, 02 Aug 2024 00:00:00 GMT</pubDate>
            <description><![CDATA[✨ The go-to tool for annotating during presentations, screen shares, and pair programming! ✨]]></description>
            <content:encoded><![CDATA[<p>✨ <strong>The go-to tool for annotating during presentations, screen shares, and pair programming!</strong> ✨</p>
<p>Hey everyone! Do you ever find yourself struggling to see the screen during a presentation or getting lost while following along during a pair programming session? Just imagine never having to ask, <strong>'Can you see this?'</strong> or say, <strong>'Wait, let me zoom in.'</strong></p>
<p>Well, guess what? I've got a game-changer for you. Meet <strong>ZoomIt</strong> – the tool you didn't know you needed but won't be able to live without. It's going to revolutionize the way you do screen sharing, presentations, and pair programming. Curious? Stick around, because you won’t want to miss how ZoomIt can make your life so much easier and more fun!</p>
<p><img decoding="async" loading="lazy" alt="thumbnail post" src="https://chaibiscuit.rajivy.me/assets/images/zoomi-it-thumb-3fd028f9e376d551f5dc0af1eab82c90.jpg" width="1200" height="644" class="img_ev3q"></p>
<p><strong><a href="https://learn.microsoft.com/en-us/sysinternals/downloads/zoomit" target="_blank" rel="noopener noreferrer">ZoomIt</a></strong> is a useful tool developed by Microsoft, ideal for presentations, pair programming, and screen sharing.</p>
<p>I assure you, it's very simple to use. I've used ZoomIt a lot in my own presentations and software development meetings, and I can tell you, it's super useful and easy to use.</p>
<p>In this post, I'll tell you all about ZoomIt, from its key features to some practical tips on getting the most out of it. Let's dive in!</p>
<h2 class="anchor anchorWithStickyNavbar_LWe7" id="tldr---version">TL;DR - version<a href="https://chaibiscuit.rajivy.me/blog/screen-sharing-like-pro#tldr---version" class="hash-link" aria-label="Direct link to TL;DR - version" title="Direct link to TL;DR - version">​</a></h2>
<p>Zoomit is a versatile tool for zooming, annotating, and timing during presentations. It's user-friendly and perfect for educators, presenters, tech support, and software developers.</p>
<p>You can get it from here <a href="https://docs.microsoft.com/en-us/sysinternals/downloads/zoomit" target="_blank" rel="noopener noreferrer">download</a></p>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="commands-list">Commands list<a href="https://chaibiscuit.rajivy.me/blog/screen-sharing-like-pro#commands-list" class="hash-link" aria-label="Direct link to Commands list" title="Direct link to Commands list">​</a></h3>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="zoom-functions">Zoom Functions<a href="https://chaibiscuit.rajivy.me/blog/screen-sharing-like-pro#zoom-functions" class="hash-link" aria-label="Direct link to Zoom Functions" title="Direct link to Zoom Functions">​</a></h3>
<table><thead><tr><th>Function</th><th>Shortcut</th></tr></thead><tbody><tr><td>Zoom Mode</td><td>Ctrl + 1</td></tr><tr><td>Zoom In</td><td>Mouse Scroll Up or Up Arrow</td></tr><tr><td>Zoom Out</td><td>Mouse Scroll Down or Down Arrow</td></tr><tr><td>Live Zoom Mode</td><td>Ctrl + 4</td></tr></tbody></table>
<p>Detailed list of commands are listed <a href="https://chaibiscuit.rajivy.me/category/misc/zoomit_cheat_sheet">here.</a></p>
<h2 class="anchor anchorWithStickyNavbar_LWe7" id="key-features">Key Features<a href="https://chaibiscuit.rajivy.me/blog/screen-sharing-like-pro#key-features" class="hash-link" aria-label="Direct link to Key Features" title="Direct link to Key Features">​</a></h2>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="1-zoom-feature">1. Zoom Feature<a href="https://chaibiscuit.rajivy.me/blog/screen-sharing-like-pro#1-zoom-feature" class="hash-link" aria-label="Direct link to 1. Zoom Feature" title="Direct link to 1. Zoom Feature">​</a></h3>
<ul>
<li><strong>How it works</strong>: To zoom in, simply press <code>Ctrl + 1</code> and you're all set! This feature allows you to emphasize specific lines of code or parts of a document. You can adjust the zoom level using your mouse wheel or arrow keys and exit zoom mode by pressing <code>Esc</code> or right-clicking.</li>
<li><strong>My Experience</strong>: I found the zoom feature very user-friendly. During a recent pair programming session, I used it to enlarge an important code block, and the audience response was extremely positive.</li>
</ul>
<p><img decoding="async" loading="lazy" alt="zoom_feature" src="https://chaibiscuit.rajivy.me/assets/images/zoomi-it-2-a8a41c98a36d48d20b3a702f2e74de8d.jpg" width="1200" height="332" class="img_ev3q"></p>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="2-live-zoom-mode">2. Live Zoom Mode:<a href="https://chaibiscuit.rajivy.me/blog/screen-sharing-like-pro#2-live-zoom-mode" class="hash-link" aria-label="Direct link to 2. Live Zoom Mode:" title="Direct link to 2. Live Zoom Mode:">​</a></h3>
<ul>
<li><strong>How it works</strong>: You can draw, type, and highlight directly on your screen. This is perfect for emphasizing important points or illustrating concepts on the fly. To activate this function, press <code>Ctrl + 4</code>. Adjust the zoom level similarly, and exit by pressing <code>Esc</code> or right-clicking.</li>
<li><strong>My Experience</strong>: The Live-zoom mode has been instrumental. I use it in code reviews to highlight specific areas of my code, for editing text, or navigating while keeping things magnified.</li>
</ul>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="3-drawing-on-the-screen">3. Drawing on the screen<a href="https://chaibiscuit.rajivy.me/blog/screen-sharing-like-pro#3-drawing-on-the-screen" class="hash-link" aria-label="Direct link to 3. Drawing on the screen" title="Direct link to 3. Drawing on the screen">​</a></h3>
<ul>
<li><strong>How it works</strong>: Now, let’s talk about drawing. To start drawing on your screen, press <code>Ctrl + 2</code>. Use the left mouse button to draw and the right mouse button to erase. You can change the color of your pen by pressing <code>R</code> for red, <code>G</code> for green, <code>B</code> for blue, <code>O</code> for orange,<code>Y</code> for yellow and <code>P</code> for pink. For a thicker or thinner line, hold <code>Ctrl</code> and use the mouse wheel. Press <code>Ctrl + K</code> to clear everything, and when you’re done, hit <code>Esc</code>.</li>
<li><strong>My Experience</strong>: Using the screen for drawing has significantly improved my screen shares. It helps me highlight key points and explain complex concepts to my team.</li>
</ul>
<p><img decoding="async" loading="lazy" alt="tldr;_version" src="https://chaibiscuit.rajivy.me/assets/images/zoomi-it-5-dc31d6c6abb337fb9d4065aa6be52d1d.jpg" width="1200" height="632" class="img_ev3q"></p>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="4-typing-text">4. Typing Text<a href="https://chaibiscuit.rajivy.me/blog/screen-sharing-like-pro#4-typing-text" class="hash-link" aria-label="Direct link to 4. Typing Text" title="Direct link to 4. Typing Text">​</a></h3>
<ul>
<li><strong>How it works</strong>: To type text on your screen, press <code>T</code>. You can then type using your keyboard. When you’re done, press <code>Esc</code> to exit text typing mode.</li>
<li><strong>My Experience</strong>: Typing text on the screen has been a game-changer for me. I use it to add comments to my code during pair programming sessions, and it has been a massive help in explaining my thought process to my team.</li>
</ul>
<p><img decoding="async" loading="lazy" alt="drawing_on_the_screen" src="https://chaibiscuit.rajivy.me/assets/images/zoomi-it-3-46e3bad74ef515e7ef4c7fd41ebc6fc4.jpg" width="1200" height="278" class="img_ev3q"></p>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="5-setting-a-break-timer">5. Setting a break-timer<a href="https://chaibiscuit.rajivy.me/blog/screen-sharing-like-pro#5-setting-a-break-timer" class="hash-link" aria-label="Direct link to 5. Setting a break-timer" title="Direct link to 5. Setting a break-timer">​</a></h3>
<ul>
<li><strong>How it works</strong>: To set a break timer, press <code>Ctrl + 3</code>. You can adjust the timer duration using the up and down arrow keys. Press <code>Spacebar</code> to start or pause the timer, and <code>Esc</code> to exit the break timer mode.</li>
<li><strong>My Experience</strong>: I have used this feature when conducting sprint retrospectives with my team. You can start a timer and wait for everyone to finish adding their sticky notes to the board.</li>
</ul>
<p><img decoding="async" loading="lazy" alt="drawing_on_the_screen" src="https://chaibiscuit.rajivy.me/assets/images/zoom-it-4-8a7a9bbad8cd65b675b05cd3fa487475.png" width="1200" height="800" class="img_ev3q"></p>
<h2 class="anchor anchorWithStickyNavbar_LWe7" id="practical-tips">Practical tips<a href="https://chaibiscuit.rajivy.me/blog/screen-sharing-like-pro#practical-tips" class="hash-link" aria-label="Direct link to Practical tips" title="Direct link to Practical tips">​</a></h2>
<p><strong>For Presenters</strong>: Utilize the zoom feature to focus on detailed parts of your slides.</p>
<p><strong>For Software Developers</strong>: Use the zoom and annotation tools to highlight specific lines of code during code reviews or to illustrate how a particular code-block works.</p>
<h2 class="anchor anchorWithStickyNavbar_LWe7" id="my-personal-use-case">My personal use case<a href="https://chaibiscuit.rajivy.me/blog/screen-sharing-like-pro#my-personal-use-case" class="hash-link" aria-label="Direct link to My personal use case" title="Direct link to My personal use case">​</a></h2>
<p><strong>Using ZoomIt in Pair Programming and Screen Sharing:</strong></p>
<p>Imagine you're working with a teammate and need to focus on a specific code block. You can zoom in using <code>Ctrl + 1</code> to guide them through it. If you need to highlight an important section, use <code>Ctrl + 2</code> to draw around it. And if you're explaining something complex, type it out on the screen using the <code>T</code> key.
Having a break timer handy is also a game changer. It helps you manage your time efficiently and ensures you take breaks to avoid burnout, making your sessions more productive and engaging.</p>
<p><img decoding="async" loading="lazy" alt="tldr;_version" src="https://chaibiscuit.rajivy.me/assets/images/zoomi-it-2-a8a41c98a36d48d20b3a702f2e74de8d.jpg" width="1200" height="332" class="img_ev3q"></p>
<h2 class="anchor anchorWithStickyNavbar_LWe7" id="conclusion">Conclusion<a href="https://chaibiscuit.rajivy.me/blog/screen-sharing-like-pro#conclusion" class="hash-link" aria-label="Direct link to Conclusion" title="Direct link to Conclusion">​</a></h2>
<p>So, there you have it! ZoomIt is a potent tool that improves presentations, pair programming, and screen-sharing sessions. Give it a try, and you'll wonder how you managed without it.</p>
<p>Let’s keep it going: smashing bugs 🐛, sipping chai ☕, and enjoying perfectly dunked biscuits 🍪.</p>
<p><strong>🎉Happy coding!!🎉</strong></p>
<div class="theme-admonition theme-admonition-info admonition_xJq3 alert alert--info"><div class="admonitionHeading_Gvgb"><span class="admonitionIcon_Rf37"><svg viewBox="0 0 14 16"><path fill-rule="evenodd" d="M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"></path></svg></span>🔥 Keep the Chai Brewing!</div><div class="admonitionContent_BuS1"><p>If you have enjoyed this post, please consider <strong><a href="https://buymeacoffee.com/rajivy" target="_blank" rel="noopener noreferrer">buying me a coffee ☕</a></strong> to help me keep writing!</p></div></div>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Easy Tips for Writing Cleaner Code]]></title>
            <link>https://chaibiscuit.rajivy.me/blog/10-refactoring-tips</link>
            <guid>https://chaibiscuit.rajivy.me/blog/10-refactoring-tips</guid>
            <pubDate>Sun, 21 Jul 2024 00:00:00 GMT</pubDate>
            <description><![CDATA[✨ 10 Simple refactoring hacks for cleaner, better code! ✨]]></description>
            <content:encoded><![CDATA[<p>✨ <strong>10 Simple refactoring hacks for cleaner, better code!</strong> ✨</p>
<p>Hey there, fellow coders! Have you ever looked at your code and thought, "Wow, this is messier than a toddler's art project!"? Well, you're not alone.</p>
<p>Today, we're delving into the enchanting world of refactoring. It's akin to spring-cleaning for your code, but much more gratifying!</p>
<p><img decoding="async" loading="lazy" alt="thumbnail post" src="https://chaibiscuit.rajivy.me/assets/images/easy-tips-thumb-734965d9cd9d9bd0219416cc70ed5aa6.jpg" width="765" height="904" class="img_ev3q"></p>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="tldr---version">TL;DR - version<a href="https://chaibiscuit.rajivy.me/blog/10-refactoring-tips#tldr---version" class="hash-link" aria-label="Direct link to TL;DR - version" title="Direct link to TL;DR - version">​</a></h3>
<p><img decoding="async" loading="lazy" alt="challenges" src="https://chaibiscuit.rajivy.me/assets/images/easy-tips-1-6a838f577f27b4dfa4df650eb34ba69c.jpg" width="1042" height="1024" class="img_ev3q"></p>
<p>Alright, let’s get into it. Refactoring involves enhancing your code without altering its functionality. Think of it as renovating a house: you’re not relocating but simply improving the living space.</p>
<div class="theme-admonition theme-admonition-info admonition_xJq3 alert alert--info"><div class="admonitionHeading_Gvgb"><span class="admonitionIcon_Rf37"><svg viewBox="0 0 14 16"><path fill-rule="evenodd" d="M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"></path></svg></span>info</div><div class="admonitionContent_BuS1"><p>Remember, this is not an exhaustive list. There are many other practices and principles to consider when writing clean code. These tips are a great starting point!</p></div></div>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="tip-1-extract-method">Tip-1: Extract Method<a href="https://chaibiscuit.rajivy.me/blog/10-refactoring-tips#tip-1-extract-method" class="hash-link" aria-label="Direct link to Tip-1: Extract Method" title="Direct link to Tip-1: Extract Method">​</a></h3>
<p>Got a chunk of code that performs a specific task? Extract it into its own method! This enhances the readability of your main code and makes your methods more reusable.</p>
<div class="tabs-container tabList__CuJ"><ul role="tablist" aria-orientation="horizontal" class="tabs"><li role="tab" tabindex="0" aria-selected="true" class="tabs__item tabItem_LNqP tabs__item--active">C#</li></ul><div class="margin-top--md"><div role="tabpanel" class="tabItem_Ymn6"><div class="language-csharp codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#d6deeb;--prism-background-color:#011627"><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-csharp codeBlock_bY9V thin-scrollbar" style="color:#d6deeb;background-color:#011627"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:#d6deeb"><span class="token plain">   </span><span class="token comment" style="color:rgb(99, 119, 119);font-style:italic">// Before</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">    </span><span class="token class-name keyword" style="color:rgb(127, 219, 202)">double</span><span class="token plain"> total </span><span class="token operator" style="color:rgb(127, 219, 202)">=</span><span class="token plain"> </span><span class="token number" style="color:rgb(247, 140, 108)">0</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">    </span><span class="token keyword" style="color:rgb(127, 219, 202)">foreach</span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token class-name keyword" style="color:rgb(127, 219, 202)">var</span><span class="token plain"> item </span><span class="token keyword" style="color:rgb(127, 219, 202)">in</span><span class="token plain"> cart</span><span class="token punctuation" style="color:rgb(199, 146, 234)">.</span><span class="token plain">Items</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">    </span><span class="token punctuation" style="color:rgb(199, 146, 234)">{</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">        total </span><span class="token operator" style="color:rgb(127, 219, 202)">+=</span><span class="token plain"> item</span><span class="token punctuation" style="color:rgb(199, 146, 234)">.</span><span class="token plain">Price </span><span class="token operator" style="color:rgb(127, 219, 202)">*</span><span class="token plain"> </span><span class="token number" style="color:rgb(247, 140, 108)">0.9</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span><span class="token plain"> </span><span class="token comment" style="color:rgb(99, 119, 119);font-style:italic">// applying discount</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">    </span><span class="token punctuation" style="color:rgb(199, 146, 234)">}</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">   </span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">   </span><span class="token comment" style="color:rgb(99, 119, 119);font-style:italic">// After</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">   </span><span class="token class-name keyword" style="color:rgb(127, 219, 202)">double</span><span class="token plain"> total </span><span class="token operator" style="color:rgb(127, 219, 202)">=</span><span class="token plain"> </span><span class="token function" style="color:rgb(130, 170, 255)">CalculateTotal</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token plain">cart</span><span class="token punctuation" style="color:rgb(199, 146, 234)">.</span><span class="token plain">Items</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain" style="display:inline-block"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">   </span><span class="token keyword" style="color:rgb(127, 219, 202)">private</span><span class="token plain"> </span><span class="token return-type class-name keyword" style="color:rgb(127, 219, 202)">double</span><span class="token plain"> </span><span class="token function" style="color:rgb(130, 170, 255)">CalculateTotal</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token class-name" style="color:rgb(255, 203, 139)">List</span><span class="token class-name punctuation" style="color:rgb(199, 146, 234)">&lt;</span><span class="token class-name" style="color:rgb(255, 203, 139)">Item</span><span class="token class-name punctuation" style="color:rgb(199, 146, 234)">&gt;</span><span class="token plain"> items</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">   </span><span class="token punctuation" style="color:rgb(199, 146, 234)">{</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">       </span><span class="token class-name keyword" style="color:rgb(127, 219, 202)">double</span><span class="token plain"> total </span><span class="token operator" style="color:rgb(127, 219, 202)">=</span><span class="token plain"> </span><span class="token number" style="color:rgb(247, 140, 108)">0</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">       </span><span class="token keyword" style="color:rgb(127, 219, 202)">foreach</span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token class-name keyword" style="color:rgb(127, 219, 202)">var</span><span class="token plain"> item </span><span class="token keyword" style="color:rgb(127, 219, 202)">in</span><span class="token plain"> items</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">       </span><span class="token punctuation" style="color:rgb(199, 146, 234)">{</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">           total </span><span class="token operator" style="color:rgb(127, 219, 202)">+=</span><span class="token plain"> item</span><span class="token punctuation" style="color:rgb(199, 146, 234)">.</span><span class="token plain">Price </span><span class="token operator" style="color:rgb(127, 219, 202)">*</span><span class="token plain"> </span><span class="token number" style="color:rgb(247, 140, 108)">0.9</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span><span class="token plain"> </span><span class="token comment" style="color:rgb(99, 119, 119);font-style:italic">// applying discount</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">       </span><span class="token punctuation" style="color:rgb(199, 146, 234)">}</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain" style="display:inline-block"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">       </span><span class="token keyword" style="color:rgb(127, 219, 202)">return</span><span class="token plain"> total</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">   </span><span class="token punctuation" style="color:rgb(199, 146, 234)">}</span><br></span></code></pre></div></div></div></div></div>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="tip-2-rename-variable">Tip-2: Rename Variable<a href="https://chaibiscuit.rajivy.me/blog/10-refactoring-tips#tip-2-rename-variable" class="hash-link" aria-label="Direct link to Tip-2: Rename Variable" title="Direct link to Tip-2: Rename Variable">​</a></h3>
<p>Naming can be challenging, but using descriptive names for variables, such as <code>customerDiscount</code> or <code>currentBalance</code>, is worth the effort. This small change can make your code much more understandable.</p>
<div class="tabs-container tabList__CuJ"><ul role="tablist" aria-orientation="horizontal" class="tabs"><li role="tab" tabindex="0" aria-selected="true" class="tabs__item tabItem_LNqP tabs__item--active">C#</li></ul><div class="margin-top--md"><div role="tabpanel" class="tabItem_Ymn6"><div class="language-csharp codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#d6deeb;--prism-background-color:#011627"><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-csharp codeBlock_bY9V thin-scrollbar" style="color:#d6deeb;background-color:#011627"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:#d6deeb"><span class="token plain">   </span><span class="token comment" style="color:rgb(99, 119, 119);font-style:italic">// Before</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">   </span><span class="token class-name keyword" style="color:rgb(127, 219, 202)">double</span><span class="token plain"> x </span><span class="token operator" style="color:rgb(127, 219, 202)">=</span><span class="token plain"> total </span><span class="token operator" style="color:rgb(127, 219, 202)">*</span><span class="token plain"> </span><span class="token number" style="color:rgb(247, 140, 108)">0.1</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain" style="display:inline-block"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">   </span><span class="token comment" style="color:rgb(99, 119, 119);font-style:italic">// After</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">   </span><span class="token class-name keyword" style="color:rgb(127, 219, 202)">double</span><span class="token plain"> customerDiscount </span><span class="token operator" style="color:rgb(127, 219, 202)">=</span><span class="token plain"> total </span><span class="token operator" style="color:rgb(127, 219, 202)">*</span><span class="token plain"> </span><span class="token number" style="color:rgb(247, 140, 108)">0.1</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span><br></span></code></pre></div></div></div></div></div>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="tip-3-replace-magic-numbers">Tip-3: Replace Magic Numbers<a href="https://chaibiscuit.rajivy.me/blog/10-refactoring-tips#tip-3-replace-magic-numbers" class="hash-link" aria-label="Direct link to Tip-3: Replace Magic Numbers" title="Direct link to Tip-3: Replace Magic Numbers">​</a></h3>
<p>If you encounter numbers like 7 or 42 directly in your code, substitute them with named constants. <code>const int MAXUSERS = 42;</code> tells you much more than just using 42 in your code.</p>
<div class="tabs-container tabList__CuJ"><ul role="tablist" aria-orientation="horizontal" class="tabs"><li role="tab" tabindex="0" aria-selected="true" class="tabs__item tabItem_LNqP tabs__item--active">C#</li></ul><div class="margin-top--md"><div role="tabpanel" class="tabItem_Ymn6"><div class="language-csharp codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#d6deeb;--prism-background-color:#011627"><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-csharp codeBlock_bY9V thin-scrollbar" style="color:#d6deeb;background-color:#011627"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:#d6deeb"><span class="token plain">   </span><span class="token comment" style="color:rgb(99, 119, 119);font-style:italic">// Before</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">   </span><span class="token keyword" style="color:rgb(127, 219, 202)">if</span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token plain">users</span><span class="token punctuation" style="color:rgb(199, 146, 234)">.</span><span class="token plain">Count </span><span class="token operator" style="color:rgb(127, 219, 202)">&gt;</span><span class="token plain"> </span><span class="token number" style="color:rgb(247, 140, 108)">42</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(199, 146, 234)">{</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">       </span><span class="token comment" style="color:rgb(99, 119, 119);font-style:italic">// Do something</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">   </span><span class="token punctuation" style="color:rgb(199, 146, 234)">}</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">   </span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">   </span><span class="token comment" style="color:rgb(99, 119, 119);font-style:italic">// After</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">   </span><span class="token keyword" style="color:rgb(127, 219, 202)">const</span><span class="token plain"> </span><span class="token class-name keyword" style="color:rgb(127, 219, 202)">int</span><span class="token plain"> MAXUSERS </span><span class="token operator" style="color:rgb(127, 219, 202)">=</span><span class="token plain"> </span><span class="token number" style="color:rgb(247, 140, 108)">42</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">   </span><span class="token keyword" style="color:rgb(127, 219, 202)">if</span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token plain">users</span><span class="token punctuation" style="color:rgb(199, 146, 234)">.</span><span class="token plain">Count </span><span class="token operator" style="color:rgb(127, 219, 202)">&gt;</span><span class="token plain"> MAXUSERS</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(199, 146, 234)">{</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">       </span><span class="token comment" style="color:rgb(99, 119, 119);font-style:italic">// Do something</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">   </span><span class="token punctuation" style="color:rgb(199, 146, 234)">}</span><br></span></code></pre></div></div></div></div></div>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="tip-4-inline-method">Tip-4: Inline Method<a href="https://chaibiscuit.rajivy.me/blog/10-refactoring-tips#tip-4-inline-method" class="hash-link" aria-label="Direct link to Tip-4: Inline Method" title="Direct link to Tip-4: Inline Method">​</a></h3>
<p>Sometimes, instead of extracting, you may need the opposite. For instance, if you have a method that returns a constant value, you should consider inlining it. It can make your code easier to follow by reducing unnecessary indirection.</p>
<div class="tabs-container tabList__CuJ"><ul role="tablist" aria-orientation="horizontal" class="tabs"><li role="tab" tabindex="0" aria-selected="true" class="tabs__item tabItem_LNqP tabs__item--active">C#</li></ul><div class="margin-top--md"><div role="tabpanel" class="tabItem_Ymn6"><div class="language-csharp codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#d6deeb;--prism-background-color:#011627"><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-csharp codeBlock_bY9V thin-scrollbar" style="color:#d6deeb;background-color:#011627"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:#d6deeb"><span class="token plain">    </span><span class="token comment" style="color:rgb(99, 119, 119);font-style:italic">// Before</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">    </span><span class="token keyword" style="color:rgb(127, 219, 202)">public</span><span class="token plain"> </span><span class="token return-type class-name keyword" style="color:rgb(127, 219, 202)">double</span><span class="token plain"> </span><span class="token function" style="color:rgb(130, 170, 255)">GetPiValue</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(199, 146, 234)">{</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">        </span><span class="token keyword" style="color:rgb(127, 219, 202)">return</span><span class="token plain"> </span><span class="token number" style="color:rgb(247, 140, 108)">3.14</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">    </span><span class="token punctuation" style="color:rgb(199, 146, 234)">}</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">    </span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">    </span><span class="token class-name keyword" style="color:rgb(127, 219, 202)">double</span><span class="token plain"> area </span><span class="token operator" style="color:rgb(127, 219, 202)">=</span><span class="token plain"> </span><span class="token function" style="color:rgb(130, 170, 255)">GetPiValue</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"> </span><span class="token operator" style="color:rgb(127, 219, 202)">*</span><span class="token plain"> radius </span><span class="token operator" style="color:rgb(127, 219, 202)">*</span><span class="token plain"> radius</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">    </span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">    </span><span class="token comment" style="color:rgb(99, 119, 119);font-style:italic">// After</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">    </span><span class="token class-name keyword" style="color:rgb(127, 219, 202)">double</span><span class="token plain"> area </span><span class="token operator" style="color:rgb(127, 219, 202)">=</span><span class="token plain"> </span><span class="token number" style="color:rgb(247, 140, 108)">3.14</span><span class="token plain"> </span><span class="token operator" style="color:rgb(127, 219, 202)">*</span><span class="token plain"> radius </span><span class="token operator" style="color:rgb(127, 219, 202)">*</span><span class="token plain"> radius</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span><br></span></code></pre></div></div></div></div></div>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="tip-5-simplify-conditionals">Tip-5: Simplify Conditionals<a href="https://chaibiscuit.rajivy.me/blog/10-refactoring-tips#tip-5-simplify-conditionals" class="hash-link" aria-label="Direct link to Tip-5: Simplify Conditionals" title="Direct link to Tip-5: Simplify Conditionals">​</a></h3>
<p>Nested if-else statements can quickly get out of hand. Use guard clauses to handle simple cases upfront and reduce the nesting. This will make your logic cleaner and more approachable.</p>
<div class="tabs-container tabList__CuJ"><ul role="tablist" aria-orientation="horizontal" class="tabs"><li role="tab" tabindex="0" aria-selected="true" class="tabs__item tabItem_LNqP tabs__item--active">C#</li></ul><div class="margin-top--md"><div role="tabpanel" class="tabItem_Ymn6"><div class="language-csharp codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#d6deeb;--prism-background-color:#011627"><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-csharp codeBlock_bY9V thin-scrollbar" style="color:#d6deeb;background-color:#011627"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:#d6deeb"><span class="token plain">   </span><span class="token comment" style="color:rgb(99, 119, 119);font-style:italic">// Before</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">   </span><span class="token keyword" style="color:rgb(127, 219, 202)">if</span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token plain">condition</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(199, 146, 234)">{</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">       </span><span class="token keyword" style="color:rgb(127, 219, 202)">if</span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token plain">anotherCondition</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(199, 146, 234)">{</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">           </span><span class="token comment" style="color:rgb(99, 119, 119);font-style:italic">// Do something</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">       </span><span class="token punctuation" style="color:rgb(199, 146, 234)">}</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">   </span><span class="token punctuation" style="color:rgb(199, 146, 234)">}</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain" style="display:inline-block"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">   </span><span class="token comment" style="color:rgb(99, 119, 119);font-style:italic">// After</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">   </span><span class="token keyword" style="color:rgb(127, 219, 202)">if</span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token operator" style="color:rgb(127, 219, 202)">!</span><span class="token plain">condition</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">return</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">   </span><span class="token keyword" style="color:rgb(127, 219, 202)">if</span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token operator" style="color:rgb(127, 219, 202)">!</span><span class="token plain">anotherCondition</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">return</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">   </span><span class="token comment" style="color:rgb(99, 119, 119);font-style:italic">// Do something</span><br></span></code></pre></div></div></div></div></div>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="tip-6-decompose-conditional">Tip-6: Decompose Conditional<a href="https://chaibiscuit.rajivy.me/blog/10-refactoring-tips#tip-6-decompose-conditional" class="hash-link" aria-label="Direct link to Tip-6: Decompose Conditional" title="Direct link to Tip-6: Decompose Conditional">​</a></h3>
<p>Break down complex conditional logic into smaller methods. This not only enhances the readability of your code but also simplifies testing.</p>
<div class="tabs-container tabList__CuJ"><ul role="tablist" aria-orientation="horizontal" class="tabs"><li role="tab" tabindex="0" aria-selected="true" class="tabs__item tabItem_LNqP tabs__item--active">C#</li></ul><div class="margin-top--md"><div role="tabpanel" class="tabItem_Ymn6"><div class="language-csharp codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#d6deeb;--prism-background-color:#011627"><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-csharp codeBlock_bY9V thin-scrollbar" style="color:#d6deeb;background-color:#011627"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:#d6deeb"><span class="token plain">   </span><span class="token comment" style="color:rgb(99, 119, 119);font-style:italic">// Before</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">   </span><span class="token keyword" style="color:rgb(127, 219, 202)">if</span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token plain">isHoliday </span><span class="token operator" style="color:rgb(127, 219, 202)">&amp;&amp;</span><span class="token plain"> isWeekend </span><span class="token operator" style="color:rgb(127, 219, 202)">&amp;&amp;</span><span class="token plain"> isSunny</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(199, 146, 234)">{</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">       </span><span class="token comment" style="color:rgb(99, 119, 119);font-style:italic">// Go for a picnic</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">   </span><span class="token punctuation" style="color:rgb(199, 146, 234)">}</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">   </span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">   </span><span class="token comment" style="color:rgb(99, 119, 119);font-style:italic">// After</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">   </span><span class="token keyword" style="color:rgb(127, 219, 202)">if</span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token function" style="color:rgb(130, 170, 255)">ShouldGoForPicnic</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(199, 146, 234)">{</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">       </span><span class="token comment" style="color:rgb(99, 119, 119);font-style:italic">// Go for a picnic</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">   </span><span class="token punctuation" style="color:rgb(199, 146, 234)">}</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">   </span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">   </span><span class="token keyword" style="color:rgb(127, 219, 202)">private</span><span class="token plain"> </span><span class="token return-type class-name keyword" style="color:rgb(127, 219, 202)">bool</span><span class="token plain"> </span><span class="token function" style="color:rgb(130, 170, 255)">ShouldGoForPicnic</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(199, 146, 234)">{</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">       </span><span class="token keyword" style="color:rgb(127, 219, 202)">return</span><span class="token plain"> isHoliday </span><span class="token operator" style="color:rgb(127, 219, 202)">&amp;&amp;</span><span class="token plain"> isWeekend </span><span class="token operator" style="color:rgb(127, 219, 202)">&amp;&amp;</span><span class="token plain"> isSunny</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">   </span><span class="token punctuation" style="color:rgb(199, 146, 234)">}</span><br></span></code></pre></div></div></div></div></div>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="tip-7-replace-temp-with-query">Tip-7: Replace Temp with Query<a href="https://chaibiscuit.rajivy.me/blog/10-refactoring-tips#tip-7-replace-temp-with-query" class="hash-link" aria-label="Direct link to Tip-7: Replace Temp with Query" title="Direct link to Tip-7: Replace Temp with Query">​</a></h3>
<p>If you’re using a temporary variable to store a value that can be derived through a method, get rid of the temp and call the method directly. This reduces the risk of errors and makes your code more concise.</p>
<div class="tabs-container tabList__CuJ"><ul role="tablist" aria-orientation="horizontal" class="tabs"><li role="tab" tabindex="0" aria-selected="true" class="tabs__item tabItem_LNqP tabs__item--active">C#</li></ul><div class="margin-top--md"><div role="tabpanel" class="tabItem_Ymn6"><div class="language-csharp codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#d6deeb;--prism-background-color:#011627"><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-csharp codeBlock_bY9V thin-scrollbar" style="color:#d6deeb;background-color:#011627"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:#d6deeb"><span class="token plain">   </span><span class="token comment" style="color:rgb(99, 119, 119);font-style:italic">// Before</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">   </span><span class="token class-name keyword" style="color:rgb(127, 219, 202)">double</span><span class="token plain"> basePrice </span><span class="token operator" style="color:rgb(127, 219, 202)">=</span><span class="token plain"> </span><span class="token function" style="color:rgb(130, 170, 255)">GetBasePrice</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">   </span><span class="token keyword" style="color:rgb(127, 219, 202)">if</span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token plain">basePrice </span><span class="token operator" style="color:rgb(127, 219, 202)">&gt;</span><span class="token plain"> </span><span class="token number" style="color:rgb(247, 140, 108)">100</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(199, 146, 234)">{</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">       </span><span class="token comment" style="color:rgb(99, 119, 119);font-style:italic">// Apply discount</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">   </span><span class="token punctuation" style="color:rgb(199, 146, 234)">}</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain" style="display:inline-block"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">   </span><span class="token comment" style="color:rgb(99, 119, 119);font-style:italic">// After</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">   </span><span class="token keyword" style="color:rgb(127, 219, 202)">if</span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token function" style="color:rgb(130, 170, 255)">GetBasePrice</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"> </span><span class="token operator" style="color:rgb(127, 219, 202)">&gt;</span><span class="token plain"> </span><span class="token number" style="color:rgb(247, 140, 108)">100</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(199, 146, 234)">{</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">       </span><span class="token comment" style="color:rgb(99, 119, 119);font-style:italic">// Apply discount</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">   </span><span class="token punctuation" style="color:rgb(199, 146, 234)">}</span><br></span></code></pre></div></div></div></div></div>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="tip-8-introduce-parameter-object">Tip-8: Introduce Parameter Object<a href="https://chaibiscuit.rajivy.me/blog/10-refactoring-tips#tip-8-introduce-parameter-object" class="hash-link" aria-label="Direct link to Tip-8: Introduce Parameter Object" title="Direct link to Tip-8: Introduce Parameter Object">​</a></h3>
<p>If your method has too many parameters, wrap them in a single object. This makes your method calls cleaner and your code easier to read.</p>
<div class="tabs-container tabList__CuJ"><ul role="tablist" aria-orientation="horizontal" class="tabs"><li role="tab" tabindex="0" aria-selected="true" class="tabs__item tabItem_LNqP tabs__item--active">C#</li></ul><div class="margin-top--md"><div role="tabpanel" class="tabItem_Ymn6"><div class="language-csharp codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#d6deeb;--prism-background-color:#011627"><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-csharp codeBlock_bY9V thin-scrollbar" style="color:#d6deeb;background-color:#011627"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:#d6deeb"><span class="token plain">   </span><span class="token comment" style="color:rgb(99, 119, 119);font-style:italic">// Before</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">   </span><span class="token keyword" style="color:rgb(127, 219, 202)">public</span><span class="token plain"> </span><span class="token return-type class-name keyword" style="color:rgb(127, 219, 202)">void</span><span class="token plain"> </span><span class="token function" style="color:rgb(130, 170, 255)">CreateOrder</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token class-name keyword" style="color:rgb(127, 219, 202)">string</span><span class="token plain"> productId</span><span class="token punctuation" style="color:rgb(199, 146, 234)">,</span><span class="token plain"> </span><span class="token class-name keyword" style="color:rgb(127, 219, 202)">int</span><span class="token plain"> quantity</span><span class="token punctuation" style="color:rgb(199, 146, 234)">,</span><span class="token plain"> </span><span class="token class-name keyword" style="color:rgb(127, 219, 202)">double</span><span class="token plain"> price</span><span class="token punctuation" style="color:rgb(199, 146, 234)">,</span><span class="token plain"> </span><span class="token class-name keyword" style="color:rgb(127, 219, 202)">string</span><span class="token plain"> customerName</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(199, 146, 234)">{</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">       </span><span class="token comment" style="color:rgb(99, 119, 119);font-style:italic">// Implementation</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">   </span><span class="token punctuation" style="color:rgb(199, 146, 234)">}</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain" style="display:inline-block"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">   </span><span class="token comment" style="color:rgb(99, 119, 119);font-style:italic">// After</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">   </span><span class="token keyword" style="color:rgb(127, 219, 202)">public</span><span class="token plain"> </span><span class="token return-type class-name keyword" style="color:rgb(127, 219, 202)">void</span><span class="token plain"> </span><span class="token function" style="color:rgb(130, 170, 255)">CreateOrder</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token class-name" style="color:rgb(255, 203, 139)">OrderDetails</span><span class="token plain"> orderDetails</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(199, 146, 234)">{</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">       </span><span class="token comment" style="color:rgb(99, 119, 119);font-style:italic">// Implementation</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">   </span><span class="token punctuation" style="color:rgb(199, 146, 234)">}</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain" style="display:inline-block"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">   </span><span class="token keyword" style="color:rgb(127, 219, 202)">public</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">class</span><span class="token plain"> </span><span class="token class-name" style="color:rgb(255, 203, 139)">OrderDetails</span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(199, 146, 234)">{</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">       </span><span class="token keyword" style="color:rgb(127, 219, 202)">public</span><span class="token plain"> </span><span class="token return-type class-name keyword" style="color:rgb(127, 219, 202)">string</span><span class="token plain"> ProductId </span><span class="token punctuation" style="color:rgb(199, 146, 234)">{</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">get</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">set</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(199, 146, 234)">}</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">       </span><span class="token keyword" style="color:rgb(127, 219, 202)">public</span><span class="token plain"> </span><span class="token return-type class-name keyword" style="color:rgb(127, 219, 202)">int</span><span class="token plain"> Quantity </span><span class="token punctuation" style="color:rgb(199, 146, 234)">{</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">get</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">set</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(199, 146, 234)">}</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">       </span><span class="token keyword" style="color:rgb(127, 219, 202)">public</span><span class="token plain"> </span><span class="token return-type class-name keyword" style="color:rgb(127, 219, 202)">double</span><span class="token plain"> Price </span><span class="token punctuation" style="color:rgb(199, 146, 234)">{</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">get</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">set</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(199, 146, 234)">}</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">       </span><span class="token keyword" style="color:rgb(127, 219, 202)">public</span><span class="token plain"> </span><span class="token return-type class-name keyword" style="color:rgb(127, 219, 202)">string</span><span class="token plain"> CustomerName </span><span class="token punctuation" style="color:rgb(199, 146, 234)">{</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">get</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">set</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(199, 146, 234)">}</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">   </span><span class="token punctuation" style="color:rgb(199, 146, 234)">}</span><br></span></code></pre></div></div></div></div></div>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="tip-9-encapsulate-collection">Tip-9: Encapsulate Collection<a href="https://chaibiscuit.rajivy.me/blog/10-refactoring-tips#tip-9-encapsulate-collection" class="hash-link" aria-label="Direct link to Tip-9: Encapsulate Collection" title="Direct link to Tip-9: Encapsulate Collection">​</a></h3>
<p>If you're working with a collection, incorporate methods to manipulate the collection within the class. This maintains data integrity and enhances the usability of your class.</p>
<div class="tabs-container tabList__CuJ"><ul role="tablist" aria-orientation="horizontal" class="tabs"><li role="tab" tabindex="0" aria-selected="true" class="tabs__item tabItem_LNqP tabs__item--active">C#</li></ul><div class="margin-top--md"><div role="tabpanel" class="tabItem_Ymn6"><div class="language-csharp codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#d6deeb;--prism-background-color:#011627"><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-csharp codeBlock_bY9V thin-scrollbar" style="color:#d6deeb;background-color:#011627"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:#d6deeb"><span class="token plain">  </span><span class="token comment" style="color:rgb(99, 119, 119);font-style:italic">// Before</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">  </span><span class="token keyword" style="color:rgb(127, 219, 202)">public</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">class</span><span class="token plain"> </span><span class="token class-name" style="color:rgb(255, 203, 139)">Order</span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(199, 146, 234)">{</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">      </span><span class="token keyword" style="color:rgb(127, 219, 202)">public</span><span class="token plain"> </span><span class="token class-name" style="color:rgb(255, 203, 139)">List</span><span class="token class-name punctuation" style="color:rgb(199, 146, 234)">&lt;</span><span class="token class-name" style="color:rgb(255, 203, 139)">Item</span><span class="token class-name punctuation" style="color:rgb(199, 146, 234)">&gt;</span><span class="token plain"> Items</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain" style="display:inline-block"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">      </span><span class="token keyword" style="color:rgb(127, 219, 202)">public</span><span class="token plain"> </span><span class="token return-type class-name keyword" style="color:rgb(127, 219, 202)">void</span><span class="token plain"> </span><span class="token function" style="color:rgb(130, 170, 255)">AddItem</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token class-name" style="color:rgb(255, 203, 139)">Item</span><span class="token plain"> item</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(199, 146, 234)">{</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">          Items</span><span class="token punctuation" style="color:rgb(199, 146, 234)">.</span><span class="token function" style="color:rgb(130, 170, 255)">Add</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token plain">item</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">      </span><span class="token punctuation" style="color:rgb(199, 146, 234)">}</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">  </span><span class="token punctuation" style="color:rgb(199, 146, 234)">}</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain" style="display:inline-block"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">  </span><span class="token comment" style="color:rgb(99, 119, 119);font-style:italic">// After</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">  </span><span class="token keyword" style="color:rgb(127, 219, 202)">public</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">class</span><span class="token plain"> </span><span class="token class-name" style="color:rgb(255, 203, 139)">Order</span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(199, 146, 234)">{</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">      </span><span class="token keyword" style="color:rgb(127, 219, 202)">private</span><span class="token plain"> </span><span class="token class-name" style="color:rgb(255, 203, 139)">List</span><span class="token class-name punctuation" style="color:rgb(199, 146, 234)">&lt;</span><span class="token class-name" style="color:rgb(255, 203, 139)">Item</span><span class="token class-name punctuation" style="color:rgb(199, 146, 234)">&gt;</span><span class="token plain"> items </span><span class="token operator" style="color:rgb(127, 219, 202)">=</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">new</span><span class="token plain"> </span><span class="token constructor-invocation class-name" style="color:rgb(255, 203, 139)">List</span><span class="token constructor-invocation class-name punctuation" style="color:rgb(199, 146, 234)">&lt;</span><span class="token constructor-invocation class-name" style="color:rgb(255, 203, 139)">Item</span><span class="token constructor-invocation class-name punctuation" style="color:rgb(199, 146, 234)">&gt;</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain" style="display:inline-block"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">      </span><span class="token keyword" style="color:rgb(127, 219, 202)">public</span><span class="token plain"> </span><span class="token return-type class-name keyword" style="color:rgb(127, 219, 202)">void</span><span class="token plain"> </span><span class="token function" style="color:rgb(130, 170, 255)">AddItem</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token class-name" style="color:rgb(255, 203, 139)">Item</span><span class="token plain"> item</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(199, 146, 234)">{</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">          items</span><span class="token punctuation" style="color:rgb(199, 146, 234)">.</span><span class="token function" style="color:rgb(130, 170, 255)">Add</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token plain">item</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">      </span><span class="token punctuation" style="color:rgb(199, 146, 234)">}</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain" style="display:inline-block"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">      </span><span class="token keyword" style="color:rgb(127, 219, 202)">public</span><span class="token plain"> </span><span class="token return-type class-name" style="color:rgb(255, 203, 139)">IReadOnlyList</span><span class="token return-type class-name punctuation" style="color:rgb(199, 146, 234)">&lt;</span><span class="token return-type class-name" style="color:rgb(255, 203, 139)">Item</span><span class="token return-type class-name punctuation" style="color:rgb(199, 146, 234)">&gt;</span><span class="token plain"> Items </span><span class="token operator" style="color:rgb(127, 219, 202)">=&gt;</span><span class="token plain"> items</span><span class="token punctuation" style="color:rgb(199, 146, 234)">.</span><span class="token function" style="color:rgb(130, 170, 255)">AsReadOnly</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">  </span><span class="token punctuation" style="color:rgb(199, 146, 234)">}</span><br></span></code></pre></div></div></div></div></div>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="tip-10-remove-dead-code">Tip-10: Remove Dead Code<a href="https://chaibiscuit.rajivy.me/blog/10-refactoring-tips#tip-10-remove-dead-code" class="hash-link" aria-label="Direct link to Tip-10: Remove Dead Code" title="Direct link to Tip-10: Remove Dead Code">​</a></h3>
<p>Make sure to delete any code that you're not using. Unused code is unnecessary clutter that can confuse anyone trying to understand your codebase.</p>
<div class="tabs-container tabList__CuJ"><ul role="tablist" aria-orientation="horizontal" class="tabs"><li role="tab" tabindex="0" aria-selected="true" class="tabs__item tabItem_LNqP tabs__item--active">C#</li></ul><div class="margin-top--md"><div role="tabpanel" class="tabItem_Ymn6"><div class="language-csharp codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#d6deeb;--prism-background-color:#011627"><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-csharp codeBlock_bY9V thin-scrollbar" style="color:#d6deeb;background-color:#011627"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:#d6deeb"><span class="token plain">   </span><span class="token comment" style="color:rgb(99, 119, 119);font-style:italic">// Before</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">   </span><span class="token keyword" style="color:rgb(127, 219, 202)">public</span><span class="token plain"> </span><span class="token return-type class-name keyword" style="color:rgb(127, 219, 202)">void</span><span class="token plain"> </span><span class="token function" style="color:rgb(130, 170, 255)">ProcessOrder</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(199, 146, 234)">{</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">       </span><span class="token comment" style="color:rgb(99, 119, 119);font-style:italic">// Some processing</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">   </span><span class="token punctuation" style="color:rgb(199, 146, 234)">}</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain" style="display:inline-block"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">   </span><span class="token keyword" style="color:rgb(127, 219, 202)">private</span><span class="token plain"> </span><span class="token return-type class-name keyword" style="color:rgb(127, 219, 202)">void</span><span class="token plain"> </span><span class="token function" style="color:rgb(130, 170, 255)">UnusedMethod</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(199, 146, 234)">{</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">       </span><span class="token comment" style="color:rgb(99, 119, 119);font-style:italic">// This method is never called</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">   </span><span class="token punctuation" style="color:rgb(199, 146, 234)">}</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain" style="display:inline-block"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">   </span><span class="token comment" style="color:rgb(99, 119, 119);font-style:italic">// After</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">   </span><span class="token keyword" style="color:rgb(127, 219, 202)">public</span><span class="token plain"> </span><span class="token return-type class-name keyword" style="color:rgb(127, 219, 202)">void</span><span class="token plain"> </span><span class="token function" style="color:rgb(130, 170, 255)">ProcessOrder</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(199, 146, 234)">{</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">       </span><span class="token comment" style="color:rgb(99, 119, 119);font-style:italic">// Some processing</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">   </span><span class="token punctuation" style="color:rgb(199, 146, 234)">}</span><br></span></code></pre></div></div></div></div></div>
<p><strong>Bonus: Tip-11 : Adopt the Single Responsibility Principle</strong></p>
<p>Each class or function should have one reason to change, and only one reason. This means every class and function should do just one thing.</p>
<div class="tabs-container tabList__CuJ"><ul role="tablist" aria-orientation="horizontal" class="tabs"><li role="tab" tabindex="0" aria-selected="true" class="tabs__item tabItem_LNqP tabs__item--active">C#</li></ul><div class="margin-top--md"><div role="tabpanel" class="tabItem_Ymn6"><div class="language-csharp codeBlockContainer_Ckt0 theme-code-block" style="--prism-color:#d6deeb;--prism-background-color:#011627"><div class="codeBlockContent_QJqH"><pre tabindex="0" class="prism-code language-csharp codeBlock_bY9V thin-scrollbar" style="color:#d6deeb;background-color:#011627"><code class="codeBlockLines_e6Vv"><span class="token-line" style="color:#d6deeb"><span class="token plain">   </span><span class="token keyword" style="color:rgb(127, 219, 202)">public</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">class</span><span class="token plain"> </span><span class="token class-name" style="color:rgb(255, 203, 139)">User</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">   </span><span class="token punctuation" style="color:rgb(199, 146, 234)">{</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">       </span><span class="token keyword" style="color:rgb(127, 219, 202)">public</span><span class="token plain"> </span><span class="token return-type class-name keyword" style="color:rgb(127, 219, 202)">string</span><span class="token plain"> Name </span><span class="token punctuation" style="color:rgb(199, 146, 234)">{</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">get</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">set</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(199, 146, 234)">}</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">       </span><span class="token keyword" style="color:rgb(127, 219, 202)">public</span><span class="token plain"> </span><span class="token return-type class-name keyword" style="color:rgb(127, 219, 202)">string</span><span class="token plain"> Email </span><span class="token punctuation" style="color:rgb(199, 146, 234)">{</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">get</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">set</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(199, 146, 234)">}</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">   </span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">       </span><span class="token keyword" style="color:rgb(127, 219, 202)">public</span><span class="token plain"> </span><span class="token return-type class-name keyword" style="color:rgb(127, 219, 202)">void</span><span class="token plain"> </span><span class="token function" style="color:rgb(130, 170, 255)">SaveToDatabase</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">       </span><span class="token punctuation" style="color:rgb(199, 146, 234)">{</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">           </span><span class="token comment" style="color:rgb(99, 119, 119);font-style:italic">// Code to save user to database</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">       </span><span class="token punctuation" style="color:rgb(199, 146, 234)">}</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">   </span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">       </span><span class="token keyword" style="color:rgb(127, 219, 202)">public</span><span class="token plain"> </span><span class="token return-type class-name keyword" style="color:rgb(127, 219, 202)">void</span><span class="token plain"> </span><span class="token function" style="color:rgb(130, 170, 255)">SendEmail</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">       </span><span class="token punctuation" style="color:rgb(199, 146, 234)">{</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">           </span><span class="token comment" style="color:rgb(99, 119, 119);font-style:italic">// Code to send email to user</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">       </span><span class="token punctuation" style="color:rgb(199, 146, 234)">}</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">   </span><span class="token punctuation" style="color:rgb(199, 146, 234)">}</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">   </span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">   </span><span class="token comment" style="color:rgb(99, 119, 119);font-style:italic">// Refactored</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">   </span><span class="token keyword" style="color:rgb(127, 219, 202)">public</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">class</span><span class="token plain"> </span><span class="token class-name" style="color:rgb(255, 203, 139)">User</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">   </span><span class="token punctuation" style="color:rgb(199, 146, 234)">{</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">       </span><span class="token keyword" style="color:rgb(127, 219, 202)">public</span><span class="token plain"> </span><span class="token return-type class-name keyword" style="color:rgb(127, 219, 202)">string</span><span class="token plain"> Name </span><span class="token punctuation" style="color:rgb(199, 146, 234)">{</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">get</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">set</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(199, 146, 234)">}</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">       </span><span class="token keyword" style="color:rgb(127, 219, 202)">public</span><span class="token plain"> </span><span class="token return-type class-name keyword" style="color:rgb(127, 219, 202)">string</span><span class="token plain"> Email </span><span class="token punctuation" style="color:rgb(199, 146, 234)">{</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">get</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">set</span><span class="token punctuation" style="color:rgb(199, 146, 234)">;</span><span class="token plain"> </span><span class="token punctuation" style="color:rgb(199, 146, 234)">}</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">   </span><span class="token punctuation" style="color:rgb(199, 146, 234)">}</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">   </span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">   </span><span class="token keyword" style="color:rgb(127, 219, 202)">public</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">class</span><span class="token plain"> </span><span class="token class-name" style="color:rgb(255, 203, 139)">UserRepository</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">   </span><span class="token punctuation" style="color:rgb(199, 146, 234)">{</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">       </span><span class="token keyword" style="color:rgb(127, 219, 202)">public</span><span class="token plain"> </span><span class="token return-type class-name keyword" style="color:rgb(127, 219, 202)">void</span><span class="token plain"> </span><span class="token function" style="color:rgb(130, 170, 255)">Save</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token class-name" style="color:rgb(255, 203, 139)">User</span><span class="token plain"> user</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">       </span><span class="token punctuation" style="color:rgb(199, 146, 234)">{</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">           </span><span class="token comment" style="color:rgb(99, 119, 119);font-style:italic">// Code to save user to database</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">       </span><span class="token punctuation" style="color:rgb(199, 146, 234)">}</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">   </span><span class="token punctuation" style="color:rgb(199, 146, 234)">}</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">   </span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">   </span><span class="token keyword" style="color:rgb(127, 219, 202)">public</span><span class="token plain"> </span><span class="token keyword" style="color:rgb(127, 219, 202)">class</span><span class="token plain"> </span><span class="token class-name" style="color:rgb(255, 203, 139)">EmailService</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">   </span><span class="token punctuation" style="color:rgb(199, 146, 234)">{</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">       </span><span class="token keyword" style="color:rgb(127, 219, 202)">public</span><span class="token plain"> </span><span class="token return-type class-name keyword" style="color:rgb(127, 219, 202)">void</span><span class="token plain"> </span><span class="token function" style="color:rgb(130, 170, 255)">SendEmail</span><span class="token punctuation" style="color:rgb(199, 146, 234)">(</span><span class="token class-name" style="color:rgb(255, 203, 139)">User</span><span class="token plain"> user</span><span class="token punctuation" style="color:rgb(199, 146, 234)">)</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">       </span><span class="token punctuation" style="color:rgb(199, 146, 234)">{</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">           </span><span class="token comment" style="color:rgb(99, 119, 119);font-style:italic">// Code to send email to user</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">       </span><span class="token punctuation" style="color:rgb(199, 146, 234)">}</span><span class="token plain"></span><br></span><span class="token-line" style="color:#d6deeb"><span class="token plain">   </span><span class="token punctuation" style="color:rgb(199, 146, 234)">}</span><span class="token plain">    </span><br></span></code></pre></div></div></div></div></div>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="conclusion">Conclusion<a href="https://chaibiscuit.rajivy.me/blog/10-refactoring-tips#conclusion" class="hash-link" aria-label="Direct link to Conclusion" title="Direct link to Conclusion">​</a></h3>
<p>So, next time you’re coding, take a moment to consider how you can refactor and make your code a little cleaner. Trust me, your future self and your team will thank you!</p>
<p>You know the drill: chai ☕ and biscuits 🍪 for focus, and clean code for brilliance 💻.</p>
<p><strong>🎉Happy coding!!🎉</strong></p>
<div class="theme-admonition theme-admonition-info admonition_xJq3 alert alert--info"><div class="admonitionHeading_Gvgb"><span class="admonitionIcon_Rf37"><svg viewBox="0 0 14 16"><path fill-rule="evenodd" d="M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"></path></svg></span>☕ Fuel the Journey!</div><div class="admonitionContent_BuS1"><p>Every <strong><a href="https://buymeacoffee.com/rajivy" target="_blank" rel="noopener noreferrer">coffee ☕</a> (or chai 🍵)</strong> you buy fuels another idea, another post, and another smile. Thank you for supporting my work!</p></div></div>]]></content:encoded>
            <category>clean-code</category>
            <category>learning</category>
            <category>refactoring</category>
        </item>
        <item>
            <title><![CDATA[Beat Procrastination and ace Self-Learning!]]></title>
            <link>https://chaibiscuit.rajivy.me/blog/self-taught-coder</link>
            <guid>https://chaibiscuit.rajivy.me/blog/self-taught-coder</guid>
            <pubDate>Sun, 16 Jun 2024 00:00:00 GMT</pubDate>
            <description><![CDATA[✨ Overcome Self-Learning Struggles with These Tips! ✨]]></description>
            <content:encoded><![CDATA[<p>✨ <strong>Overcome Self-Learning Struggles with These Tips!</strong> ✨</p>
<p>Hey there! Struggling as a self-taught programmer? You’re not alone. Let's discuss the common challenges of being a self-taught coder and how to overcome them today.</p>
<p>By the end of this post, as a self-taught programmer, I will share my tips for navigating the self-learning maze, staying motivated, and connected. Ready to level up your learning game? Let’s dive in!</p>
<p><img decoding="async" loading="lazy" alt="thumbnail post" src="https://chaibiscuit.rajivy.me/assets/images/build-small-feb540a2d1e40ef8b2305185396169d9.jpg" width="827" height="412" class="img_ev3q"></p>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="tldr---version">TL;DR - version<a href="https://chaibiscuit.rajivy.me/blog/self-taught-coder#tldr---version" class="hash-link" aria-label="Direct link to TL;DR - version" title="Direct link to TL;DR - version">​</a></h3>
<p><img decoding="async" loading="lazy" alt="challenges" src="https://chaibiscuit.rajivy.me/assets/images/challenges-b171500bedf2fd726f92884daffd0d39.gif" width="1050" height="1050" class="img_ev3q"></p>
<p><img decoding="async" loading="lazy" alt="6_tips" src="https://chaibiscuit.rajivy.me/assets/images/6_tips-3b505c1bff0a551c3878cab5c2bafc29.jpg" width="1200" height="1018" class="img_ev3q"></p>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="challenges">Challenges<a href="https://chaibiscuit.rajivy.me/blog/self-taught-coder#challenges" class="hash-link" aria-label="Direct link to Challenges" title="Direct link to Challenges">​</a></h3>
<p>First up, the challenges of self-learning:</p>
<ol>
<li><strong>Information Overload</strong>: There is an overwhelming number of books, tutorials, and courses available, making it difficult to determine where to begin and whom to trust.</li>
<li><strong>Lack of Direction</strong>: Without a well-defined curriculum, it's easy to become lost and fall into "tutorial hell," jumping from one tutorial to another without truly mastering anything.</li>
<li><strong>Keeping Motivated</strong>: Staying motivated without deadlines and accountability can be challenging, as procrastination often becomes the biggest hurdle.</li>
<li><strong>Course Fatigue</strong>: Platforms such as Udemy offer extensive courses that may seem valuable, but many individuals fail to complete them, moving from one course to another without truly learning.</li>
<li><strong>Missing Feedback</strong>: Learning alone means missing out on valuable feedback and code reviews that could help you improve.</li>
<li><strong>Feeling Alone</strong>: Self-learning can sometimes feel lonely because you miss out on the collaborative environment that traditional education provides.</li>
</ol>
<p><img decoding="async" loading="lazy" alt="challenges" src="https://chaibiscuit.rajivy.me/assets/images/challenges-b171500bedf2fd726f92884daffd0d39.gif" width="1050" height="1050" class="img_ev3q"></p>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="tackle-these-challenges">Tackle these challenges<a href="https://chaibiscuit.rajivy.me/blog/self-taught-coder#tackle-these-challenges" class="hash-link" aria-label="Direct link to Tackle these challenges" title="Direct link to Tackle these challenges">​</a></h3>
<p>Now, let’s talk about how to tackle these challenges:</p>
<ol>
<li><strong>Follow a Roadmap</strong>: Make sure to use structured roadmaps to guide your learning.</li>
<li><strong>Set Achievable Goals</strong>: Split up your learning into smaller parts with clear goals and deadlines. This will help you stay on track and keep your motivation up.</li>
<li><strong>Join Learning Communities</strong>: You can find awesome programming communities on platforms like Stack Overflow. If you're taking any courses, make sure to join their forums and get in on the action.</li>
<li><strong>Get Feedback</strong>: Don't forget to share your code on places like Stack Overflow or GitHub and ask for feedback. Get involved in open-source projects to learn from experienced developers.</li>
<li><strong>Work on Real Projects</strong>: Don't forget to put your learning into practice by working on real projects. This will help you really understand what you've learned and give you something cool to show off. Share your projects on GitHub when you're ready!</li>
<li><strong>Stay Consistent</strong>: Just keep at it! Code a little every day to build up momentum.</li>
<li><strong>Use Multiple Resources</strong>: Don’t rely on a single source of information. Utilize books, online courses, tutorials, forums, and videos to gain different perspectives and explanations</li>
<li><strong>Create a Study Schedule</strong>: Plan your study schedule and stick to it to maintain discipline and dedicate time to learning.</li>
<li><strong>Take Breaks</strong>: Don't overwork yourself. Take regular breaks to rest and recharge, which can enhance productivity and creativity.</li>
<li><strong>Teach Others</strong>: Explaining concepts to others is a great way to strengthen your own understanding. Consider writing blog posts, creating tutorial videos, or engaging in online forums.</li>
<li><strong>Experiment and Play</strong>: Don’t hesitate to experiment by building small projects or modifying existing ones, as this hands-on approach deepens understanding.</li>
<li><strong>Learn Debugging</strong>: Get comfortable with debugging tools and techniques. Learning how to troubleshoot your code efficiently can save a lot of time and frustration.</li>
<li><strong>Stay Updated</strong>: Technology evolves rapidly. Stay updated on the latest trends, tools, and best practices by following industry blogs, podcasts, and news sources.</li>
<li><strong>Read Code from Others</strong>: Look at open-source projects or code snippets from other developers. Analyzing how others write and structure their code can provide new insights and techniques.</li>
</ol>
<p><img decoding="async" loading="lazy" alt="6_tips" src="https://chaibiscuit.rajivy.me/assets/images/6_tips-3b505c1bff0a551c3878cab5c2bafc29.jpg" width="1200" height="1018" class="img_ev3q"></p>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="using-ai">Using AI<a href="https://chaibiscuit.rajivy.me/blog/self-taught-coder#using-ai" class="hash-link" aria-label="Direct link to Using AI" title="Direct link to Using AI">​</a></h3>
<p>We can leverage AI tools such as GitHub Co-pilot and Code Rabbit-AI, which greatly assist in coding and pull request reviews. They can be used as a peer programmer to help with coding.</p>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="career-impact">Career Impact<a href="https://chaibiscuit.rajivy.me/blog/self-taught-coder#career-impact" class="hash-link" aria-label="Direct link to Career Impact" title="Direct link to Career Impact">​</a></h3>
<p>I was able to advance from an <strong>application specialist</strong> to a <strong>developer</strong> role through <strong>self-teaching</strong>. Initially, employers were
skeptical, but I overcame their doubts by creating small projects to solve common problems. For example, I built a basic
LEM (low-equity-margin) calculator on MS Azure. This calculator took property prices and deposit amounts as input to
calculate LEM fees from various banks. During interviews, I demonstrated this application on my iPad, showcasing my
practical skills and problem-solving abilities. Tackling such challenges on my own enhanced my problem-solving skills,
made me more resourceful, and helped me address any knowledge gaps through continuous learning and feedback.</p>
<div class="theme-admonition theme-admonition-tip admonition_xJq3 alert alert--success"><div class="admonitionHeading_Gvgb"><span class="admonitionIcon_Rf37"><svg viewBox="0 0 12 16"><path fill-rule="evenodd" d="M6.5 0C3.48 0 1 2.19 1 5c0 .92.55 2.25 1 3 1.34 2.25 1.78 2.78 2 4v1h5v-1c.22-1.22.66-1.75 2-4 .45-.75 1-2.08 1-3 0-2.81-2.48-5-5.5-5zm3.64 7.48c-.25.44-.47.8-.67 1.11-.86 1.41-1.25 2.06-1.45 3.23-.02.05-.02.11-.02.17H5c0-.06 0-.13-.02-.17-.2-1.17-.59-1.83-1.45-3.23-.2-.31-.42-.67-.67-1.11C2.44 6.78 2 5.65 2 5c0-2.2 2.02-4 4.5-4 1.22 0 2.36.42 3.22 1.19C10.55 2.94 11 3.94 11 5c0 .66-.44 1.78-.86 2.48zM4 14h5c-.23 1.14-1.3 2-2.5 2s-2.27-.86-2.5-2z"></path></svg></span>Fun-fact</div><div class="admonitionContent_BuS1"><p>The site your reading this post is also a side project I built as part of my self-learning journey.</p></div></div>
<p><img decoding="async" loading="lazy" alt="thumbnail post" src="https://chaibiscuit.rajivy.me/assets/images/build-small-feb540a2d1e40ef8b2305185396169d9.jpg" width="827" height="412" class="img_ev3q"></p>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="conclusion">Conclusion<a href="https://chaibiscuit.rajivy.me/blog/self-taught-coder#conclusion" class="hash-link" aria-label="Direct link to Conclusion" title="Direct link to Conclusion">​</a></h3>
<p>Whenever you're feeling overwhelmed or stuck, keep these tips in mind to keep pushing ahead. Let's all support each other on this journey.</p>
<p>One last thought: keep sipping ☕, crunching 🍪, and coding 🛠️—your next breakthrough is just a chai away.</p>
<p><strong>🎉Happy coding!!🎉</strong></p>
<div class="theme-admonition theme-admonition-info admonition_xJq3 alert alert--info"><div class="admonitionHeading_Gvgb"><span class="admonitionIcon_Rf37"><svg viewBox="0 0 14 16"><path fill-rule="evenodd" d="M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"></path></svg></span>🔥 Keep the Chai Brewing!</div><div class="admonitionContent_BuS1"><p>Every <strong><a href="https://buymeacoffee.com/rajivy" target="_blank" rel="noopener noreferrer">coffee ☕ (or chai 🍵)</a></strong> you buy fuels another idea, another post, and another smile. Thank you for supporting my work!</p></div></div>]]></content:encoded>
            <category>101</category>
            <category>learning</category>
        </item>
        <item>
            <title><![CDATA[Unlocking AI Magic - A Four-Minute Guide]]></title>
            <link>https://chaibiscuit.rajivy.me/blog/ai-intro</link>
            <guid>https://chaibiscuit.rajivy.me/blog/ai-intro</guid>
            <pubDate>Sun, 02 Jun 2024 00:00:00 GMT</pubDate>
            <description><![CDATA[✨ Discover the Incredible World of AI - A Simple Intro for Curious Minds (and 5-Year-Olds) ✨]]></description>
            <content:encoded><![CDATA[<p>✨ <strong>Discover the Incredible World of AI - A Simple Intro for Curious Minds (and 5-Year-Olds)</strong> ✨</p>
<p>My 5-year-old son recently asked me what AI is, and trying to explain it to him inspired me to break it down for all of you too. Have you ever wondered how your phone seems to understand you, or how self-driving cars navigate the roads? These are not just technological marvels, but practical applications of Artificial Intelligence, a technology that's not just a concept, but a part of our everyday lives. Let's dive into this fascinating realm of AI, and discover how it's shaping our world, all in just four minutes!</p>
<p><img decoding="async" loading="lazy" alt="ai_fun post" src="https://chaibiscuit.rajivy.me/assets/images/ai_thumbnail-1-4a3dfc5a430b6a142ec93d5f5fcf2233.jpg" width="1200" height="686" class="img_ev3q"></p>
<p>AI enables computers and robots to do things that typically require human intelligence, like understanding language, recognizing images, and playing games. It's like having a toy that can talk to you, understand what you say, and learn just like you.</p>
<p>AI can help in many ways, such as teaching us new things, finding answers to our questions, and creating cool drawings and stories. It's like having a super smart friend who can assist us with almost anything. Cool, right?</p>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="tldr---version">TL;DR - version<a href="https://chaibiscuit.rajivy.me/blog/ai-intro#tldr---version" class="hash-link" aria-label="Direct link to TL;DR - version" title="Direct link to TL;DR - version">​</a></h3>
<p><img decoding="async" loading="lazy" alt="ai_fun post" src="https://chaibiscuit.rajivy.me/assets/images/ai-funda-2-1-882e1b2ae6a7786590c45b82789c49bf.jpg" width="1200" height="862" class="img_ev3q"></p>
<p>Some key workloads include the following:</p>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="machine-learning">Machine Learning<a href="https://chaibiscuit.rajivy.me/blog/ai-intro#machine-learning" class="hash-link" aria-label="Direct link to Machine Learning" title="Direct link to Machine Learning">​</a></h3>
<p>Now, let's delve into the powerhouse of AI, <strong>Machine Learning</strong>. Imagine a computer that can think for itself, that can learn from massive amounts of data and use that knowledge to make predictions. It's not just a concept; it's a reality. Machine Learning is the magic behind your movie recommendations on Netflix, and it's like having a weather forecast that accurately predicts future conditions by analyzing historical data. The power of AI is truly awe-inspiring, isn't it?</p>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="computer-vision">Computer vision<a href="https://chaibiscuit.rajivy.me/blog/ai-intro#computer-vision" class="hash-link" aria-label="Direct link to Computer vision" title="Direct link to Computer vision">​</a></h3>
<p><strong>Computer vision</strong> enables machines to interpret data from cameras, videos, and images, allowing AI to understand the visual world. It's used in self-driving cars, facial recognition on smartphones, medical imaging, security systems, and retail inventory management, giving robots their own set of eyes for superhuman accuracy.</p>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="natural-language-processing-or-nlp">Natural Language Processing, or NLP<a href="https://chaibiscuit.rajivy.me/blog/ai-intro#natural-language-processing-or-nlp" class="hash-link" aria-label="Direct link to Natural Language Processing, or NLP" title="Direct link to Natural Language Processing, or NLP">​</a></h3>
<p><strong>Natural Language Processing, or NLP</strong>, empowers AI to comprehend and respond to human language. Thanks to natural language processing (NLP), virtual assistants such as Siri, Alexa, and Google Assistant can engage in conversations with us, answer queries, and execute tasks on demand. Imagine instructing your assistant to set reminders, send messages, or even crack a joke. NLP also drives language translation services, facilitating real-time communication across diverse languages. It’s like having a super-intelligent companion who speaks every language and is always at your service, making our interactions with technology more fluid and human-like.</p>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="document-intelligence">Document Intelligence<a href="https://chaibiscuit.rajivy.me/blog/ai-intro#document-intelligence" class="hash-link" aria-label="Direct link to Document Intelligence" title="Direct link to Document Intelligence">​</a></h3>
<p>Then there’s <strong>Document Intelligence</strong>—think of it as your ultimate paperwork wizard. This feature automates the extraction and interpretation of information from documents, simplifying data management. Document intelligence ensures accuracy and efficiency in finance, legal, and healthcare by automating paperwork processing. AI eliminates the need for manual document sorting, freeing up time for more meaningful work. It's like having a tireless office assistant who works around the clock without making mistakes, allowing us to focus on tasks that require our unique human skills.</p>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="knowledge-mining">Knowledge Mining<a href="https://chaibiscuit.rajivy.me/blog/ai-intro#knowledge-mining" class="hash-link" aria-label="Direct link to Knowledge Mining" title="Direct link to Knowledge Mining">​</a></h3>
<p><strong>Knowledge Mining</strong> harnesses AI to sift through vast amounts of data to unearth valuable insights. It's like having a digital treasure hunter that consistently strikes gold. Businesses exploit this capability to scrutinize market trends, decipher customer behavior, and make informed, data-driven decisions. For instance, AI can swiftly retrieve relevant information to address customer service inquiries. Simultaneously, business intelligence helps companies stay ahead of the competition by unveiling hidden patterns and opportunities. Just envision transforming massive data into a bountiful source of insights, fueling innovation and propelling growth.</p>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="generative-ai">Generative AI<a href="https://chaibiscuit.rajivy.me/blog/ai-intro#generative-ai" class="hash-link" aria-label="Direct link to Generative AI" title="Direct link to Generative AI">​</a></h3>
<p><strong>Generative AI</strong> is the artist in the AI family. It can create original content, such as writing a novel, composing music, or designing graphics. By utilising advanced models like Generative Adversarial Networks (GANs), generative AI can produce new and innovative outputs that can rival human creativity. It is used in creative industries, content creation, and software development. Just imagine a robot, Picasso or Shakespeare, tirelessly crafting masterpieces. Artists and designers can use AI to brainstorm new ideas, writers can get help generating storylines, and developers can automate parts of coding. The possibilities are endless as human creativity blends with AI's boundless potential.</p>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="conclusion">Conclusion<a href="https://chaibiscuit.rajivy.me/blog/ai-intro#conclusion" class="hash-link" aria-label="Direct link to Conclusion" title="Direct link to Conclusion">​</a></h3>
<p>Dive into the world of AI and unlock the future today! Whether you're a tech enthusiast or just someone curious about the future, there’s much more to explore.</p>
<p>And that’s AI, demystified in four minutes! Thanks for reading, and stay curious!</p>
<p>Remember: let chai ☕ and biscuits 🍪 fuel your focus while you build the future 💡.</p>
<p><strong>🎉Happy coding!!🎉</strong></p>
<div class="theme-admonition theme-admonition-info admonition_xJq3 alert alert--info"><div class="admonitionHeading_Gvgb"><span class="admonitionIcon_Rf37"><svg viewBox="0 0 14 16"><path fill-rule="evenodd" d="M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"></path></svg></span>☕ Fuel the Journey!</div><div class="admonitionContent_BuS1"><p>Liked what you read? Let’s keep the chai ☕ (or coffee ☕) flowing—<strong><a href="https://buymeacoffee.com/rajivy" target="_blank" rel="noopener noreferrer">buying me a coffee ☕</a></strong> to help me write the next one!</p></div></div>]]></content:encoded>
            <category>ai</category>
            <category>fundamentals</category>
        </item>
        <item>
            <title><![CDATA[How I passed the AWS Developer Exam]]></title>
            <link>https://chaibiscuit.rajivy.me/blog/aws-DVA-C02-study-guide</link>
            <guid>https://chaibiscuit.rajivy.me/blog/aws-DVA-C02-study-guide</guid>
            <pubDate>Sun, 26 May 2024 00:00:00 GMT</pubDate>
            <description><![CDATA[✨ My experience and how I passed the AWS Certified Developer - Associate ✨]]></description>
            <content:encoded><![CDATA[<p>✨ <strong>My experience and how I passed the AWS Certified Developer - Associate</strong> ✨</p>
<p>Taking the AWS Developer Associate exam was a significant milestone in my journey as a developer. Here's a detailed account of my experience, from preparation to the actual exam day.</p>
<p><img decoding="async" loading="lazy" alt="first post" src="https://chaibiscuit.rajivy.me/assets/images/aws_thumbnail-fa211d94949ebdb1fb9281ab1cb1ea8f.jpg" width="1150" height="719" class="img_ev3q"></p>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="initial-nervousness">Initial Nervousness<a href="https://chaibiscuit.rajivy.me/blog/aws-DVA-C02-study-guide#initial-nervousness" class="hash-link" aria-label="Direct link to Initial Nervousness" title="Direct link to Initial Nervousness">​</a></h3>
<p>As the exam day approached, I felt excitement and nervousness. This was the first time I was sitting for an AWS exam, and the uncertainty of what to expect added to my anxiety. However, I was determined to give it my best shot.</p>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="preparation-strategy">Preparation Strategy<a href="https://chaibiscuit.rajivy.me/blog/aws-DVA-C02-study-guide#preparation-strategy" class="hash-link" aria-label="Direct link to Preparation Strategy" title="Direct link to Preparation Strategy">​</a></h3>
<p>I heavily relied on the AWS Certified Developer – Associate Exam Guide provided on the <strong>AWS website</strong> to prepare for the exam. The guide outlines all the topics and services within the scope of the exam, which was instrumental in structuring my study plan.</p>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="understanding-exam-structure">Understanding exam structure<a href="https://chaibiscuit.rajivy.me/blog/aws-DVA-C02-study-guide#understanding-exam-structure" class="hash-link" aria-label="Direct link to Understanding exam structure" title="Direct link to Understanding exam structure">​</a></h3>
<p>Understanding the exam domains and their respective weights is essential for effective preparation. Below are the primary domains covered in the AWS Developer Associate exam, along with their percentage weights:</p>
<ul>
<li><strong>Domain-1</strong>: Development with AWS Services (32% of scored content)</li>
<li><strong>Domain-2</strong>: Security (26% of scored content)</li>
<li><strong>Domain-3</strong>: Deployment (24% of scored content)</li>
<li><strong>Domain-4</strong>: Troubleshooting and Optimization (18% of scored content)</li>
</ul>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="building-notes-and-focusing-on-key-services">Building Notes and focusing on Key Services<a href="https://chaibiscuit.rajivy.me/blog/aws-DVA-C02-study-guide#building-notes-and-focusing-on-key-services" class="hash-link" aria-label="Direct link to Building Notes and focusing on Key Services" title="Direct link to Building Notes and focusing on Key Services">​</a></h3>
<p>During my preparation, I took detailed notes on various AWS resources outlined in the exam guide. This practice was invaluable for consolidating my understanding and quickly revising key concepts. I paid extra attention to the services highlighted in the exam guide to ensure thorough knowledge of each one.</p>
<p>Here's a <strong>conceptual representation</strong> of the services which are in-scope for the exam.</p>
<p><img decoding="async" loading="lazy" alt="exam_prep" src="https://chaibiscuit.rajivy.me/assets/images/examprep-1-b249f5acc23ba5e70d0580624a291c6f.jpg" width="1440" height="900" class="img_ev3q"></p>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="self-study-and-additional-practice">Self-Study and Additional Practice<a href="https://chaibiscuit.rajivy.me/blog/aws-DVA-C02-study-guide#self-study-and-additional-practice" class="hash-link" aria-label="Direct link to Self-Study and Additional Practice" title="Direct link to Self-Study and Additional Practice">​</a></h3>
<p>I made sure to gain practical experience at work and also dedicated time to studying services like AWS Lambda functions and DynamoDB. Even though these topics were not part of my job, I understood their importance for the exam and made sure to learn how to use them effectively. I practiced creating and managing Lambda functions and working with DynamoDB through online tutorials and AWS's free tier.</p>
<table><thead><tr><th>Feel free to check out the links to my notes here:</th><th><strong>Pdf Link</strong></th></tr></thead><tbody><tr><td><a href="https://chaibiscuit.rajivy.me/certifications/aws/dev_associate/aws_developer_associate">30-day Prep guide</a></td><td><a href="https://buymeacoffee.com/rajivy/e/258340" target="_blank" rel="noopener noreferrer">Here's the 30-day preparation timeline</a><br><a href="https://buymeacoffee.com/rajivy/e/258407" target="_blank" rel="noopener noreferrer">Here's the pdf</a></td></tr><tr><td><a href="https://chaibiscuit.rajivy.me/certifications/aws/dev_associate/overview_topics">In-scope services</a></td><td><a href="https://buymeacoffee.com/rajivy/e/258410" target="_blank" rel="noopener noreferrer">Here's the pdf</a></td></tr><tr><td><a href="https://chaibiscuit.rajivy.me/certifications/aws/dev_associate/compute_services">About Compute Services</a></td><td><a href="https://buymeacoffee.com/rajivy/e/258411" target="_blank" rel="noopener noreferrer">Here's the pdf</a></td></tr><tr><td><a href="https://chaibiscuit.rajivy.me/certifications/aws/dev_associate/storage_services">About Storage Services</a></td><td><a href="https://buymeacoffee.com/rajivy/e/258415" target="_blank" rel="noopener noreferrer">Here's the pdf</a></td></tr><tr><td><a href="https://chaibiscuit.rajivy.me/certifications/aws/dev_associate/database_services">About Database Services</a></td><td><a href="https://buymeacoffee.com/rajivy/e/258414" target="_blank" rel="noopener noreferrer">Here's the pdf</a></td></tr><tr><td><a href="https://chaibiscuit.rajivy.me/certifications/aws/dev_associate/cdn_service">About Networking and Content Delivery Services</a></td><td><a href="https://buymeacoffee.com/rajivy/e/258413" target="_blank" rel="noopener noreferrer">Here's the pdf</a></td></tr><tr><td><a href="https://chaibiscuit.rajivy.me/certifications/aws/dev_associate/container_services">About Container Services</a></td><td><a href="https://buymeacoffee.com/rajivy/e/258412" target="_blank" rel="noopener noreferrer">Here's the pdf</a></td></tr></tbody></table>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="hands-on-practice">Hands-on Practice<a href="https://chaibiscuit.rajivy.me/blog/aws-DVA-C02-study-guide#hands-on-practice" class="hash-link" aria-label="Direct link to Hands-on Practice" title="Direct link to Hands-on Practice">​</a></h3>
<p>One of the most beneficial aspects of my preparation was the hands-on experience I gained from my job. I had the opportunity to work with various AWS services, which gave me practical insights that went beyond theoretical knowledge. Some of the key services I worked with include:</p>
<ul>
<li><strong>AWS RDS (PostgreSQL)</strong>: Integrating our application with RDS provided me with hands-on experience in setting up, maintaining, and querying databases.</li>
<li><strong>EKS (Elastic Kubernetes Service)</strong>: I have deployed and managed containerized applications using Kubernetes, which is essential for modern cloud-native applications.</li>
<li><strong>ECR (Elastic Container Registry)</strong>: Understanding how to store, manage, and deploy Docker container images was part of my daily tasks.</li>
<li><strong>CodeBuild and CodePipeline</strong>: Implementing CI/CD pipelines has helped me understand the end-to-end software development lifecycle on AWS.</li>
</ul>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="exam-day">Exam Day<a href="https://chaibiscuit.rajivy.me/blog/aws-DVA-C02-study-guide#exam-day" class="hash-link" aria-label="Direct link to Exam Day" title="Direct link to Exam Day">​</a></h3>
<p>I chose to take the exam at a local test centre rather than online proctored, as I wanted to avoid any disturbances and hassle. On exam day, I arrived at the exam centre feeling a mix of anticipation and nerves. Once I started the exam, I found that my thorough preparation and hands-on experience paid off. The questions were challenging but manageable, and I felt confident in my answers.</p>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="my-two-cents">My two cents<a href="https://chaibiscuit.rajivy.me/blog/aws-DVA-C02-study-guide#my-two-cents" class="hash-link" aria-label="Direct link to My two cents" title="Direct link to My two cents">​</a></h3>
<ul>
<li><strong>Create and Experiment!</strong> There's no substitute for hands-on practice.</li>
<li><strong>Familiarize Yourself with the Exam Guide</strong> to ensure your projects are on target.</li>
<li><strong>Time Management is Key</strong> during the exam.</li>
</ul>
<p><img decoding="async" loading="lazy" alt="first post" src="https://chaibiscuit.rajivy.me/assets/images/sample-9047070a5c845c41ffcbd8e9db32c354.jpg" width="1200" height="1345" class="img_ev3q"></p>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="conclusion">Conclusion<a href="https://chaibiscuit.rajivy.me/blog/aws-DVA-C02-study-guide#conclusion" class="hash-link" aria-label="Direct link to Conclusion" title="Direct link to Conclusion">​</a></h3>
<p>Passing the AWS Developer Associate exam was a rewarding experience. It validated the effort I had put into learning and working with AWS services. For anyone preparing for this exam, I highly recommend following the official AWS prep guide, gaining as much hands-on experience as possible, and making detailed notes to aid your revision.</p>
<p>Remember: let chai ☕ and biscuits 🍪 fuel your focus while you build the future 💡.</p>
<p><strong>🎉Happy coding!!🎉</strong></p>
<div class="theme-admonition theme-admonition-info admonition_xJq3 alert alert--info"><div class="admonitionHeading_Gvgb"><span class="admonitionIcon_Rf37"><svg viewBox="0 0 14 16"><path fill-rule="evenodd" d="M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"></path></svg></span>🔥 Keep the Chai Brewing!</div><div class="admonitionContent_BuS1"><p>This post was powered by chai ☕ and biscuits 🍪. If you'd like to fuel the next one, consider <strong><a href="https://buymeacoffee.com/rajivy" target="_blank" rel="noopener noreferrer">buying me a coffee ☕</a></strong>!</p></div></div>]]></content:encoded>
            <category>study guide</category>
            <category>aws</category>
            <category>certification</category>
        </item>
        <item>
            <title><![CDATA[Devcontainers - Why the Hype?]]></title>
            <link>https://chaibiscuit.rajivy.me/blog/dev-container-101</link>
            <guid>https://chaibiscuit.rajivy.me/blog/dev-container-101</guid>
            <pubDate>Thu, 16 May 2024 00:00:00 GMT</pubDate>
            <description><![CDATA[✨ Devcontainers: A Simple Introduction ✨]]></description>
            <content:encoded><![CDATA[<p>✨ <strong>Devcontainers: A Simple Introduction</strong> ✨</p>
<p>A development container, commonly known as a <strong><a href="https://containers.dev/" target="_blank" rel="noopener noreferrer">Dev containers</a></strong>, provides a comprehensive environment for software
development within a container. It's utilized to operate applications, isolate necessary tools, libraries, and runtimes
for code management, and support continuous integration and testing processes.</p>
<p><img decoding="async" loading="lazy" alt="second post" src="https://chaibiscuit.rajivy.me/assets/images/101-d2ecd0394c44d19582ca5bb4b952609b.jpg" width="1200" height="686" class="img_ev3q"></p>
<h2 class="anchor anchorWithStickyNavbar_LWe7" id="discover-dev-containers-a-simple-introduction"><strong>Discover Dev containers: A Simple Introduction</strong><a href="https://chaibiscuit.rajivy.me/blog/dev-container-101#discover-dev-containers-a-simple-introduction" class="hash-link" aria-label="Direct link to discover-dev-containers-a-simple-introduction" title="Direct link to discover-dev-containers-a-simple-introduction">​</a></h2>
<p>Welcome to the world of Development Containers, or <span class="bg-sky-300 dark:bg-sky-600">"Dev containers"</span> for short—a game-changing tool that's reshaping how developers work with code! Whether you're a seasoned programmer or just dipping your toes into the vast ocean of
development, understanding dev containers <span class="bg-sky-300 dark:bg-sky-600">can streamline your workflow and enhance your coding experience</span>. So, buckle up as we embark on a creative journey to demystify this powerful tool.</p>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="what-are-dev-containers">What Are Dev containers?<a href="https://chaibiscuit.rajivy.me/blog/dev-container-101#what-are-dev-containers" class="hash-link" aria-label="Direct link to What Are Dev containers?" title="Direct link to What Are Dev containers?">​</a></h3>
<p>Imagine walking into a kitchen where all the spices and ingredients for a delicious Indian curry are pre-arranged and ready to use. Dev containers work similarly for coding. They are flexible, reusable development environments with all the necessary tools, settings, and extensions. This allows you to start coding right away without worrying about manual setups.</p>
<p><span class="bg-sky-300 dark:bg-sky-600">Unlike virtual machines, Dev Containers do not bundle a full operating system—only the necessary components are included</span>, making them much more efficient regarding system resources. Dev containers use technologies like Docker to create and manage these containers.</p>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="why-dev-containers">Why Dev containers?<a href="https://chaibiscuit.rajivy.me/blog/dev-container-101#why-dev-containers" class="hash-link" aria-label="Direct link to Why Dev containers?" title="Direct link to Why Dev containers?">​</a></h3>
<p>Here’s why you might want to jump on the dev container bandwagon:</p>
<ul>
<li><strong>Consistency Across Environments</strong>: Dev containers ensure that each team member works in an identical development environment, eliminating the "but it works on my machine!" issue.</li>
<li><strong>Quick Onboarding</strong>: New team members can quickly get started by cloning the repository and launching the development container, making them ready to code in no time.</li>
<li><strong>Versatility and Portability</strong>: Whether you're using a Windows laptop, a Mac, or a tablet, your dev container can run consistently across all platforms.</li>
</ul>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="how-dev-containers-work">How Dev Containers Work<a href="https://chaibiscuit.rajivy.me/blog/dev-container-101#how-dev-containers-work" class="hash-link" aria-label="Direct link to How Dev Containers Work" title="Direct link to How Dev Containers Work">​</a></h3>
<p><span class="bg-sky-300 dark:bg-sky-600">The core </span> of a dev container <span class="bg-sky-300 dark:bg-sky-600">setup is a configuration file that defines the environment</span>. This file, typically named <code>devcontainer.json</code>, instructs your development tool (such as Visual Studio Code) on how to build the container. It specifies details such as the base image to use, the extensions to install, and the ports to open.</p>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="is-this-compatible-with-any-programming-languages-or-frameworks">Is this compatible with any programming languages or frameworks?<a href="https://chaibiscuit.rajivy.me/blog/dev-container-101#is-this-compatible-with-any-programming-languages-or-frameworks" class="hash-link" aria-label="Direct link to Is this compatible with any programming languages or frameworks?" title="Direct link to Is this compatible with any programming languages or frameworks?">​</a></h3>
<p>Dev containers <span class="bg-sky-300 dark:bg-sky-600">can be configured for virtually any programming language or framework</span>. You adjust the Dockerfile and configuration to include the necessary tools, libraries, and dependencies specific to your project's needs.</p>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="how-can-i-share-a-dev-container-with-my-team">How can I share a Dev container with my team?<a href="https://chaibiscuit.rajivy.me/blog/dev-container-101#how-can-i-share-a-dev-container-with-my-team" class="hash-link" aria-label="Direct link to How can I share a Dev container with my team?" title="Direct link to How can I share a Dev container with my team?">​</a></h3>
<p>To share a Dev container with the team, <span class="bg-sky-300 dark:bg-sky-600">include the <code>devcontainer.json</code> file and any associated Dockerfiles in the project's repository</span>. This will allow all team members to build the same container on their local machines, ensuring everyone has an identical development environment.</p>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="what-are-the-limitations-of-using-dev-containers">What are the limitations of using Dev containers?<a href="https://chaibiscuit.rajivy.me/blog/dev-container-101#what-are-the-limitations-of-using-dev-containers" class="hash-link" aria-label="Direct link to What are the limitations of using Dev containers?" title="Direct link to What are the limitations of using Dev containers?">​</a></h3>
<p>While Dev containers offer many benefits, there are limitations:</p>
<ul>
<li>They require familiarity with Docker and container management.</li>
<li>Performance might be slightly reduced compared to a native setup, especially regarding file system performance.</li>
<li>Not all tools or applications may work seamlessly inside containers without additional configuration.</li>
</ul>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="how-do-dev-containers-improve-security">How do Dev containers improve security?<a href="https://chaibiscuit.rajivy.me/blog/dev-container-101#how-do-dev-containers-improve-security" class="hash-link" aria-label="Direct link to How do Dev containers improve security?" title="Direct link to How do Dev containers improve security?">​</a></h3>
<p><span class="bg-sky-300 dark:bg-sky-600">By isolating the development environment</span> from the local system, Dev containers <span class="bg-sky-300 dark:bg-sky-600">reduce the risk of running untrusted code directly on the host machine</span>. Additionally, dependencies and tools are confined within the container, minimising the impact of malicious code.</p>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="dev-containers-vs-regular-containers">Dev Containers vs Regular Containers<a href="https://chaibiscuit.rajivy.me/blog/dev-container-101#dev-containers-vs-regular-containers" class="hash-link" aria-label="Direct link to Dev Containers vs Regular Containers" title="Direct link to Dev Containers vs Regular Containers">​</a></h3>
<table><thead><tr><th>Feature</th><th>Devcontainers</th><th>Regular Containers</th></tr></thead><tbody><tr><td><strong>Purpose</strong></td><td>Specifically designed for software development</td><td>Designed for a broad range of applications</td></tr><tr><td><strong>Configuration</strong></td><td>Pre-configured with development tools and environments</td><td>Configured for specific runtime needs</td></tr><tr><td><strong>Development Tools</strong></td><td>Integrated with tools like VS Code, debuggers, linters</td><td>Typically does not include development-specific tools</td></tr><tr><td><strong>Workspace Interaction</strong></td><td>Workspace is often mounted for real-time editing</td><td>Generally static; does not interact with host workspace</td></tr><tr><td><strong>Dependency Management</strong></td><td>Manages dependencies to ensure consistency</td><td>Manages dependencies for operational stability</td></tr><tr><td><strong>Isolation</strong></td><td>Isolates development environment to avoid host conflicts</td><td>Provides general isolation from the host system</td></tr><tr><td><strong>Example</strong></td><td>A dev container for .NET development might include the .NET SDK, essential VS Code extensions for C#, and pre-configured debug settings.</td><td>A regular container might be set up to host a .NET web application, configured with only the necessary runtimes and services like IIS for deployment.</td></tr></tbody></table>
<h2 class="anchor anchorWithStickyNavbar_LWe7" id="setting-up-your-first-dev-container"><strong>Setting Up Your First Dev Container</strong><a href="https://chaibiscuit.rajivy.me/blog/dev-container-101#setting-up-your-first-dev-container" class="hash-link" aria-label="Direct link to setting-up-your-first-dev-container" title="Direct link to setting-up-your-first-dev-container">​</a></h2>
<p>Here’s a simple step-by-step guide to setting up your first dev container using Visual Studio Code, one of the most popular editors that support this feature.</p>
<ol>
<li><strong>Install Prerequisites</strong>: Make sure you install Docker on your machine, as it’s the backbone for creating containers.</li>
<li><strong>Clone a Repository</strong>: Find a project with a <code>devcontainer.json</code> file or create a new one by cloning a template from a source like GitHub.</li>
<li><strong>Open with Visual Studio Code</strong>: Open the project folder in VS Code. VS Code might prompt you to reopen the folder in a container. Go ahead and click "Reopen in Container".</li>
<li><strong>Start Coding</strong>: Once the container is built and running, you can start editing, debugging, and running your code as if everything was locally installed on your machine.</li>
</ol>
<div class="theme-admonition theme-admonition-info admonition_xJq3 alert alert--info"><div class="admonitionHeading_Gvgb"><span class="admonitionIcon_Rf37"><svg viewBox="0 0 14 16"><path fill-rule="evenodd" d="M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"></path></svg></span>info</div><div class="admonitionContent_BuS1"><p>I will cover the setting up and dev containers in action topics in the upcoming posts.</p></div></div>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="customizing-your-dev-container">Customizing Your Dev Container<a href="https://chaibiscuit.rajivy.me/blog/dev-container-101#customizing-your-dev-container" class="hash-link" aria-label="Direct link to Customizing Your Dev Container" title="Direct link to Customizing Your Dev Container">​</a></h3>
<p>Customising your dev container is where you can get creative. You can modify your <code>devcontainer.json</code> to:</p>
<ul>
<li><strong>Change the Base Image</strong>: You might want a different operating system or tools pre-installed depending on your project's needs.</li>
<li><strong>Install Extensions</strong>: Automatically install VS Code extensions that are essential for your project.</li>
<li><strong>Forward Ports</strong>: Automatically forward ports for web development or database access.</li>
</ul>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="dev-containers-in-action">Dev containers in Action<a href="https://chaibiscuit.rajivy.me/blog/dev-container-101#dev-containers-in-action" class="hash-link" aria-label="Direct link to Dev containers in Action" title="Direct link to Dev containers in Action">​</a></h3>
<p>To illustrate the power of dev containers, let's take an imaginary scenario. Suppose you're developing a web application using Node.js. Your <code>devcontainer.json</code> might include settings to install Node.js, configure the necessary extensions for JavaScript development, and forward the ports used by Node.js applications.</p>
<h2 class="anchor anchorWithStickyNavbar_LWe7" id="beyond-the-basics"><strong>Beyond the Basics</strong><a href="https://chaibiscuit.rajivy.me/blog/dev-container-101#beyond-the-basics" class="hash-link" aria-label="Direct link to beyond-the-basics" title="Direct link to beyond-the-basics">​</a></h2>
<p>Once you’re comfortable with essential dev containers, you can explore more advanced features like:</p>
<ul>
<li><strong>Integrating with Cloud Services</strong>: Set up your dev container to interact with cloud databases or storage.</li>
<li><strong>Using Docker Compose</strong>: You can use Docker Compose within your dev container setup to orchestrate multiple services for more complex environments.</li>
</ul>
<h2 class="anchor anchorWithStickyNavbar_LWe7" id="conclusion"><strong>Conclusion</strong><a href="https://chaibiscuit.rajivy.me/blog/dev-container-101#conclusion" class="hash-link" aria-label="Direct link to conclusion" title="Direct link to conclusion">​</a></h2>
<p>Dev containers represent a powerful paradigm shift in the development world, making managing project environments and collaborating across diverse teams easier. As you explore this exciting tool, remember that <span class="bg-sky-300 dark:bg-sky-600">the key to mastering dev containers lies in experimentation and customisation </span>. Dive in, tweak, and transform your dev container to fit your project’s unique palate.</p>
<p>As always, may your chai ☕ be endless, your biscuits 🍪 be perfect, and your code run without errors ✅.</p>
<p><strong>🎉Happy coding!!🎉</strong></p>
<div class="theme-admonition theme-admonition-info admonition_xJq3 alert alert--info"><div class="admonitionHeading_Gvgb"><span class="admonitionIcon_Rf37"><svg viewBox="0 0 14 16"><path fill-rule="evenodd" d="M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"></path></svg></span>☕ Fuel the Journey!</div><div class="admonitionContent_BuS1"><p>Every great idea starts with a sip of chai ☕ (or coffee ☕!). If you’d like to support more posts like this, <strong><a href="https://buymeacoffee.com/rajivy" target="_blank" rel="noopener noreferrer">buying me a coffee ☕</a></strong> keeps the ideas flowing!</p></div></div>]]></content:encoded>
            <category>docker</category>
            <category>container</category>
            <category>101</category>
            <category>qna</category>
        </item>
        <item>
            <title><![CDATA[Embarking on a New Chapter]]></title>
            <link>https://chaibiscuit.rajivy.me/blog/welcome</link>
            <guid>https://chaibiscuit.rajivy.me/blog/welcome</guid>
            <pubDate>Sun, 12 May 2024 00:00:00 GMT</pubDate>
            <description><![CDATA[Welcome to my first blog post! 🎉]]></description>
            <content:encoded><![CDATA[<p><strong>Welcome to my first blog post!</strong> 🎉</p>
<p>I embarked on a journey to find a good documentation platform, starting with <strong><a href="https://dotnet.github.io/docfx/index.html" target="_blank" rel="noopener noreferrer">DocFx</a></strong>. While, I was charmed by its simplicity, I soon hit the limits of
customisation.</p>
<p>That's when I discovered <strong><a href="https://docusaurus.io/" target="_blank" rel="noopener noreferrer">Docusaurus</a></strong> - a world of vibrant themes and advanced features that
transformed my site into an engaging, dynamic hub. It was a true game-changer in documentation!</p>
<p>During this process, the site's name was also changed from <strong>"Coffee &amp; Docs"</strong> to <strong>"Chai Biscuit"</strong>.</p>
<p><img decoding="async" loading="lazy" alt="first post" src="https://chaibiscuit.rajivy.me/assets/images/firstpost-f827a79823b1293e7e3411125136d494.png" width="1792" height="1024" class="img_ev3q"></p>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="the-beginning-why-i-chose-docfx">The Beginning: Why I Chose DocFX<a href="https://chaibiscuit.rajivy.me/blog/welcome#the-beginning-why-i-chose-docfx" class="hash-link" aria-label="Direct link to The Beginning: Why I Chose DocFX" title="Direct link to The Beginning: Why I Chose DocFX">​</a></h3>
<p>Like any <strong>enthusiastic developer</strong> eager to document their work, I embarked on my journey with DocFX. It was a natural
fit, as getting started was as easy as installing dotnet cli. Being a <strong>.Net dev</strong>, I met the minimum requirements,
enabling me to start using DocFX immediately. During the early stages of my DocFX experience, I was optimistic as I
explored its capabilities. I found its simplicity and ability to produce immediate results delightful.</p>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="hitting-roadblocks-with-docfx">Hitting Roadblocks with DocFX<a href="https://chaibiscuit.rajivy.me/blog/welcome#hitting-roadblocks-with-docfx" class="hash-link" aria-label="Direct link to Hitting Roadblocks with DocFX" title="Direct link to Hitting Roadblocks with DocFX">​</a></h3>
<p>As I started adding more content, so did its demands. I soon realised that DocFX, though robust, came with its set of
limitations:</p>
<ul>
<li>
<p><strong>Customization Woes</strong>: My vision for a sleek and user-friendly website clashed with the limited theming options
available. I wanted a platform that could provide aesthetics and functionality without requiring extensive
workarounds.</p>
</li>
<li>
<p><strong>Community and Support</strong>: Finding solutions and support in the community became increasingly difficult, leaving me
stranded with my problems.</p>
</li>
</ul>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="discovering-docusaurus">Discovering Docusaurus<a href="https://chaibiscuit.rajivy.me/blog/welcome#discovering-docusaurus" class="hash-link" aria-label="Direct link to Discovering Docusaurus" title="Direct link to Discovering Docusaurus">​</a></h3>
<p>While exploring alternative platforms, I discovered Docusaurus. Its impressive features seemed almost too good to be
true.</p>
<ul>
<li>
<p><strong>Vibrant Customization</strong>: Docusaurus offers effortless customization through many themes and plugins. It promises a
wide range of customisation options with minimal effort.</p>
</li>
<li>
<p><strong>Advanced Search Functionality</strong>: Integrated Algolia search means my documentation will be as user-friendly and
searchable as modern websites, even though I haven't enabled it yet 😊.</p>
</li>
<li>
<p><strong>Dynamic Content Management</strong>: The ease of managing markdown files and documentation versions was a game changer.
Additionally, its React foundation opened up a world of possibilities for interactive content.</p>
</li>
</ul>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="the-migration-a-smooth-transition">The Migration: A Smooth Transition<a href="https://chaibiscuit.rajivy.me/blog/welcome#the-migration-a-smooth-transition" class="hash-link" aria-label="Direct link to The Migration: A Smooth Transition" title="Direct link to The Migration: A Smooth Transition">​</a></h3>
<p>Transitioning to Docusaurus was an enlightening process. I carefully planned the migration of my existing content to the
new structure, utilising Docusaurus's vibrant ecosystem to improve every aspect of my site. The migration was about not
just moving content but transforming how it was presented and interacted with.</p>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="the-result-a-revitalized-documentation-experience">The Result: A Revitalized Documentation Experience<a href="https://chaibiscuit.rajivy.me/blog/welcome#the-result-a-revitalized-documentation-experience" class="hash-link" aria-label="Direct link to The Result: A Revitalized Documentation Experience" title="Direct link to The Result: A Revitalized Documentation Experience">​</a></h3>
<p>My site is no longer a mere collection of guides. It has evolved into a dynamic and engaging platform that visitors
truly enjoy exploring. Docusaurus has not only met my expectations but has surpassed them, making every bit of the
effort put into it worthwhile.</p>
<h3 class="anchor anchorWithStickyNavbar_LWe7" id="reflections-and-advice">Reflections and Advice<a href="https://chaibiscuit.rajivy.me/blog/welcome#reflections-and-advice" class="hash-link" aria-label="Direct link to Reflections and Advice" title="Direct link to Reflections and Advice">​</a></h3>
<p>The journey from DocFX to Docusaurus has taught me a valuable lesson about the significance of adaptability in
technology choices. My advice for those who are planning a similar migration is to think about their needs and the
community support they might require in the long run. Do not hesitate to embrace the change, as it could transform how
you and your users interact with your site.
During my transition, I realised that having the right tools is essential to communicate the story of your development
work effectively.</p>
<p>Finally, This cool GIF that demonstrates how the site has evolved since its inception</p>
<p><img decoding="async" loading="lazy" alt="evolution" src="https://chaibiscuit.rajivy.me/assets/images/evolve-c678ced8b9f66a1227c8f63cbac950be.gif" width="853" height="480" class="img_ev3q"></p>
<p>Let’s keep it going: strong chai ☕, steady biscuits 🍪, and unstoppable code 💻.</p>
<p><strong>🎉Happy coding!!🎉</strong></p>
<div class="theme-admonition theme-admonition-info admonition_xJq3 alert alert--info"><div class="admonitionHeading_Gvgb"><span class="admonitionIcon_Rf37"><svg viewBox="0 0 14 16"><path fill-rule="evenodd" d="M7 2.3c3.14 0 5.7 2.56 5.7 5.7s-2.56 5.7-5.7 5.7A5.71 5.71 0 0 1 1.3 8c0-3.14 2.56-5.7 5.7-5.7zM7 1C3.14 1 0 4.14 0 8s3.14 7 7 7 7-3.14 7-7-3.14-7-7-7zm1 3H6v5h2V4zm0 6H6v2h2v-2z"></path></svg></span>🔥 Keep the Chai Brewing!</div><div class="admonitionContent_BuS1"><p>Keep the chai ☕ flowing and the biscuits 🍪 dunking! If you enjoyed this, <strong><a href="https://buymeacoffee.com/rajivy" target="_blank" rel="noopener noreferrer">buying me a coffee ☕</a></strong> helps me keep writing.</p></div></div>]]></content:encoded>
            <category>hello</category>
            <category>journey</category>
        </item>
    </channel>
</rss>