<?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 CodeWithIndu on Medium]]></title>
        <description><![CDATA[Stories by CodeWithIndu on Medium]]></description>
        <link>https://medium.com/@induthakur993?source=rss-7b4b5356de0e------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*p6sOZN1qUM1nFHUZsbjkRQ.png</url>
            <title>Stories by CodeWithIndu on Medium</title>
            <link>https://medium.com/@induthakur993?source=rss-7b4b5356de0e------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 12:17:39 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@induthakur993/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[ What is a DTO?]]></title>
            <link>https://medium.com/@induthakur993/what-is-a-dto-41c1df3c3b58?source=rss-7b4b5356de0e------2</link>
            <guid isPermaLink="false">https://medium.com/p/41c1df3c3b58</guid>
            <dc:creator><![CDATA[CodeWithIndu]]></dc:creator>
            <pubDate>Tue, 18 Nov 2025 15:07:58 GMT</pubDate>
            <atom:updated>2025-11-18T15:07:58.046Z</atom:updated>
            <content:encoded><![CDATA[<p>DTO stands for <strong>Data Transfer Object</strong>.</p><p>It is a <strong>simple class</strong> that is used to <strong>send data</strong> from one place to another.</p><p>That’s it.<br> No logic, no calculations, no database code — just <strong>data</strong>.</p><h3>🚫 Without DTO → Big Problems</h3><p>If you return your <strong>database model</strong> directly in API responses:</p><p>❌ You might expose unnecessary columns<br> (e.g., password, internal IDs, flags)</p><p>❌ You tightly couple your database with your UI<br> (If DB changes → UI breaks)</p><p>❌ Security issues<br> (Hackers may see data they shouldn’t)</p><p>❌ Harder to maintain<br> (API lifetime becomes dependent on database structure)</p><p>DTO fixes all these problems.</p><p>DTO allows you to:</p><p>✔ Send <strong>only required data</strong><br> ✔ Hide sensitive information<br> ✔ Control what goes in the request and response<br> ✔ Make your API <strong>clean</strong> and <strong>stable</strong><br> ✔ Completely separate your UI from your database</p><h3>🧠 Example You Will Never Forget</h3><p>Let’s say you have a database model:</p><pre>public class Student<br>{<br>    public int Id { get; set; }<br>    public string Name { get; set; }<br>    public string Email { get; set; }<br>    public string PasswordHash { get; set; }<br>    public DateTime CreatedDate { get; set; }<br>}</pre><p>Should you send this to your frontend?</p><p>❌ No — it contains password &amp; internal data.</p><p>Instead, you create a <strong>StudentDTO</strong>:</p><pre>public class StudentDto<br>{<br>    public int Id { get; set; }<br>    public string Name { get; set; }<br>}</pre><p>Now your <strong>API will return only what the UI needs</strong>, safely.</p><h3>🛠 Example Controller Without DTO (BAD)</h3><pre>[HttpGet]<br>public Student GetStudent()<br>{<br>    return _context.Students.First();<br>}</pre><p>Frontend receives EVERYTHING — including password hash.<br> Very risky.</p><h3>🛠 Example Controller With DTO (GOOD)</h3><pre>[HttpGet]<br>public StudentDto GetStudent()<br>{<br>    var s = _context.Students.First();</pre><pre>    return new StudentDto<br>    {<br>        Id = s.Id,<br>        Name = s.Name<br>    };<br>}</pre><pre>Clean. Secure. Professional.</pre><p>1️⃣ When the database changes, DTO doesn’t have to change<br> → <strong>frontend never breaks</strong></p><p>2️⃣ It improves <strong>security</strong></p><p>3️⃣ It supports <strong>clean architecture</strong></p><p>4️⃣ Helps in <strong>API versioning</strong>, and <strong>large projects</strong></p><p>5️⃣ Makes your system <strong>future-proof</strong></p><h3>🧩 Memory Trick</h3><p>👉 <strong>Database Model = Kitchen Plate</strong><br> 👉 <strong>DTO = Delivery Box</strong></p><p>We never send the kitchen plate directly to the customer.<br> We always send the delivery box.</p><p>This one comparison will stick with you forever.</p><blockquote><strong><em>DTO is a simple, clean object created only to transfer data safely without exposing your actual database structure.</em></strong></blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=41c1df3c3b58" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What is Async and Await in C#?]]></title>
            <link>https://medium.com/@induthakur993/what-is-async-and-await-in-c-a625dc581297?source=rss-7b4b5356de0e------2</link>
            <guid isPermaLink="false">https://medium.com/p/a625dc581297</guid>
            <dc:creator><![CDATA[CodeWithIndu]]></dc:creator>
            <pubDate>Thu, 13 Nov 2025 15:32:04 GMT</pubDate>
            <atom:updated>2025-11-13T15:32:04.721Z</atom:updated>
            <content:encoded><![CDATA[<h3>👉</h3><p><strong>async and </strong><strong>await</strong> are used in C# to make your program <strong>non-blocking</strong> — meaning your app can do <strong>multiple things at once</strong> without freezing.</p><ul><li><strong>async keyword</strong>:<br> Marks a method as <em>asynchronous</em>, meaning it can contain await statements.</li><li><strong>await keyword</strong>:<br> <em>Pauses</em> the execution of the method until the awaited task is completed — <strong>without blocking</strong> the main thread.</li></ul><h3>🧩 Example Without Async/Await (Blocking Code)</h3><pre> public IEnumerable&lt;Product&gt; GetAll()<br> {<br>     return _context.Products.ToList();<br> }<br><br> public Product GetById(int id)<br> {<br>     return _context.Products.FirstOrDefault(p =&gt; p.Id == id);<br> }</pre><p>⏳ Here, the <strong>thread is blocked</strong> for 5 seconds — <br> your UI will <strong>freeze</strong> during this time.</p><h3>⚡ Example With Async/Await (Non-Blocking Code)</h3><pre>public async Task&lt;Student&gt; UpdateAsync(Student student)<br>{<br>    _context.Students.Update(student);<br>    await _context.SaveChangesAsync();<br>    return student;<br>}<br><br>public async Task&lt;bool&gt; DeleteAsync(int id)<br>{<br>    var student = await _context.Students.FindAsync(id);<br>    if (student == null)<br>        return false;<br><br>    _context.Students.Remove(student);<br>    await _context.SaveChangesAsync();<br>    return true;<br>}</pre><p>✅ The difference:</p><ul><li>While the app <strong>waits for data</strong>, the <strong>main thread is free</strong> to handle other requests.</li><li>When the data arrives, execution <strong>resumes automatically</strong>.</li></ul><h3>Example:</h3><p>Imagine your computer as a restaurant:</p><ul><li><strong>Threads</strong> are your waiters (they serve customers).</li><li><strong>Tasks</strong> are the orders they serve.</li><li><strong>Async/Await</strong> ensures that while one order is cooking, the waiter serves other customers.</li></ul><p>Without async, the waiter stands still doing nothing until the order is ready. 😴<br> With async, the waiter serves other tables in the meantime. 🚀</p><h3>🧠 Why Do We Use Async and Await?</h3><p>✅ To <strong>avoid blocking</strong> the main thread (UI won’t freeze).<br> ✅ To <strong>improve performance</strong> by handling multiple requests at once.<br> ✅ To <strong>write cleaner async code</strong> (instead of complex callbacks).<br> ✅ To <strong>use resources efficiently</strong> (threads don’t stay idle).</p><h3>✨</h3><ul><li><strong>Thread:</strong> A worker that executes code.</li><li><strong>Task:</strong> A unit of work running on a thread.</li><li><strong>Async/Await:</strong> A smart way to run tasks <em>without blocking</em> your application.</li><li><strong>Use Case:</strong> Best for I/O operations — API calls, DB access, file I/O, etc.</li><li><strong>Benefit:</strong> Improves performance, responsiveness, and user experience.</li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a625dc581297" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ What is Repository Pattern?]]></title>
            <link>https://medium.com/@induthakur993/what-is-repository-pattern-5a0d546369b8?source=rss-7b4b5356de0e------2</link>
            <guid isPermaLink="false">https://medium.com/p/5a0d546369b8</guid>
            <category><![CDATA[repository-pattern]]></category>
            <dc:creator><![CDATA[CodeWithIndu]]></dc:creator>
            <pubDate>Wed, 12 Nov 2025 14:50:42 GMT</pubDate>
            <atom:updated>2025-11-12T15:12:49.826Z</atom:updated>
            <content:encoded><![CDATA[<ul><li>The <strong>Repository Pattern</strong> is a <strong>design pattern</strong> that separates <strong>data access logic</strong> (like database operations) from the <strong>business logic</strong> of your application.</li><li>It acts as a <strong>middle layer</strong> between your <strong>controller/service layer</strong> and <strong>data layer (like Entity Framework or ADO.NET)</strong>.</li><li>The goal is to <strong>achieve clean code</strong>, <strong>easy maintenance</strong>, and <strong>loose coupling</strong> between application layers.</li><li>It helps to <strong>centralize all database-related operations</strong> in one place (the repository).</li><li>It helps in writing <strong>clean, testable, and maintainable</strong> code</li></ul><h3>⚙️ Why We Use Repository Pattern</h3><ol><li>✅ To keep <strong>Controller and Service layers clean</strong> — no direct DB queries inside them.</li><li>✅ To achieve <strong>separation of concerns</strong> — data logic is separate from business logic.</li><li>✅ To make the code <strong>easier to maintain and test</strong>.</li><li>✅ To support <strong>Unit Testing</strong> easily (you can mock the repository).</li><li>✅ To <strong>reduce duplicate database code</strong> (CRUD operations are reusable).</li></ol><h3>🧩 Example Structure</h3><pre>Controller  →  Service  →  IService →  DbContext (EF Core)</pre><h3>💻 Example Code</h3><p><strong>1️⃣ Repository Interface</strong></p><pre>public interface IProductService<br>{<br>    IEnumerable&lt;Product&gt; GetAll();<br>    Product GetById(int id);<br>    void Add(Product product);<br>    void Update(Product product);<br>    void Delete(int id);<br>}</pre><p><strong>2️⃣ Repository Implementation</strong></p><pre> public class ProductService: IProductService<br> {<br>     private readonly ApplicationDbContext _context;<br><br>     </pre><pre>public ProductService(ApplicationDbContext context)<br>     {<br>         _context = context;<br>     }<br>public IEnumerable&lt;Product&gt; GetAll()<br>{<br>    return _context.Products.ToList();<br>}<br><br>public Product GetById(int id)<br>{<br>    return _context.Products.FirstOrDefault(p =&gt; p.Id == id);<br>}<br><br>public void Add(Product product)<br>{<br>    _context.Products.Add(product);<br>    _context.SaveChanges();<br>}<br><br> public void Update(Product product)<br> {<br>     var existing = _context.Products.FirstOrDefault(x =&gt; x.Id == product.Id);<br><br>     if (existing != null)<br>     {<br>         existing.Name = product.Name;<br>         existing.Price = product.Price;<br>         _context.SaveChanges(); <br>     }<br> }<br> public void Delete(int id)<br> {<br>     var product = _context.Products.Find(id);<br>     if (product != null)<br>     {<br>         _context.Products.Remove(product);<br>         _context.SaveChanges();<br>     }<br> }</pre><ul><li>Controller → calls ProductService</li><li>ProductService → calls ProductRepository</li><li>ProductRepository → interacts with ApplicationDbContext (EF Core) to perform DB operations</li></ul><h3>🧾 Benefits</h3><ul><li>🧩 Separation of concerns</li><li>🔁 Reusability</li><li>🧪 Easy Unit Testing</li><li>🔒 Encapsulates data access logic</li><li>💡 Maintainable and scalable architecture</li></ul><h3>📍 In Short</h3><blockquote><em>The Repository Pattern works as a </em><strong><em>bridge</em></strong><em> between your </em><strong><em>business logic</em></strong><em> and </em><strong><em>database</em></strong><em>, helping you write </em><strong><em>clean, testable, and maintainable</em></strong><em> code.</em></blockquote><h3>🧠 Repository Pattern + SOLID Principles + OOP Concepts</h3><h3>✅ 1. SOLID Principle: Single Responsibility Principle (SRP)</h3><ul><li><strong>Meaning:</strong><br> A class should have <strong>only one reason to change</strong> — it should do only one job.</li><li><strong>How Repository Pattern applies:</strong></li><li>The <strong>repository</strong> is only responsible for <strong>data access logic</strong> (CRUD operations).</li><li>The <strong>service</strong> handles <strong>business logic</strong>.</li><li>The <strong>controller</strong> handles <strong>API endpoints / UI logic</strong>.</li></ul><p>👉 So each layer (Controller, Service, Repository) has <strong>a single responsibility</strong>.</p><p><strong>Example:</strong></p><pre>// Repository → Only Database Logic<br>// Service → Only Business Logic<br>// Controller → Only Request/Response Logic</pre><p>✅ This clearly follows <strong>SRP</strong>.</p><h3>✅ 2. SOLID Principle: Dependency Inversion Principle (DIP)</h3><ul><li><strong>Meaning:</strong><br> High-level modules should <strong>not depend on low-level modules</strong>; both should depend on <strong>abstractions</strong> (interfaces).</li><li><strong>How Repository Pattern applies:</strong></li><li>Controller depends on IProductService, not ProductService directly.</li><li>Service depends on IRepository&lt;Product&gt;, not Repository&lt;Product&gt; directly.</li></ul><p>👉 We inject interfaces, not concrete classes — this is <strong>Dependency Inversion</strong>.</p><p><strong>Example:</strong></p><pre>public class ProductService : IProductService<br>{<br>    private readonly IRepository&lt;Product&gt; _repository;</pre><pre>    public ProductService(IRepository&lt;Product&gt; repository)<br>    {<br>        _repository = repository;  // 👈 Dependency on abstraction<br>    }<br>}</pre><p>✅ This follows <strong>DIP</strong> using <strong>Dependency Injection (DI)</strong>.</p><h3>✅ 3. OOP Concept: Abstraction</h3><ul><li>The repository interface (IRepository&lt;T&gt;) hides <strong>complex data access logic</strong> behind simple method names like GetAll(), Add(), Update().</li><li>The user of the repository (like ProductService) doesn’t need to know <strong>how</strong> data is fetched — only <strong>what</strong> methods to call.</li></ul><p>✅ This is a perfect example of <strong>Abstraction</strong>.</p><h3>✅ 4. OOP Concept: Encapsulation</h3><ul><li>Repository pattern encapsulates all the <strong>data access logic</strong> (EF Core, SQL queries) inside a single class.</li><li>The rest of the application doesn’t need to know or touch database code.</li></ul><p>✅ This shows <strong>Encapsulation</strong> — data access logic is hidden behind a clean interface.</p><h3>✅ 5. Optional: Interface Segregation Principle (ISP)</h3><ul><li>We can create <strong>specific repositories</strong> like IProductRepository, ICategoryRepository instead of one huge interface.</li><li>This avoids forcing classes to implement methods they don’t need.</li></ul><p>✅ This supports <strong>ISP</strong>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5a0d546369b8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ Backend (ASP.NET Core Web API)]]></title>
            <link>https://medium.com/@induthakur993/backend-asp-net-core-web-api-58ed9a129a7a?source=rss-7b4b5356de0e------2</link>
            <guid isPermaLink="false">https://medium.com/p/58ed9a129a7a</guid>
            <dc:creator><![CDATA[CodeWithIndu]]></dc:creator>
            <pubDate>Fri, 26 Sep 2025 06:58:28 GMT</pubDate>
            <atom:updated>2025-09-26T06:58:28.170Z</atom:updated>
            <content:encoded><![CDATA[<p>🔹 Backend (ASP.NET Core Web API)</p><p>1. Create a User entity</p><p>public class User<br>{<br> public int Id { get; set; }<br> public string Username { get; set; }<br> public string Password { get; set; } // ⚠️ Store hashed password in real apps!<br>}</p><p>— -</p><p>2. DbContext</p><p>public class AppDbContext : DbContext<br>{<br> public AppDbContext(DbContextOptions&lt;AppDbContext&gt; options) : base(options) { }</p><p>public DbSet&lt;User&gt; Users { get; set; }<br>}</p><p>— -</p><p>3. appsettings.json (JWT key)</p><p>“Jwt”: {<br> “Key”: “my_super_secret_key_12345”,<br> “Issuer”: “MyApp”,<br> “Audience”: “MyAppAudience”,<br> “ExpireMinutes”: 60<br>}</p><p>— -</p><p>4. Program.cs (minimal setup)</p><p>var builder = WebApplication.CreateBuilder(args);</p><p>builder.Services.AddDbContext&lt;AppDbContext&gt;(options =&gt;<br> options.UseInMemoryDatabase(“MyDb”)); // simple in-memory DB</p><p>builder.Services.AddAuthentication(JwtBearerDefaults.AuthenticationScheme)<br>.AddJwtBearer(options =&gt;<br>{<br> var jwt = builder.Configuration.GetSection(“Jwt”);<br> options.TokenValidationParameters = new TokenValidationParameters<br> {<br> ValidateIssuer = true,<br> ValidateAudience = true,<br> ValidateIssuerSigningKey = true,<br> ValidIssuer = jwt[“Issuer”],<br> ValidAudience = jwt[“Audience”],<br> IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(jwt[“Key”]))<br> };<br>});</p><p>builder.Services.AddControllers();<br>var app = builder.Build();</p><p>app.UseAuthentication();<br>app.UseAuthorization();<br>app.MapControllers();<br>app.Run();</p><p>— -</p><p>5. AuthController</p><p>[ApiController]<br>[Route(“api/[controller]”)]<br>public class AuthController : ControllerBase<br>{<br> private readonly AppDbContext _db;<br> private readonly IConfiguration _config;</p><p>public AuthController(AppDbContext db, IConfiguration config)<br> {<br> _db = db;<br> _config = config;<br> }</p><p>[HttpPost(“register”)]<br> public IActionResult Register(User dto)<br> {<br> if (_db.Users.Any(u =&gt; u.Username == dto.Username))<br> return BadRequest(“Username already exists”);</p><p>_db.Users.Add(dto); // ⚠️ Save plain password (demo only!)<br> _db.SaveChanges();<br> return Ok(“User registered”);<br> }</p><p>[HttpPost(“login”)]<br> public IActionResult Login(User dto)<br> {<br> var user = _db.Users.FirstOrDefault(u =&gt; <br> u.Username == dto.Username &amp;&amp; u.Password == dto.Password);</p><p>if (user == null) return Unauthorized(“Invalid credentials”);</p><p>var token = GenerateJwtToken(user);<br> return Ok(new { token });<br> }</p><p>[Authorize]<br> [HttpGet(“me”)]<br> public IActionResult Me() =&gt; Ok(User.Identity.Name);</p><p>private string GenerateJwtToken(User user)<br> {<br> var jwt = _config.GetSection(“Jwt”);<br> var key = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(jwt[“Key”]));<br> var creds = new SigningCredentials(key, SecurityAlgorithms.HmacSha256);</p><p>var claims = new[]<br> {<br> new Claim(ClaimTypes.Name, user.Username),<br> new Claim(“uid”, user.Id.ToString())<br> };</p><p>var token = new JwtSecurityToken(<br> issuer: jwt[“Issuer”],<br> audience: jwt[“Audience”],<br> claims: claims,<br> expires: DateTime.UtcNow.AddMinutes(int.Parse(jwt[“ExpireMinutes”])),<br> signingCredentials: creds<br> );</p><p>return new JwtSecurityTokenHandler().WriteToken(token);<br> }<br>}</p><p>— -</p><p>🔹 Frontend (Angular)</p><p>1. AuthService</p><p><a href="http://twitter.com/Injectable">@Injectable</a>({ providedIn: ‘root’ })<br>export class AuthService {<br> private apiUrl = ‘<a href="https://localhost:5001/api/auth&#39;">https://localhost:5001/api/auth&#39;</a>;</p><p>constructor(private http: HttpClient) {}</p><p>register(username: string, password: string) {<br> return this.http.post(`${this.apiUrl}/register`, { username, password });<br> }</p><p>login(username: string, password: string) {<br> return this.http.post&lt;{token: string}&gt;(`${this.apiUrl}/login`, { username, password });<br> }</p><p>setToken(token: string) { localStorage.setItem(‘jwt’, token); }<br> getToken() { return localStorage.getItem(‘jwt’); }<br>}</p><p>— -</p><p>2. Simple Register/Login Component</p><p><a href="http://twitter.com/Component">@Component</a>({<br> selector: ‘app-auth’,<br> template: `<br> &lt;h2&gt;Register&lt;/h2&gt;<br> &lt;input [(ngModel)]=”username” placeholder=”Username”/&gt;<br> &lt;input [(ngModel)]=”password” placeholder=”Password” type=”password”/&gt;<br> &lt;button (click)=”register()”&gt;Register&lt;/button&gt;</p><p>&lt;h2&gt;Login&lt;/h2&gt;<br> &lt;button (click)=”login()”&gt;Login&lt;/button&gt;<br> `<br>})<br>export class AuthComponent {<br> username = ‘’;<br> password = ‘’;</p><p>constructor(private auth: AuthService) {}</p><p>register() {<br> this.auth.register(this.username, this.password).subscribe(res =&gt; alert(‘Registered!’));<br> }</p><p>login() {<br> this.auth.login(this.username, this.password).subscribe(res =&gt; {<br> this.auth.setToken(res.token);<br> alert(‘Logged in!’);<br> });<br> }<br>}</p><p>— -</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=58ed9a129a7a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ Method Overloading in C#: The Power of Writing Flexible Methods]]></title>
            <link>https://medium.com/@induthakur993/method-overloading-in-c-the-power-of-writing-flexible-methods-3c0365d6a101?source=rss-7b4b5356de0e------2</link>
            <guid isPermaLink="false">https://medium.com/p/3c0365d6a101</guid>
            <dc:creator><![CDATA[CodeWithIndu]]></dc:creator>
            <pubDate>Thu, 25 Sep 2025 23:39:45 GMT</pubDate>
            <atom:updated>2025-09-25T23:39:45.931Z</atom:updated>
            <content:encoded><![CDATA[<h3>📖 Definition</h3><p><strong>Method Overloading</strong> in C# is the ability to create <strong>multiple methods with the same name</strong> but with <strong>different parameter lists</strong> (number, type, or order of parameters).<br> 👉 It makes code more <strong>readable</strong>, <strong>flexible</strong>, and <strong>easy to use</strong> without inventing new method names.</p><h3>📝 Explanation with Example</h3><p>Let’s say you want to create an Add method. Sometimes you want to add <strong>two numbers</strong>, sometimes <strong>three numbers</strong>, and sometimes even <strong>strings</strong> (concatenation). Instead of writing AddTwo, AddThree, AddStrings, you can just use <strong>method overloading</strong>.</p><h3>Example in C#</h3><pre>using System;</pre><pre>class Calculator<br>{<br>    // Add two integers<br>    public int Add(int a, int b)<br>    {<br>        return a + b;<br>    }</pre><pre>    // Add three integers<br>    public int Add(int a, int b, int c)<br>    {<br>        return a + b + c;<br>    }</pre><pre>    // Add two doubles<br>    public double Add(double a, double b)<br>    {<br>        return a + b;<br>    }</pre><pre>    // Add two strings (concatenate)<br>    public string Add(string a, string b)<br>    {<br>        return a + b;<br>    }<br>}</pre><pre>class Program<br>{<br>    static void Main()<br>    {<br>        Calculator calc = new Calculator();</pre><pre>        Console.WriteLine(calc.Add(2, 3));         // 5<br>        Console.WriteLine(calc.Add(2, 3, 4));      // 9<br>        Console.WriteLine(calc.Add(2.5, 3.1));     // 5.6<br>        Console.WriteLine(calc.Add(&quot;Hi&quot;, &quot; User&quot;)); // Hi User<br>    }<br>}</pre><h3>🌍 Real-world Analogy</h3><p>Think about a <strong>Restaurant Menu</strong> 🍽️</p><ul><li>If you order “Pizza”, the waiter asks: <em>Small, Medium, or Large?</em></li><li>The action is the same: <em>Serve Pizza</em>, but the <strong>parameters</strong> (size) are different.</li></ul><p>Similarly, in programming:</p><ul><li>Add(int, int) → Adding two integers</li><li>Add(double, double) → Adding decimals</li><li>Add(string, string) → Adding (joining) strings</li></ul><p>Same <strong>method name</strong>, different <strong>parameters</strong> = Overloading. ✅</p><h3>🚀 Why Do We Need Method Overloading?</h3><ul><li><strong>Readability:</strong> One method name for related actions.</li><li><strong>Flexibility:</strong> Handle different input types.</li><li><strong>Clean Code:</strong> Avoids unnecessary names like AddInt, AddDouble.</li><li><strong>Interview Tip:</strong> Overloading happens at <strong>compile-time</strong> (also called <strong>Compile-Time Polymorphism</strong>).</li></ul><h3>⚡ Quick Facts for Interview</h3><ul><li>You <strong>cannot</strong> overload a method by just changing the return type.</li><li>Overloading works by changing <strong>number, type, or order</strong> of parameters.</li><li>Common in .NET methods like Console.WriteLine() (you can pass int, double, string, object, etc.).</li></ul><p>✅ <strong>In short:</strong> Method Overloading allows us to reuse the same method name for similar operations, making code clean, flexible, and interview-ready.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3c0365d6a101" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[SQL Tutorial: How to Find Duplicate Rows in a Table (Step-by-Step Guide)]]></title>
            <link>https://medium.com/@induthakur993/sql-tutorial-how-to-find-duplicate-rows-in-a-table-step-by-step-guide-6364aab4dfd6?source=rss-7b4b5356de0e------2</link>
            <guid isPermaLink="false">https://medium.com/p/6364aab4dfd6</guid>
            <dc:creator><![CDATA[CodeWithIndu]]></dc:creator>
            <pubDate>Sat, 20 Sep 2025 15:17:08 GMT</pubDate>
            <atom:updated>2025-09-20T15:17:08.569Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>how to find duplicate rows</strong> in a table using SQL.</p><p>📊 <strong>Example Table: Employees</strong></p><pre>| Id  | Name   | Salary  |<br>|:---:|:------|-------:|<br>| 1   | Amit   | 50000  |<br>| 2   | Amit   | 60000  |<br>| 3   | Neha   | 70000  |<br>| 4   | Priya  | 80000  |<br>| 5   | Karan  | 60000  |<br>| 6   | Simran | 90000  |<br>| 7   | Rahul  | 75000  |<br>| 8   | John   | 50000  |</pre><p>🪜 <strong>Step-by-Step Flow</strong></p><h3>🔹 Step 1: Check which names are duplicated</h3><pre>SELECT Name, COUNT(*) AS DuplicateCount<br>FROM Employees<br>GROUP BY Name<br>HAVING COUNT(*) &gt; 1;</pre><p><strong>Explanation</strong></p><ul><li>GROUP BY Name groups all rows with the same name.</li><li>COUNT(*) counts how many rows are in each group.</li><li>HAVING COUNT(*) &gt; 1 filters only groups with duplicates.</li></ul><p><strong>Expected Output:</strong></p><pre>Name   | DuplicateCount<br>-------+---------------<br>Amit   | 2<br></pre><h3>🔹 Step 2: Find duplicates across multiple columns (Name + Salary)</h3><pre>SELECT Name, Salary, COUNT(*) AS DuplicateCount<br>FROM Employees<br>GROUP BY Name, Salary<br>HAVING COUNT(*) &gt; 1;</pre><p>✅ Use this if duplicates should be identified by <strong>both name and salary</strong>.</p><p>🧠 <strong>Memory Trick:</strong><br> Think of GROUP BY as putting similar names in a box. HAVING &gt;1 lets you pick only boxes that have more than 1 item.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6364aab4dfd6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What is a Join in SQL?]]></title>
            <link>https://medium.com/@induthakur993/what-is-a-join-in-sql-af0851ab8220?source=rss-7b4b5356de0e------2</link>
            <guid isPermaLink="false">https://medium.com/p/af0851ab8220</guid>
            <dc:creator><![CDATA[CodeWithIndu]]></dc:creator>
            <pubDate>Mon, 15 Sep 2025 14:17:39 GMT</pubDate>
            <atom:updated>2025-09-21T02:47:06.921Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>What is a Join in SQL?</strong></p><p>A <strong>JOIN</strong> in SQL is used to combine rows from two or more tables based on a related column, usually a <strong>Primary Key</strong> in one table and a <strong>Foreign Key</strong> in another.</p><ul><li>Example: Students have a ClassId that corresponds to a class in the Classes table.</li></ul><p>For Example</p><h4><strong>Student Table</strong></h4><pre>StudentId   Name    ClassId<br>---------   ----    -------<br>1           Ravi    101<br>2           Neha    102<br>3           Aman    NULL<br>4           Priya   104</pre><h4>Classes Table</h4><pre>ClassId   ClassName<br>-------   ---------<br>101       Science<br>102       Math<br>103       English</pre><h3>Types of Joins</h3><h4>1. INNER JOIN</h4><p>Returns only matching rows in both tables.</p><p>Only students with valid class IDs are shown.</p><p>Diagram:</p><figure><img alt="" src="https://cdn-images-1.medium.com/proxy/0*7LjwxFo5gBAADBlG" /></figure><h4>Syntax</h4><p>SELECT S.Name, c.ClassName<br>FROM Students S<br>INNER JOIN Classes c ON S.ClassId = c.ClassId;</p><h3>Example of Inner Join</h3><p><strong>Students Table</strong></p><pre>StudentId   Name    ClassId<br>---------   ----    -------<br>1           Ravi    101<br>2           Neha    102<br>3           Aman    NULL<br>4           Priya   104</pre><p><strong>Classes Table</strong></p><pre>ClassId   ClassName<br>-------   ---------<br>101       Science<br>102       Math<br>103       English</pre><h4>Result</h4><pre> Name   ClassName<br>-------   ---------<br>Ravi      Science<br>Neha      Math<br></pre><p>✅ Only students with a valid class appear. Students with NULL or unmatched ClassId are excluded.</p><h4>2. LEFT JOIN</h4><p>Return all records from the left table, and the matched records from the right table.</p><p>All students are included, class is NULL if no match.</p><p>Diagram:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/0*TwN2K4DbCEbTxTom.png" /></figure><p>SELECT S.Name, c.ClassName<br>FROM Students S<br>LEFT JOIN Classes c ON S.ClassId = c.ClassId;</p><h4>Example of Left Joins</h4><p><strong>Students Table</strong></p><pre>StudentId   Name    ClassId<br>---------   ----    -------<br>1           Ravi    101<br>2           Neha    102<br>3           Aman    NULL<br>4           Priya   104</pre><p><strong>Classes Table</strong></p><pre>ClassId   ClassName<br>-------   ---------<br>101       Science<br>102       Math<br>103       English</pre><h4>Result</h4><pre> Name     ClassName<br>-------   ---------<br>Ravi      Science<br>Neha      Math<br>Aman      Null<br>Priya     Null</pre><h4>3. RIGHT JOIN</h4><p>Returns all classes, even if no students are enrolled.</p><p>All classes are included , Student is NULL if no one joined.</p><p>Diagram:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/420/0*Zeuwr4Yg5-jZsso-" /></figure><p>SELECT S.Name, c.ClassName<br>FROM Students S<br>RIGHT JOIN Classes c ON S.ClassId = c.ClassId;</p><p>Example of Right Join</p><p><strong>Students Table</strong></p><pre>StudentId   Name    ClassId<br>---------   ----    -------<br>1           Ravi    101<br>2           Neha    102<br>3           Aman    NULL<br>4           Priya   104</pre><p><strong>Classes Table</strong></p><pre>ClassId   ClassName<br>-------   ---------<br>101       Science<br>102       Math<br>103       English</pre><h4>Result</h4><pre> Name      ClassName<br>-------   ---------<br>Ravi       Science<br>Neha       Math<br>Null       English</pre><h4>4. FULL JOIN</h4><p>Returns all students and all classes (matched or not).</p><p>Everything from both tables is included.</p><p>Diagram:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/0*iqXlhSC9vy_GD6Ks.png" /></figure><p>SELECT S.Name, c.ClassName<br>FROM Students S<br>FULL JOIN Classes c ON S.ClassId = c.ClassId;</p><p>For Example</p><p><strong>Students Table</strong></p><pre>StudentId   Name    ClassId<br>---------   ----    -------<br>1           Ravi    101<br>2           Neha    102<br>3           Aman    NULL<br>4           Priya   104</pre><p><strong>Classes Table</strong></p><pre>ClassId   ClassName<br>-------   ---------<br>101       Science<br>102       Math<br>103       English</pre><p>Result Full Join</p><pre> Name     ClassName<br>-------   ---------<br>Ravi       Science<br>Neha       Math<br>Aman       Null<br>Priya      Null<br>Null       English</pre><h4>5. CROSS JOIN</h4><p>Returns <strong>all possible combinations</strong> (Cartesian product).</p><p>4 Students × 3 Classes = 12 rows</p><p>Diagram:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/346/0*XLszC4OuN7WpYjek" /></figure><p>SELECT S.Name, c.ClassName<br>FROM Students S<br>CROSS JOIN Classes c;</p><h4>Example Cross Join</h4><p><strong>Students Table</strong></p><pre>StudentId   Name    ClassId<br>---------   ----    -------<br>1           Ravi    101<br>2           Neha    102<br>3           Aman    NULL<br>4           Priya   104</pre><p><strong>Classes Table</strong></p><pre>ClassId   ClassName<br>-------   ---------<br>101       Science<br>102       Math<br>103       English</pre><h4>CROSS JOIN Result</h4><pre>Name    ClassName<br>----    ---------<br>Ravi    Science<br>Ravi    Math<br>Ravi    English<br>Neha    Science<br>Neha    Math<br>Neha    English<br>Aman    Science<br>Aman    Math<br>Aman    English<br>Priya   Science<br>Priya   Math<br>Priya   English</pre><h4>6. SELF JOIN</h4><p>A <strong>Self join </strong>is when a table is joined with itself.</p><p>Useful for hierarchical or relational data (like Employee → Manager).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1000/0*d8syFmpiCZOFJ1xV.png" /></figure><p>SELECT e.EmpName AS Employee,<br> m.EmpName AS Manager<br>FROM Employees e<br>LEFT JOIN Employees m<br> ON e.ManagerId = m.EmpId;</p><h3>Example Table: Employees</h3><pre>EmpId   EmpName   ManagerId<br>-----   -------   ---------<br>1       Ravi      NULL<br>2       Neha      1<br>3       Aman      1<br>4       Priya     2<br>5       Karan     2</pre><h3>Result</h3><pre>Employee   Manager<br>--------   -------<br>Ravi       NULL<br>Neha       Ravi<br>Aman       Ravi<br>Priya      Neha<br>Karan      Neha</pre><h3>Key Takeaways</h3><ol><li><strong>INNER JOIN</strong> → Only matched rows</li><li><strong>LEFT JOIN</strong> → All from left + matches from right</li><li><strong>RIGHT JOIN</strong> → All from right + matches from left</li><li><strong>FULL JOIN</strong> → All rows from both tables</li><li><strong>CROSS JOIN</strong> → All combinations</li><li><strong>SELF JOIN</strong> → Join table with itself for hierarchical relations</li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=af0851ab8220" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[SQL Tutorial: How to Find the Second-Highest Salary Using OFFSET (Step-by-Step Guide)]]></title>
            <link>https://medium.com/@induthakur993/sql-tutorial-how-to-find-the-second-highest-salary-using-offset-step-by-step-guide-fbe5bfe46731?source=rss-7b4b5356de0e------2</link>
            <guid isPermaLink="false">https://medium.com/p/fbe5bfe46731</guid>
            <dc:creator><![CDATA[CodeWithIndu]]></dc:creator>
            <pubDate>Sat, 13 Sep 2025 17:29:49 GMT</pubDate>
            <atom:updated>2025-09-16T11:26:28.703Z</atom:updated>
            <content:encoded><![CDATA[<p>We want to find the <strong>2nd highest salary</strong> from a Employees table.</p><h3>📊 Example Table: Employees</h3><pre>| EmpID | Name  | Salary |<br>|-------|-------|--------|<br>| 1     | Ram   | 50000  |<br>| 2     | Sita  | 70000  |<br>| 3     | Mohan | 60000  |<br>| 4     | Riya  | 90000  |<br>| 5     | Neha  | 70000  |</pre><h3>🪜 Step-by-Step Flow</h3><p>👉 Imagine this as a flow:</p><h3>🔹 Step 1: Sort Salaries</h3><pre>SELECT DISTINCT Salary<br>FROM Employees<br>ORDER BY Salary DESC;</pre><ul><li>Collect all salaries</li><li>Remove duplicates using <strong>DISTINCT</strong></li><li>Sort them from <strong>highest → lowest</strong></li></ul><p>➡️ Result: 90000, 70000, 60000, 50000</p><h3>🔹 Step 2: Pick the 2nd Highest</h3><p>Now we want the salary that comes <strong>after the 1st highest</strong>.</p><p>✅ Best way = Use <strong>OFFSET</strong></p><pre>SELECT DISTINCT Salary<br>FROM Employees<br>ORDER BY Salary DESC<br>OFFSET 1 ROW FETCH NEXT 1 ROW ONLY;</pre><h3>🔍 Explanation</h3><ul><li><strong>OFFSET 1 ROW</strong> → Skip the 1st row (highest salary = 90000)</li><li><strong>FETCH NEXT 1 ROW ONLY</strong> → Select the next row (70000)</li></ul><p>👉 Output = <strong>70000</strong></p><h3>🧠 Easy Memory Trick</h3><p>Think of it like a <strong>race podium 🏆</strong>:</p><ul><li>1st place → Highest salary</li><li>2nd place → Second-highest salary</li><li>SQL OFFSET just tells the database: “Skip 1st place, give me 2nd.”</li></ul><h3>✅ Final Answer</h3><pre>SELECT DISTINCT Salary<br>FROM Employees<br>ORDER BY Salary DESC<br>OFFSET 1 ROW FETCH NEXT 1 ROW ONLY;</pre><p>This query will always return the <strong>second-highest salary</strong>.</p><h3>✅ To Find the Third Highest Salary:</h3><pre>SELECT DISTINCT Salary<br>FROM Employees<br>ORDER BY Salary DESC<br>OFFSET 2 ROWS FETCH NEXT 1 ROW ONLY;</pre><h3>🔍 Explanation:</h3><ul><li>ORDER BY Salary DESC → sorts salaries from highest to lowest.</li><li>OFFSET 2 ROWS → skips the top 2 unique salaries.</li><li>FETCH NEXT 1 ROW ONLY → returns the <strong>third</strong> unique highest salary.</li></ul><h3>💡 Tip:</h3><p>This approach only works <strong>correctly</strong> if:</p><ul><li>You use DISTINCT to avoid duplicate salary values.</li><li>There are <strong>at least 3 distinct salaries</strong> in the table.</li></ul><p>#SQL #InterviewQuestions #Database #SQLQueries #OFFSET #SecondHighestSalary #LearnSQL #CodingInterview</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=fbe5bfe46731" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ What is Abstraction?]]></title>
            <link>https://medium.com/@induthakur993/what-is-abstraction-7f11be9cf0aa?source=rss-7b4b5356de0e------2</link>
            <guid isPermaLink="false">https://medium.com/p/7f11be9cf0aa</guid>
            <dc:creator><![CDATA[CodeWithIndu]]></dc:creator>
            <pubDate>Fri, 12 Sep 2025 12:42:23 GMT</pubDate>
            <atom:updated>2025-09-12T13:46:01.192Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Definition:</strong><br> Abstraction is the process of <strong>hiding complex implementation details</strong> and showing only the <strong>essential features</strong> to the user. It <strong>focuses on “what” an object does, not “how” it does it</strong>.</p><p><strong>Key Points:</strong></p><ul><li>Achieved using <strong>abstract classes</strong> or <strong>interfaces</strong> in C#.</li><li>Helps in <strong>reducing complexity</strong> and <strong>improving code maintainability</strong>.</li><li>Makes <strong>code reusable, flexible, and secure</strong>.</li></ul><h3>💡 Real-World Examples of Abstraction</h3><ol><li><strong>Car Example:</strong></li></ol><ul><li>You press the <strong>Start</strong> button.</li><li>You <strong>don’t need to know how the engine works</strong>.</li><li>You <strong>just know the car starts</strong></li></ul><ol><li><strong>TV Remote Example</strong></li></ol><ul><li>Pressing buttons <strong>changes channels or volume</strong>.</li><li>You <strong>don’t need to understand the circuitry inside</strong>.</li></ul><h3>🖥️ C# Example of Abstraction</h3><p><strong>Using Abstract Class:</strong></p><pre>// Abstract class<br>abstract class Vehicle<br>{<br>    public abstract void Start(); // Abstract method<br>    public void Stop() // Concrete method<br>    {<br>        Console.WriteLine(&quot;Vehicle stopped.&quot;);<br>    }<br>}</pre><pre>// Derived class<br>class Car : Vehicle<br>{<br>    public override void Start()<br>    {<br>        Console.WriteLine(&quot;Car started.&quot;);<br>    }<br>}</pre><pre>class Program<br>{<br>    static void Main(string[] args)<br>    {<br>        Vehicle myCar = new Car();<br>        myCar.Start(); // Output: Car started<br>        myCar.Stop();  // Output: Vehicle stopped<br>    }<br>}</pre><p><strong>Using Interface:</strong></p><pre>interface IDevice<br>{<br>    void TurnOn();<br>    void TurnOff();<br>}</pre><pre>class TV : IDevice<br>{<br>    public void TurnOn()<br>    {<br>        Console.WriteLine(&quot;TV is ON&quot;);<br>    }<br>    public void TurnOff()<br>    {<br>        Console.WriteLine(&quot;TV is OFF&quot;);<br>    }<br>}</pre><p><strong>Key Point:</strong></p><ul><li>Users <strong>interact with </strong><strong>Start(), </strong><strong>TurnOn()</strong> methods without worrying about internal logic.</li></ul><h3>✅ Tips to Remember Abstraction</h3><ol><li><strong>Think “What, not How”</strong> — Focus on <strong>what the object does</strong>, not how it does it.</li><li><strong>Use Real-life Objects</strong> — Car, TV, Remote, ATM.</li><li><strong>Always mention abstract classes and interfaces</strong> in interviews</li><li><strong>Shortcut Trick:</strong></li></ol><ul><li><strong>Abstraction = Hide Details, Show Essentials</strong></li><li>Repeat it 3–5 times before interviews; it sticks in memory.</li></ul><p>💡 <strong>Interview Tip Example:</strong><br> <em>“Abstraction in C# allows hiding complex logic and exposing only necessary features. For example, when we drive a car, we just press the start button; we don’t need to know how the engine works.”</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7f11be9cf0aa" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What is Entity Framework?]]></title>
            <link>https://medium.com/@induthakur993/what-is-entity-framework-b29c0858e155?source=rss-7b4b5356de0e------2</link>
            <guid isPermaLink="false">https://medium.com/p/b29c0858e155</guid>
            <dc:creator><![CDATA[CodeWithIndu]]></dc:creator>
            <pubDate>Thu, 11 Sep 2025 03:26:09 GMT</pubDate>
            <atom:updated>2025-09-11T03:26:09.437Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*s5kO9dhZ2X69NBPV95Brpw.png" /></figure><ol><li><strong>Definition</strong> → Entity Framework (EF) is an <strong>Object Relational Mapper (ORM)</strong> for .NET.</li><li><strong>Purpose</strong> → Helps developers interact with databases using <strong>C# objects</strong> instead of writing raw SQL.</li><li><strong>Database Operations</strong> → Supports <strong>CRUD</strong> (Create, Read, Update, Delete) with minimal SQL.</li><li><strong>Approaches</strong> →</li></ol><ul><li><strong>Code First</strong> → Create classes first, then generate the database.</li><li><strong>Database First</strong> → Start with an existing database, EF creates models.</li><li><strong>Model First</strong> → Create model diagram, EF generates DB + code.</li></ul><ol><li><strong>LINQ Support</strong> → Use <strong>LINQ queries</strong> to fetch and manipulate data.</li><li><strong>Change Tracking</strong> → EF automatically tracks changes in objects and updates the database.</li><li><strong>Cross-Database</strong> → Works with SQL Server, MySQL, etc.</li><li><strong>Migration Support</strong> → Easily manage schema changes over time.</li><li><strong>Productivity</strong> → Reduces boilerplate SQL code and speeds up development.</li><li><strong>Real-World Example</strong> → Instead of writing</li></ol><pre>SELECT * FROM Employees WHERE Id=1;</pre><p>You can just write in C#:</p><pre>var emp = context.Employees.Find(1);<br></pre><p>This increases <strong>productivity</strong>, reduces boilerplate SQL, and makes the application more <strong>maintainable</strong> and <strong>database independent</strong>.</p><p>💡 <strong>Answer (Interview Ready):</strong></p><p>Entity Framework is an <strong>Object Relational Mapper (ORM)</strong> provided by Microsoft for .NET applications. It allows developers to interact with the database using <strong>C# objects</strong> instead of writing complex SQL queries.</p><p>With EF, we can easily perform <strong>CRUD operations</strong> (Create, Read, Update, Delete) using <strong>LINQ queries</strong>, and EF automatically converts them into SQL queries in the background.</p><p>It supports different approaches like <strong>Code First</strong>, <strong>Database First</strong>, and <strong>Model First</strong>, and also provides <strong>migrations</strong> to handle schema changes.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b29c0858e155" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>