<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Mohit Goyal on Medium]]></title>
        <description><![CDATA[Stories by Mohit Goyal on Medium]]></description>
        <link>https://medium.com/@mohitgoyal2804_76807?source=rss-53655b2918a3------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*s5-Im4eH8_Ddx6pPR72zUA.jpeg</url>
            <title>Stories by Mohit Goyal on Medium</title>
            <link>https://medium.com/@mohitgoyal2804_76807?source=rss-53655b2918a3------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 20 Nov 2026 21:04:08 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@mohitgoyal2804_76807/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[5 Daily Coding Tips I Wish I Knew Earlier — From a Senior Developer’s Desk]]></title>
            <link>https://medium.com/@mohitgoyal2804_76807/5-daily-coding-tips-i-wish-i-knew-earlier-from-a-senior-developers-desk-30e2afb778ac?source=rss-53655b2918a3------2</link>
            <guid isPermaLink="false">https://medium.com/p/30e2afb778ac</guid>
            <category><![CDATA[clean-code]]></category>
            <category><![CDATA[refactoring]]></category>
            <category><![CDATA[coding-tips]]></category>
            <category><![CDATA[development]]></category>
            <category><![CDATA[software-development]]></category>
            <dc:creator><![CDATA[Mohit Goyal]]></dc:creator>
            <pubDate>Sat, 12 Jul 2025 06:16:50 GMT</pubDate>
            <atom:updated>2025-07-12T06:16:50.688Z</atom:updated>
            <content:encoded><![CDATA[<h3>5 Daily Coding Tips I Wish I Knew Earlier — From a Senior Developer’s Desk</h3><p><strong>“Good code is like a good conversation — clear, respectful, and leaves no confusion.”</strong></p><p>After 7 + years of writing code, fixing bugs at 3 AM, reviewing PRs, and shipping code that runs in production.</p><p>I’ve learned that writing code is not just a skill… it’s a habit.</p><p>Whether you’re just starting out or already in your mid-level journey, here are <strong>5 simple but powerful coding tips</strong> I follow every single day. These aren’t from a book — these are from my desk.</p><h3>1. Think Before You Code — Write Less, Solve More</h3><p>When I started out, I thought being a good dev meant writing a lot of code fast.</p><p>But experience taught me:<br> <strong>Less code = fewer bugs + faster reviews + easier maintenance.</strong></p><p>Before jumping into your editor:</p><ul><li>Understand the requirement (don’t just assume)</li><li>Think about edge cases</li><li>Ask: “Can this be done simpler?”</li></ul><blockquote><strong><em>Tip:</em></strong><em> Spend the first 10 minutes white boarding or pseudo-coding. You’ll be amazed how much you won’t need to write.</em></blockquote><h3>2. Name Things Like You’re Explaining to Your Future Self</h3><p>Variables, functions, classes — they should <em>tell a story</em>.</p><pre>var dt = DateTime.Now;<br><br>// Good<br>var orderPlacedTime = DateTime.Now;</pre><p>A good name:</p><ul><li>Is specific (avoid data, info, stuff)</li><li>Avoids abbreviations unless they’re obvious (ID, URL)</li><li>Makes comments unnecessary</li></ul><blockquote><em>“Code is read more often than it is written. So write for the reader, not the machine.”</em></blockquote><h3>3. Don’t Repeat Yourself (DRY), But Don’t Obsess</h3><p>Ah, the DRY principle. It’s golden — but here’s the catch: <strong>early abstraction is dangerous</strong>.</p><p>✅ Reuse code when it’s truly repeated with the same meaning.<br> ❌ Don’t abstract every two-line duplication. Sometimes it just adds confusion.</p><blockquote><strong><em>Rule of thumb:</em></strong><em> The third time you write similar code — extract it.</em></blockquote><h3>4. 🛑 Write Fewer Comments — Let Code Speak</h3><p>I used to write comments like:</p><pre>// This function adds two numbers<br>int Add(int a, int b) =&gt; a + b;</pre><p>That’s just noise.</p><p>💬 Good comments:</p><ul><li>Explain <em>why</em>, not <em>what</em></li><li>Exist only when the code can’t be made clearer</li><li>Don’t lie (outdated comments are worse than none)</li></ul><blockquote><em>✍️ Instead: Refactor confusing code. Rename methods. Extract logic.</em></blockquote><h3>5. Test What You Fear Will Break — Before It Breaks</h3><p>You don’t need 100% test coverage. But you <strong>do</strong> need peace of mind.</p><p>When you write code that:</p><ul><li>Touches money</li><li>Sends notifications</li><li>Calls external APIs</li></ul><p><strong>Write tests.</strong> Even basic ones.</p><blockquote><em>“The best bug is the one you never ship.”</em></blockquote><p>Use unit tests for logic-heavy code, and integration tests where APIs, DBs, or services are involved.</p><h3>🎯 Final Thoughts: Code Like a Craftsman</h3><p>Clean code isn’t a fancy term — it’s a habit. A mindset. And a mark of someone who cares not just about code, but about the people who will read, use, and maintain it.</p><p>If I had to summarize:</p><ul><li>Think first.</li><li>Name things clearly.</li><li>Reuse wisely.</li><li>Comment only when it helps.</li><li>And always test the risky stuff.</li></ul><p>👋 Thanks for reading.</p><p>If this resonated with you, hit that like or drop a comment. Let’s make better software together — one clean line at a time.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=30e2afb778ac" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Understanding Table Variable, Temp Table, Global Temp Table, and CTE in SQL Server — Explained…]]></title>
            <link>https://medium.com/@mohitgoyal2804_76807/understanding-table-variable-temp-table-global-temp-table-and-cte-in-sql-server-explained-d65640218344?source=rss-53655b2918a3------2</link>
            <guid isPermaLink="false">https://medium.com/p/d65640218344</guid>
            <category><![CDATA[sql]]></category>
            <category><![CDATA[sqlconcepts]]></category>
            <category><![CDATA[sql-server]]></category>
            <dc:creator><![CDATA[Mohit Goyal]]></dc:creator>
            <pubDate>Sun, 25 May 2025 06:41:24 GMT</pubDate>
            <atom:updated>2025-05-25T06:54:12.321Z</atom:updated>
            <content:encoded><![CDATA[<h3>Understanding Table Variable, Temp Table, Global Temp Table, and CTE in SQL Server — Explained with Real Examples</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kJkC3hLuvqlhNmCzEClvAw.png" /></figure><p>If you’re working with SQL Server and ever wondered <strong>when to use table variables, temp tables, or CTEs</strong>, you’re not alone! These are common tools in the developer’s toolbox — but each one serves a different purpose.</p><p>In this post, we’ll walk through each one <strong>in simple terms</strong>, give you real-life <strong>examples</strong>, and help you <strong>decide when to use which</strong>.</p><h3>1. Table Variable — Like a Pocket Notepad</h3><p>Think of a <strong>table variable</strong> as a quick note you jot down during a meeting. It’s <strong>small</strong>, <strong>temporary</strong>, and only you can see it until your task is done.</p><pre>DECLARE @Employees TABLE (<br>    Id INT,<br>    Name VARCHAR(100)<br>);<br><br>INSERT INTO @Employees VALUES (1, &#39;John&#39;), (2, &#39;Jane&#39;);<br><br>SELECT * FROM @Employees;</pre><h3>Pros:</h3><ul><li>Stored in memory — fast for small data.</li><li>Automatically cleared after the batch or procedure ends.</li><li>Great for small, temporary results.</li></ul><h3>Cons:</h3><ul><li>No statistics = bad performance on large data.</li><li>Can’t use advanced indexing (only limited options).</li><li>Limited to the current batch or procedure.</li></ul><h3>When to Use:</h3><ul><li>Inside <strong>stored procedures</strong>.</li><li>For <strong>small lookup or filtering tasks</strong>.</li></ul><h3>2. Temporary Table — Like a Whiteboard in a Meeting Room</h3><p>A <strong>temporary table</strong> is like a whiteboard. You can write a lot on it, erase, rewrite, and it stays there as long as you’re in the room (session).</p><pre>CREATE TABLE #TempEmployees (<br>    Id INT,<br>    Name VARCHAR(100)<br>);<br><br>INSERT INTO #TempEmployees VALUES (1, &#39;Alice&#39;), (2, &#39;Bob&#39;);<br><br>SELECT * FROM #TempEmployees;</pre><h3>Pros:</h3><ul><li>Supports indexes and constraints.</li><li>Performs well with large data sets.</li><li>Good for <strong>complex queries, joins, and filtering</strong>.</li></ul><h3>Cons:</h3><ul><li>Stored in tempdb — can slow down if overused.</li><li>Must be manually dropped or ends when your session ends.</li></ul><h3>When to Use:</h3><ul><li>Handling <strong>intermediate large data sets</strong>.</li><li>Performing <strong>multi-step transformations</strong>.</li></ul><h3>3. Global Temporary Table — Like a Shared Google Doc</h3><p>A <strong>global temporary table (</strong><strong>##)</strong> is like a Google Doc — anyone with the link (session) can see it until all users are done.</p><pre>CREATE TABLE ##GlobalEmployees (<br>    Id INT,<br>    Name VARCHAR(100)<br>);<br><br>INSERT INTO ##GlobalEmployees VALUES (1, &#39;Karan&#39;);<br><br>SELECT * FROM ##GlobalEmployees;</pre><h3>Pros:</h3><ul><li>Shared across sessions/users.</li><li>Useful in <strong>scheduled jobs or background tasks</strong>.</li></ul><h3>Cons:</h3><ul><li>Can be a <strong>security issue</strong> if not managed well.</li><li>Hard to debug if multiple users write to it.</li></ul><h3>When to Use:</h3><ul><li>You want to <strong>share data</strong> between different users or jobs.</li><li>Temporary reporting accessible by all users.</li></ul><h3>4. CTE (Common Table Expression) — Like a Shortcut or Alias</h3><p>A <strong>CTE</strong> is like a shortcut you create in a document to avoid repeating long content again and again.</p><pre>WITH EmpCTE AS (<br>    SELECT Id, Name<br>    FROM Employees<br>    WHERE Department = &#39;IT&#39;<br>)<br>SELECT * FROM EmpCTE;</pre><h3>Pros:</h3><ul><li>Makes queries <strong>readable and maintainable</strong>.</li><li>Supports <strong>recursive queries</strong> (e.g., organization hierarchies).</li><li>Does not use tempdb.</li></ul><h3>Cons:</h3><ul><li>Not materialized — it’s just a reusable query part.</li><li>Can be slow if reused many times in one query.</li><li>Can’t create indexes.</li></ul><h3>When to Use:</h3><ul><li>You need to simplify <strong>complex joins</strong> or <strong>nested queries</strong>.</li><li>You’re building <strong>recursive logic</strong>, like parent-child structures.</li></ul><h3>Conclusion</h3><p>Each of these tools — <strong>table variables</strong>, <strong>temp tables</strong>, <strong>global temp tables</strong>, and <strong>CTEs</strong> — has its strengths. Here’s how to pick the right one:</p><ul><li>Use <strong>table variables</strong> for quick, small data tasks.</li><li>Use <strong>temp tables</strong> when working with larger data or needing indexe</li><li>Use <strong>global temp tables</strong> if multiple users/sessions need access to the same temporary data.</li><li>Use <strong>CTEs</strong> to simplify queries, especially with recursion.</li></ul><p><strong>Happy Querying!</strong><br>Let me know in the comments: What’s your favourite use case for CTEs or temp tables?</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d65640218344" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[A Beginner’s Guide to Web API in C# and .NET — Components, Control Flow & Code Examples]]></title>
            <link>https://medium.com/@mohitgoyal2804_76807/a-beginners-guide-to-web-api-in-c-and-net-components-control-flow-code-examples-967715d3dd5f?source=rss-53655b2918a3------2</link>
            <guid isPermaLink="false">https://medium.com/p/967715d3dd5f</guid>
            <category><![CDATA[basics]]></category>
            <category><![CDATA[c-sharp-programming]]></category>
            <category><![CDATA[dotnet-core]]></category>
            <category><![CDATA[web-api-development]]></category>
            <category><![CDATA[dotnet]]></category>
            <dc:creator><![CDATA[Mohit Goyal]]></dc:creator>
            <pubDate>Wed, 07 May 2025 17:37:15 GMT</pubDate>
            <atom:updated>2025-05-07T17:37:15.469Z</atom:updated>
            <content:encoded><![CDATA[<h3>A Beginner’s Guide to Web API in C# and .NET — Components, Control Flow &amp; Code Examples</h3><p>Web APIs are the backbone of modern applications. Whether it’s mobile apps, web apps, or third-party integrations, APIs act as bridges to connect systems. In this blog, we’ll dive into <strong>how to build a Web API using C# and .NET</strong>, understanding its <strong>components, architecture, control flow</strong>, and the <strong>file structure</strong> involved.</p><p>Let’s start step-by-step.</p><h3>🧠 What is a Web API?</h3><p>A <strong>Web API</strong> is a set of HTTP endpoints (URLs) exposed by your backend server, allowing client apps to <strong>send and receive data</strong> using protocols like <strong>HTTP/HTTPS</strong>.</p><p>.NET makes this super easy using <strong>ASP.NET Core Web API</strong> framework.</p><h3>🛠️ Tools &amp; Tech Stack</h3><ul><li><strong>.NET 6/7/8 SDK</strong></li><li><strong>C# Language</strong></li><li><strong>Visual Studio / VS Code</strong></li></ul><h3>📁 Project Setup</h3><h3>✅ Step 1: Create Web API Project</h3><pre>dotnet new webapi -n MyFirstApi<br>cd MyFirstApi</pre><p>This creates a default API project with essential files.</p><h3>📂 Understanding the File Structure</h3><pre>MyFirstApi/<br>├── Controllers/<br>│   └── WeatherForecastController.cs<br>├── Program.cs<br>├── appsettings.json<br>├── Properties/<br>└── MyFirstApi.csproj</pre><h3>🔍 Explanation:</h3><ul><li><strong>Controllers/</strong>: Contains controller classes. These define your endpoints.</li><li><strong>Program.cs</strong>: Entry point; configures services and middleware.</li><li><strong>appsettings.json</strong>: Configuration file (e.g., connection strings).</li><li><strong>.csproj</strong>: Project metadata.</li></ul><h3>🧱 Building Blocks of Web API</h3><h3>1. Controller: Handles incoming HTTP requests.</h3><pre>[ApiController]<br>[Route(&quot;api/[controller]&quot;)]<br>public class ProductsController : ControllerBase<br>{<br>    [HttpGet]<br>    public IActionResult GetAll()<br>    {<br>        var products = new List&lt;string&gt; { &quot;Laptop&quot;, &quot;Phone&quot;, &quot;Tablet&quot; };<br>        return Ok(products);<br>    }<br>}</pre><h3>2. Routing: URL → Method mapping using [Route], [HttpGet], etc.</h3><h3>3. Dependency Injection: Inject services (like database, logging) via constructor.</h3><h3>4. Middleware: Components that handle requests/responses (e.g., logging, auth).</h3><h3>🧭 Control Flow: How a Request Is Processed</h3><pre>Client → Middleware Pipeline → Routing → Controller Action → Response</pre><ol><li>User sends a request to GET /api/products.</li><li>Middleware handles logging, authentication, etc.</li><li>Routing maps URL to ProductsController.GetAll.</li><li>Action is executed and response is returned.</li></ol><h3>✍️ Add a Custom Controller</h3><p>Let’s create a new controller to manage books:</p><pre>// Controllers/BooksController.cs<br>[ApiController]<br>[Route(&quot;api/[controller]&quot;)]<br>public class BooksController : ControllerBase<br>{<br>    private static List&lt;string&gt; books = new List&lt;string&gt;<br>    {<br>        &quot;Atomic Habits&quot;, &quot;Clean Code&quot;, &quot;The Pragmatic Programmer&quot;<br>    };<br><br>    [HttpGet]<br>    public IActionResult GetBooks() =&gt; Ok(books);<br><br>    [HttpPost]<br>    public IActionResult AddBook([FromBody] string newBook)<br>    {<br>        books.Add(newBook);<br>        return Created(&quot;&quot;, newBook);<br>    }<br>}</pre><p>Test these endpoints using <strong>Postman</strong> or Swagger UI (/swagger in browser).</p><h3>🛡️ Adding Model &amp; Validation</h3><p>Create a model:</p><pre>public class Book<br>{<br>    public int Id { get; set; }<br>    <br>    [Required]<br>    public string Title { get; set; }<br>}</pre><p>Update controller to accept Book model:</p><pre>[HttpPost]<br>public IActionResult AddBook([FromBody] Book book)<br>{<br>    if (!ModelState.IsValid)<br>        return BadRequest(ModelState);<br>    // Save logic...<br>    return Created(&quot;&quot;, book);<br>}</pre><h3>🧪 Testing the API</h3><p>Run your project:</p><pre>dotnet run</pre><p>Navigate to: <a href="https://localhost:5001/swagger">https://localhost:5001/swagger</a></p><p>You’ll see Swagger UI — a handy interface to test APIs.</p><h3>🧰 Dependency Injection Example</h3><p>Let’s inject a service:</p><pre>public interface IBookService<br>{<br>    List&lt;string&gt; GetBooks();<br>}<br><br>public class BookService : IBookService<br>{<br>    public List&lt;string&gt; GetBooks() =&gt; new() { &quot;Book A&quot;, &quot;Book B&quot; };<br>}</pre><p>Register in Program.cs:</p><pre>builder.Services.AddScoped&lt;IBookService, BookService&gt;();</pre><p>Use in controller:</p><pre>private readonly IBookService _bookService;<br>public BooksController(IBookService bookService) =&gt; _bookService = bookService;<br><br>[HttpGet(&quot;id&quot;)]<br>public IActionResult GetBooksFromService() =&gt; Ok(_bookService.GetBooks());</pre><h3>🧭 Program.cs — Behind the Scenes</h3><pre>var builder = WebApplication.CreateBuilder(args);<br>// Add services to container<br>builder.Services.AddControllers();<br>builder.Services.AddEndpointsApiExplorer();<br>builder.Services.AddSwaggerGen();<br>var app = builder.Build();<br>// Middleware pipeline<br>if (app.Environment.IsDevelopment())<br>{<br>    app.UseSwagger();<br>    app.UseSwaggerUI();<br>}<br>app.UseHttpsRedirection();<br>app.UseAuthorization();<br>app.MapControllers();<br>app.Run();</pre><h3>✅ Final Tips</h3><ul><li>Use <strong>DTOs</strong> to separate domain and exposed models.</li><li>Use <strong>AutoMapper</strong> for clean mapping.</li><li>Add <strong>logging</strong>, <strong>exception handling middleware</strong>, and <strong>filters</strong> for real-world apps.</li><li>Use <strong>Entity Framework</strong> to connect to a real database.</li></ul><h3>🙌 Let’s Connect!</h3><p>Hope this gave you a solid foundation to start building <strong>Web APIs with .NET</strong>. Want more examples with <strong>authentication</strong>, <strong>database</strong>, or <strong>unit testing</strong>? Comment below or connect with me for the next part.</p><p>Happy Coding! 💻✨</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=967715d3dd5f" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>