<?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 sankar marimuthu on Medium]]></title>
        <description><![CDATA[Stories by sankar marimuthu on Medium]]></description>
        <link>https://medium.com/@sankarums?source=rss-9e0b6a412a2d------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*iCXofR_ekMD_93dqjb-ZQQ.jpeg</url>
            <title>Stories by sankar marimuthu on Medium</title>
            <link>https://medium.com/@sankarums?source=rss-9e0b6a412a2d------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 01:59:45 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@sankarums/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[9 Core JavaScript Ideas That Make You a Better Developer Instantly]]></title>
            <link>https://javascript.plainenglish.io/9-core-javascript-ideas-that-make-you-a-better-developer-instantly-54b916b93a35?source=rss-9e0b6a412a2d------2</link>
            <guid isPermaLink="false">https://medium.com/p/54b916b93a35</guid>
            <category><![CDATA[javascript-development]]></category>
            <category><![CDATA[learn-to-code-javascript]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[9-core-javascript]]></category>
            <dc:creator><![CDATA[sankar marimuthu]]></dc:creator>
            <pubDate>Fri, 12 Dec 2025 13:17:29 GMT</pubDate>
            <atom:updated>2025-12-12T17:55:11.408Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/800/1*RSCEKa6DRXnREdtQEbHvdg.jpeg" /></figure><p>You’ll often hear people say</p><p><strong>“If you want to reach a senior level in JavaScript, focus on the fundamentals.”</strong></p><p>That advice sounds good, but it can be hard to know what the “fundamentals” actually are.</p><p>In this post, I’ll break down <strong>nine core JavaScript concepts</strong> that senior engineers use all the time, both in interviews and in real production work.<br>I’ve included simple <strong>code examples</strong> to help these ideas make sense.</p><p>Let’s start with the part of JavaScript that decides when your code runs.</p><h4>1. The Event Loop: The Heartbeat of JavaScript</h4><p>JavaScript runs on a single thread. That means only one piece of code executes at a time.</p><p>So how does it deal with timers, network requests, promises, UI updates, and everything happening at once?</p><p>That’s where the <strong>event loop</strong> steps in.</p><p>JavaScript splits work into:</p><h4>Call Stack</h4><p>Runs normal synchronous code.<br><strong>Microtask Queue<br></strong>High-priority async tasks, mainly <strong>Promises</strong>.<br><strong>Macrotask Queue<br></strong>Lower-priority async tasks, such as <strong>setTimeout</strong>, setInterval, or I/O.</p><p>Process order:</p><ol><li>Empty the call stack</li><li>Run <em>all</em> microtasks</li><li>Run one macrotask</li><li>Update UI</li><li>Repeat</li></ol><h4>Example: Which console.log runs first?</h4><pre>console.log(1);<br><br>setTimeout(() =&gt; console.log(2), 0);<br><br>Promise.resolve().then(() =&gt; console.log(3));<br><br>console.log(4);</pre><p>Output:</p><pre>1<br>4<br>3<br>2</pre><p>Why?</p><ul><li>1 and 4 are synchronous -&gt;run immediately</li><li>Promise callback -&gt;microtask -&gt;runs before any macrotask</li><li>setTimeout -&gt; macrotask -&gt; runs last</li></ul><p>Master this ordering and many interview puzzles become easy.</p><h4>2. Execution Context: What JavaScript Creates Before Running a Function</h4><p>Every time JavaScript executes a function, it builds an <strong>execution context</strong>.</p><p>It contains:</p><ul><li>The function’s code</li><li>The value of this</li><li>The function parameters</li><li>All variables are accessible inside it</li></ul><p><strong>Example: See the execution context in action</strong></p><pre>function greet(name) {<br>  const message = &quot;Hello&quot;;<br>  console.log(message, name);<br>}<br><br>greet(&quot;Sankar&quot;);</pre><p>When greet() runs, JS creates a fresh execution context holding name and message.</p><h4>3. Scope &amp; The Scope Chain: What Code Can “See”</h4><p>JavaScript uses <strong>lexical scope, which means</strong> it depends on where the code is written, not where it’s called.</p><p>Every pair of { } creates a new scope.<br><strong>Example: Scope chain behavior</strong></p><pre>const x = 10;<br><br>function outer() {<br>  const y = 20;<br><br>  function inner() {<br>    const z = 30;<br>    console.log(x, y, z); // all accessible<br>  }<br><br>  inner();<br>}<br><br>outer();</pre><p>Inner functions can “look outward,” but outer functions cannot access inner variables.</p><h4>4. Closures: Functions That Remember</h4><p>A closure happens when a function keeps access to the variables from where it was created, <em>even after the outer function has finished running</em>.</p><pre>function counter() {<br>  let count = 0;<br><br>  return function () {<br>    count++;<br>    return count;<br>  }<br>}<br><br>const increment = counter();<br><br>console.log(increment()); // 1<br>console.log(increment()); // 2<br>console.log(increment()); // 3</pre><p>The inner function remembers count.<br>That “memory” is the closure.</p><h4>5. Garbage Collection: How JS Frees Memory.</h4><p>JavaScript automatically deletes data that is no longer referenced.</p><p>The engine performs a <strong>mark-and-sweep</strong> process:</p><ul><li>“Mark” everything that is still reachable</li><li>Remove everything that isn’t</li></ul><p>Closures can keep variables in memory longer than you might expect, so knowing this helps you avoid memory leaks.</p><p><strong>Example: Memory leak risk</strong></p><pre>function createLeak() {<br>  const largeArray = new Array(1000000).fill(&quot;X&quot;);<br><br>  return () =&gt; {<br>    console.log(&quot;Still here&quot;);<br>  };<br>}<br><br>const fn = createLeak(); // largeArray remains in memory</pre><p>Since the returned function could use <em>largeArray</em>, JavaScript keeps it in memory.</p><h4>6. The Callback Era: Before Promises Existed</h4><p>Before Promises, everything async relied on callbacks.</p><p><strong>Example: Nested callbacks (“callback hell”)</strong></p><pre>getUser(1, function (user) {<br>  getOrders(user.id, function (orders) {<br>    getDetails(orders[0], function (details) {<br>      console.log(&quot;Done!&quot;);<br>    });<br>  });<br>});</pre><p>This kind of code quickly becomes hard to manage.</p><h4>7. Promises: A Cleaner Way to Handle Async Work</h4><p>Promises solved callback hell by giving async code a clear lifecycle:</p><ul><li>pending</li><li>fulfilled</li><li>rejected</li></ul><p>The handlers for Promises (<em>then </em>and <em>catch</em>) run as <strong>microtasks</strong>.</p><p><strong>Example: Basic Promise</strong></p><pre>function fetchData() {<br>  return new Promise(resolve =&gt; {<br>    setTimeout(() =&gt; resolve(&quot;Data loaded&quot;), 1000);<br>  });<br>}<br><br>fetchData().then(result =&gt; console.log(result));</pre><h4><strong>8. Async/Await — The Modern Way</strong></h4><p>Async/await is built on top of Promises, but it lets you write async code as if it were synchronous.</p><p><strong>Example: Async/Await version</strong></p><pre>async function load() {<br>  const result = await fetchData();<br>  console.log(result);<br>}<br><br>load();</pre><p>It’s cleaner, easier to read, and very common in modern code.</p><h4>9. Generator Functions: Functions You Can Pause</h4><p>Generator functions can pause and resume, which makes them useful for things like:</p><ul><li>custom async flows</li><li>data streaming</li><li>implementing async/await under the hood</li></ul><p><strong>Example: Simple generator</strong></p><pre>function* numbers() {<br>  yield 1;<br>  yield 2;<br>  yield 3;<br>}<br><br>const iterator = numbers();<br><br>console.log(iterator.next().value); // 1<br>console.log(iterator.next().value); // 2<br>console.log(iterator.next().value); // 3</pre><p>Each .next() continues where the function paused.</p><p>If you truly understand:</p><ul><li>the event loop</li><li>execution context</li><li>scopes</li><li>closures</li><li>garbage collection</li><li>promises</li><li>async/await</li><li>generators</li></ul><p>you’ll write clearer code and debug faster.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=54b916b93a35" width="1" height="1" alt=""><hr><p><a href="https://javascript.plainenglish.io/9-core-javascript-ideas-that-make-you-a-better-developer-instantly-54b916b93a35">9 Core JavaScript Ideas That Make You a Better Developer Instantly</a> was originally published in <a href="https://javascript.plainenglish.io/">JavaScript in Plain English</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[5 Common Angular Mistakes That Slow Your App Down (and How Signals Fix Them)]]></title>
            <link>https://javascript.plainenglish.io/5-common-angular-mistakes-that-slow-your-app-down-and-how-signals-fix-them-eed1b343d066?source=rss-9e0b6a412a2d------2</link>
            <guid isPermaLink="false">https://medium.com/p/eed1b343d066</guid>
            <category><![CDATA[angular-performance]]></category>
            <category><![CDATA[boost-angular-performance]]></category>
            <category><![CDATA[signal]]></category>
            <category><![CDATA[angular]]></category>
            <dc:creator><![CDATA[sankar marimuthu]]></dc:creator>
            <pubDate>Sun, 16 Nov 2025 14:27:36 GMT</pubDate>
            <atom:updated>2025-11-16T16:40:28.123Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*30QwI9K_sIwWCQCYpsruag.png" /></figure><p>Hey Friends!</p><p>If your app feels sluggish, or your state management looks like a maze of nested subscriptions and streams, you’re definitely not alone. I’ve reviewed numerous Angular applications, and I keep encountering the <em>same</em> problems repeatedly.</p><p>Today, let’s break down <strong>five major Angular mistakes</strong> and explore how a modern, <strong>signal-based approach</strong> can fix them. Make sure to read until the end, as it can shape your future as an Angular developer.</p><h4>Mistake #1: Relying on “Change-Detect Everything”</h4><p>For years, Angular has relied on <strong><em>zone.js</em></strong> to detect changes. You click a button, an API response arrives, an event fires — <em>and Angular checks almost the entire component tree.</em></p><p>Even if the change happens in a tiny component, Angular basically says:</p><blockquote>“Let’s re-check everything… just in case.”</blockquote><p>This is like waking up an entire city because someone burnt a slice of toast.</p><p><strong>Signals change this.</strong></p><p>Imagine clicking “Add to Cart.”<br>A signal updates in a service.<br>Only the components that <strong>use</strong> that signal update.<br>Everything else stays untouched.</p><p>This precision means:</p><ul><li>No <strong><em>zone.js</em></strong> overhead</li><li>Smaller bundles</li><li>Faster apps</li><li>Predictable UI updates</li></ul><p>This is the direction Angular is headed. Ignoring signals today isn’t just a mistake — it’s choosing to fall behind.</p><h4>Mistake #2: Using Heavy State Management Tools for Simple Needs</h4><p>Many developers use <strong><em>BehaviorSubject </em></strong>for even the simplest shared values.</p><p>The old pattern:</p><ol><li>Create a <strong><em>BehaviorSubject</em></strong></li><li>Expose it as an observable</li><li>Use async pipes everywhere.</li><li>Call .<strong><em>next</em></strong>() for updates</li></ol><p>Sure, it works… but you’re mixing reactive streams just to update a single basic value.</p><p><strong>The signal-based approach is so much simpler:</strong></p><pre>// theme.service.ts<br>theme = signal(&#39;light&#39;);<br><br>// In component<br>const currentTheme = this.theme();</pre><p>No async pipe.<br>No subjects.<br>No .next().</p><p>And it fits naturally into Angular’s change detection model.</p><p>Cleaner, simpler, faster.</p><h4>Mistake #3: Complex Logic for Simple Derived Values</h4><p>Let’s say you want a full name based on two observables.</p><p>Old way:</p><ul><li>Use <strong><em>combineLatest</em></strong></li><li>Concatenate values</li><li>Keep an eye on redundant emissions</li><li>Use async pipes in the template</li></ul><p>Something like:</p><pre>fullName$ = combineLatest([firstName$, lastName$]).pipe(<br>  map(([f, l]) =&gt; `${f} ${l}`)<br>);</pre><p>It works, but now you’re maintaining a full observable chain just to join two strings.</p><p><strong>Signals fix this neatly:</strong></p><pre>firstName = signal(&#39;John&#39;);<br>lastName = signal(&#39;Doe&#39;);<br><br>fullName = computed(() =&gt; `${this.firstName()} ${this.lastName()}`);</pre><ul><li>Automatically cached</li><li>Recomputes only when dependencies change</li><li>No async pipe needed</li><li>Much more readable</li></ul><p>Angular handles the reactivity for you.</p><h4>Mistake #4: Putting Side Effects in the Wrong Places</h4><p>Side effects include things like:</p><ul><li>Logging</li><li>Writing to storage</li><li>Calling analytics APIs</li></ul><p>Many developers bury these inside nested subscriptions or the tap operator.</p><p>Sometimes you’ll even find a <strong>subscribe inside another subscribe</strong>, which is… well, dangerous.</p><p>A cleaner approach is using Angular’s effect():</p><pre>count = signal(0);<br><br>constructor() {<br>  effect(() =&gt; {<br>    localStorage.setItem(&#39;cartCount&#39;, this.count());<br>  });<br>}</pre><h4>Benefits:</h4><ul><li>Automatically tracks dependencies</li><li>Runs only when needed</li><li>Supports cleanup with <strong><em>onCleanup</em></strong>()</li><li>No manual unsubscribe required</li></ul><p>This organizes your app into clean, predictable layers.</p><h4>Mistake #5: Sticking to Old Habits “Because It Works”</h4><p>This one is the biggest.</p><p>Many Angular devs still cling to:</p><ul><li>Heavy <strong><em>RxJS </em></strong>patterns</li><li><strong><em>zone.js</em></strong>-driven change detection</li><li>Old component APIs</li></ul><p>But signals aren’t just another optional feature — they’re becoming the <strong>foundation of future Angular</strong>.</p><p>Signals enable:</p><ul><li>Zoneless Angular</li><li>Simpler components</li><li>Faster reactivity</li><li>Better developer experience</li><li>Easier future APIs (like forms)</li></ul><p>Every Angular app built today <strong>without</strong> signals is accumulating technical debt from the moment it’s created.</p><p>We explored how old habits can hurt performance, and how Angular signals offer clearer, faster, cleaner solutions.</p><p>Want to build modern, high-performance Angular apps?</p><ul><li>Start embracing signals.</li><li>Keep your logic simple.</li><li>Stop overusing streams where they’re not needed.</li><li>Place side effects in the right place.</li><li>Evolve with the framework.</li></ul><p>Angular is changing fast — and signals are at the heart of that change.</p><p>Happy coding, and keep building smarter!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=eed1b343d066" width="1" height="1" alt=""><hr><p><a href="https://javascript.plainenglish.io/5-common-angular-mistakes-that-slow-your-app-down-and-how-signals-fix-them-eed1b343d066">5 Common Angular Mistakes That Slow Your App Down (and How Signals Fix Them)</a> was originally published in <a href="https://javascript.plainenglish.io/">JavaScript in Plain English</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ASP.NET MVC vs ASP.NET Core MVC — What Should You Learn in 2025?]]></title>
            <link>https://medium.com/@sankarums/asp-net-mvc-vs-asp-net-core-mvc-what-should-you-learn-in-2025-9341d3ae08ea?source=rss-9e0b6a412a2d------2</link>
            <guid isPermaLink="false">https://medium.com/p/9341d3ae08ea</guid>
            <category><![CDATA[dotnet-core]]></category>
            <category><![CDATA[aspnet]]></category>
            <category><![CDATA[aspnet-mvc]]></category>
            <category><![CDATA[aspnetcoremvc]]></category>
            <category><![CDATA[mvc-vs-coremvc]]></category>
            <dc:creator><![CDATA[sankar marimuthu]]></dc:creator>
            <pubDate>Tue, 11 Nov 2025 10:00:20 GMT</pubDate>
            <atom:updated>2025-11-11T10:00:20.909Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WeHTX1SOq09nJDg87ObkJA.png" /></figure><h3>ASP.NET MVC vs ASP.NET Core MVC — What Should You Learn in 2025?</h3><p>If you’re just starting your .NET journey, you’ve probably faced this confusion:<br><strong>Should I learn ASP.NET MVC or ASP.NET Core MVC?</strong></p><p>You’re not alone! Many beginners and even intermediate developers often ask me this question. You might have seen job posts that say <em>“C# and ASP.NET MVC required,”</em> while others mention <em>“C# with ASP.NET Core MVC experience preferred.”</em></p><p>So what’s the real difference? Which one gives you better career growth? And most importantly, <strong>what should you focus on learning today?</strong><br>Let’s clear this up once and for all.</p><h4>Understanding the Background</h4><p>Microsoft originally had two different frameworks:</p><ol><li><strong>.NET Framework</strong> — The old, Windows-only platform.</li><li><strong>.NET Core</strong> — The newer, cross-platform version that runs on Windows, Linux, and macOS.</li></ol><p>Later, Microsoft decided to merge both into a single unified platform, now simply called <strong>.NET</strong>.<br>So when you hear about <strong>.NET 6, .NET 7, .NET 8</strong>, or the latest <strong>.NET 13</strong>, remember that these are all based on <strong>.NET Core</strong>.</p><p>That means <strong>if you download the latest version of .NET today, you’re already getting ASP.NET Core MVC</strong> by default.<br>The old ASP.NET MVC (the one from .NET Framework) officially ended its support after version 5.0.</p><h4>Why Is ASP.NET MVC Still Around?</h4><p>Good question!</p><p>Although ASP.NET MVC is considered outdated, <strong>many large organizations continue to maintain legacy projects built with it</strong>. These are massive enterprise applications, and rewriting them completely would take years.</p><p>That’s why you’ll still find companies hiring developers who know ASP.NET MVC — mostly for <strong>maintenance or upgrade work</strong>.<br>However, for new projects, almost everyone is choosing <strong>ASP.NET Core MVC</strong>.</p><h3>The Core Differences (Explained Simply)</h3><p>This is where most beginners get stuck, so let’s break it down in plain English.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/828/1*UE1dwc_vsJ-26XeKCGMgiA.png" /></figure><p>So, <strong>ASP.NET Core MVC</strong> comes out ahead in almost every way.</p><h4>Example: A Simple “Hello” App</h4><p>Here’s a quick example to show you what it’s like to use ASP.NET Core MVC.<br>Let’s create a basic controller that says hello to users by name.</p><pre>using Microsoft.AspNetCore.Mvc;<br><br>namespace HelloApp.Controllers<br>{<br>    public class GreetController : Controller<br>    {<br>        [HttpGet(&quot;/hello/{name}&quot;)]<br>        public IActionResult SayHello(string name)<br>        {<br>            return Content($&quot;Hello, {name}! Welcome to ASP.NET Core MVC 🎉&quot;);<br>        }<br>    }<br>}</pre><p>Now run your app and visit:<br>👉 <a href="https://localhost:5001/hello/San">https://localhost:5001/hello/San</a></p><p>You’ll get:<br><strong>“Hello, San! Welcome to ASP.NET Core MVC 🎉”</strong></p><p>That’s how clean and simple ASP.NET Core MVC can be.</p><p>What About Career Opportunities?</p><p>Most companies now want developers with <strong>Core MVC experience</strong> because:</p><ul><li>It’s future-ready</li><li>Works with cloud and AI integrations</li><li>Supports modern development practices like microservices and DevOps</li></ul><h4>My Honest Suggestion</h4><p>If you’re just starting out, don’t spend time learning the old framework.<br>Focus on learning <strong>ASP.NET Core MVC instead</strong>.</p><p>It’s faster, more flexible, and opens up better job opportunities. Also, once you know Core MVC, you can easily work on older ASP.NET MVC projects if needed, since most<strong> of the coding concepts are the same</strong>. The main differences are in configuration and deployment.</p><p>To sum it up:</p><ul><li>ASP.NET MVC = Old, Windows-only, limited support</li><li>ASP.NET Core MVC = Modern, open-source, cross-platform, high-performance</li></ul><p>If you want to stay up-to-date and ready for your career in 2025 and beyond,<br><strong>ASP.NET Core MVC is the preferred approach.</strong></p><p>So go ahead and download the latest .NET SDK, open Visual Studio or VS Code, and start building your first Core MVC app today!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9341d3ae08ea" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Debug Angular Like a Pro: Stop Using Console Logs and Start Using VS Code Debugger]]></title>
            <link>https://javascript.plainenglish.io/debug-angular-like-a-pro-stop-using-console-logs-and-start-using-vs-code-debugger-f1c6c001eac1?source=rss-9e0b6a412a2d------2</link>
            <guid isPermaLink="false">https://medium.com/p/f1c6c001eac1</guid>
            <category><![CDATA[angular-debug-in-vs-code]]></category>
            <category><![CDATA[console-log]]></category>
            <category><![CDATA[vs-code-editor]]></category>
            <category><![CDATA[angular-debug]]></category>
            <dc:creator><![CDATA[sankar marimuthu]]></dc:creator>
            <pubDate>Tue, 11 Nov 2025 09:26:20 GMT</pubDate>
            <atom:updated>2025-11-11T17:22:02.702Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fNNTmIR2zPg9g979tBig4g.png" /><figcaption>VS Code Debugger</figcaption></figure><p>Hey friends!</p><p>Let’s be honest. We’ve all been there: you hit a tough Angular bug, and your first instinct is to add console.log() statements everywhere, hoping one of them reveals the problem.</p><p>But what if I told you there’s a cleaner, smarter, and faster way to debug your Angular app without cluttering your code with print statements?</p><p>In this post, I’ll walk you through how to <strong>debug Angular like a pro</strong> right inside <strong>Visual Studio Code</strong>. You’ll learn how to set breakpoints, inspect variables, deal with async issues, and even catch those sneaky bugs that hide deep in your code.</p><p>Let’s dive in.</p><h4>Step 1: Setting Up Debugging in VS Code</h4><p>Before we start, open your Angular project in Visual Studio Code.</p><p>On the left sidebar, you’ll see a <strong>“Run and Debug”</strong> icon (or just press <strong>Ctrl + Shift + D</strong>). Click on that.</p><p>Now, choose <strong>“Run and Debug” → “Web App (Chrome)”</strong>.</p><p>This creates a file called launch.json inside a hidden .vscode folder. VS Code uses this file to know how to run your app in debug mode.</p><p>Here’s what it looks like (with a small change we’ll make):</p><pre>{<br>  &quot;version&quot;: &quot;0.2.0&quot;,<br>  &quot;configurations&quot;: [<br>    {<br>      &quot;name&quot;: &quot;Launch Chrome&quot;,<br>      &quot;type&quot;: &quot;chrome&quot;,<br>      &quot;request&quot;: &quot;launch&quot;,<br>      &quot;url&quot;: &quot;http://localhost:4200&quot;,<br>      &quot;webRoot&quot;: &quot;${workspaceFolder}&quot;<br>    }<br>  ]<br>}</pre><p>Notice that we’ve set the port to 4200, which is Angular’s default.<br>That’s it. We’re ready to debug!</p><h4>Step 2: (Optional) Add a Task for Better Workflow</h4><p>While this isn’t required, it’s a good idea to add a <em>tasks.json</em> file in the same <em>.vscode</em> folder.<br>This lets you run your Angular app automatically when debugging starts.</p><p>Here’s a sample:</p><pre>{<br>  &quot;version&quot;: &quot;2.0.0&quot;,<br>  &quot;tasks&quot;: [<br>    {<br>      &quot;label&quot;: &quot;ng serve&quot;,<br>      &quot;type&quot;: &quot;shell&quot;,<br>      &quot;command&quot;: &quot;npm&quot;,<br>      &quot;args&quot;: [&quot;run&quot;, &quot;start&quot;],<br>      &quot;isBackground&quot;: true,<br>      &quot;problemMatcher&quot;: &quot;$tsc-watch&quot;<br>    }<br>  ]<br>}</pre><p>Now, go back to your <em>launch.json</em> and add a line like this:</p><pre>&quot;preLaunchTask&quot;: &quot;ng serve&quot;</pre><p>This tells VS Code to start your Angular app before launching Chrome in debug mode.</p><h4>Step 3: Add Breakpoints and Start Debugging</h4><p>Now comes the fun part.</p><p>Open any component or service file in your project. Let’s say we have a simple <strong>User List Component</strong>:</p><pre>// user-list.component.ts<br>@Component({<br>  selector: &#39;app-user-list&#39;,<br>  template: `<br>    &lt;button (click)=&quot;loadUsers()&quot;&gt;Load Users&lt;/button&gt;<br>    &lt;ul&gt;<br>      &lt;li *ngFor=&quot;let user of users&quot;&gt;{{ user }}&lt;/li&gt;<br>    &lt;/ul&gt;<br>  `<br>})<br>export class UserListComponent {<br>  users: string[] = [];<br><br>  loadUsers() {<br>    const allUsers = [&#39;Alice&#39;, &#39;Bob&#39;, &#39;Charlie&#39;];<br>    this.users = allUsers.filter(user =&gt; user.startsWith(&#39;A&#39;));<br>    console.log(&#39;Users loaded:&#39;, this.users);<br>  }<br>}</pre><p>Instead of relying on console.log(), let’s use <strong>breakpoints</strong>.</p><p>To add one, just click on the line number where you want the code to pause. You’ll see a red dot appear.</p><p>For example, set a breakpoint on the line:</p><pre>this.users = allUsers.filter(user =&gt; user.startsWith(&#39;A&#39;));</pre><p>Now go to the <strong>Run and Debug</strong> panel and click <strong>“Launch Chrome”</strong> (the configuration we created earlier).</p><p>VS Code will open a new browser window in debug mode, and your app will start.</p><p>When you click the “<strong><em>Load Users</em></strong>” button, the debugger will pause exactly at your breakpoint.</p><h3>Step 4: Inspect Variables Like a Detective</h3><p>When your app pauses at a breakpoint, look to the <strong>left sidebar</strong> in VS Code. You’ll see:</p><ul><li><strong>Variables</strong> — shows the current values of variables in that scope.</li><li><strong>Watch</strong> — lets you manually add variables you want to monitor.</li><li><strong>Call Stack</strong> — tells you which functions were called to get to this point.</li></ul><p>For example, under “Variables,” you might see something like:</p><pre>allUsers: [&quot;Alice&quot;, &quot;Bob&quot;, &quot;Charlie&quot;]<br>users: []</pre><p>As you step over each line (by pressing <strong>F10</strong>), you can watch these values change in real time.</p><p>You can also hover your mouse over a variable directly in the code to see its current value.</p><h4>Step 5: Debug Async Issues (Promises, Observables, etc.)</h4><p>If your function involves async operations like HTTP calls or <em>setTimeout()</em>, you can still debug them easily.</p><p>Set a breakpoint inside the callback or subscription, and VS Code will pause when that code executes.</p><p>Example:</p><pre>loadUsers() {<br>  setTimeout(() =&gt; {<br>    this.users = [&#39;Alice&#39;, &#39;Bob&#39;, &#39;Charlie&#39;];<br>  }, 1000);<br>}</pre><p>Even though it runs after a delay, your breakpoint inside the arrow function will still be hit once the timer completes.</p><p>This is super helpful when debugging Observables or delayed API responses.</p><h4>Step 6: Watching Expressions</h4><p>Let’s say you want to monitor how many users are loaded over time.<br>Instead of adding another console.log(), go to the <strong>Watch</strong> section in VS Code and type users.length.</p><p>Now every time your app pauses, you’ll instantly see how many users are in the list. No code changes needed.</p><h4>Step 7: Run, Step, and Continue</h4><p>VS Code gives you simple controls at the top of the window:</p><ul><li>▶ <strong>Continue (F5)</strong> — Run until the next breakpoint</li><li>⏩ <strong>Step Over (F10)</strong> — Run the next line</li><li>🔽 <strong>Step Into (F11)</strong> — Go inside the function call</li><li>🔼 <strong>Step Out (Shift+F11)</strong> — Jump out of the function</li></ul><p>You can use these to walk through your code line by line and truly understand what’s happening under the hood.</p><p>And that’s it! You’ve just learned how to <strong>debug Angular applications directly in VS Code. N</strong>o more guessing, no more console spam.</p><p>With breakpoints, variable inspection, and the call stack, you’ll find bugs faster and understand your app better.</p><p>So next time your Angular app misbehaves, don’t panic. Just launch Chrome in debug mode and take control.</p><p>If you found this helpful, share it with a fellow developer who’s still drowning in console logs. And remember, debugging is not just about fixing errors; it’s about understanding your code.</p><p>Happy debugging, and see you in the next post!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f1c6c001eac1" width="1" height="1" alt=""><hr><p><a href="https://javascript.plainenglish.io/debug-angular-like-a-pro-stop-using-console-logs-and-start-using-vs-code-debugger-f1c6c001eac1">Debug Angular Like a Pro: Stop Using Console Logs and Start Using VS Code Debugger</a> was originally published in <a href="https://javascript.plainenglish.io/">JavaScript in Plain English</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How to Find and Fix Memory Leaks in Your Angular or JavaScript App]]></title>
            <link>https://javascript.plainenglish.io/how-to-find-and-fix-memory-leaks-in-your-angular-or-javascript-app-b9f35545a91c?source=rss-9e0b6a412a2d------2</link>
            <guid isPermaLink="false">https://medium.com/p/b9f35545a91c</guid>
            <category><![CDATA[angular]]></category>
            <category><![CDATA[memory-leak]]></category>
            <category><![CDATA[javascript-tips]]></category>
            <dc:creator><![CDATA[sankar marimuthu]]></dc:creator>
            <pubDate>Wed, 05 Nov 2025 07:18:01 GMT</pubDate>
            <atom:updated>2025-11-05T08:41:44.718Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*m32TqoK5fPs3iwi73D2eDA.png" /><figcaption>Fix Memory Leaks</figcaption></figure><p>Hey!</p><p>Have you ever noticed your program running smoothly at first, but then it suddenly slows down, freezes, or crashes? If this sounds familiar, you might be dealing with a memory leak.</p><p>Don’t worry, you’re not the only one facing this. Memory leaks are tricky and can get worse over time, slowing down your computer.</p><p>In this post, I’ll explain what memory leaks are, how they happen in JavaScript, and how to find and fix them using Chrome DevTools and a simple example.</p><p>Let’s get started.</p><h4>What is a Memory Leak?</h4><p>Simply put, a memory leak happens when your program keeps using memory it no longer needs.</p><blockquote>Think of it like borrowing boxes to move. After you unpack, you should return the boxes. If you forget, the empty boxes pile up and take up space. This is similar to what happens when software doesn’t release memory it no longer needs.</blockquote><p>JavaScript uses a garbage collector to remove values you don’t need anymore. But sometimes, our code can stop it from doing its job.</p><h4>How JavaScript Memory Leaks Happen</h4><p>Here are some common ways memory leaks can show up in your app:</p><p><strong>Global Variables:</strong> If you skip <em>let</em>, <em>const</em>, or <em>var</em>, JavaScript attaches the variable to the global <em>window </em>object. This means it stays in memory even when you no longer need it.</p><pre>function startCounter() {<br>  counter = 0; // forgot &#39;let&#39; or &#39;const&#39; 😬<br>  setInterval(() =&gt; counter++, 1000);<br>}</pre><p>Now, <em>counter </em>is a global variable, so the garbage collector will never remove it.</p><p><strong>Uncleared Timers or Intervals:</strong> If you use <em>setInterval()</em> and forget to clear it, it keeps running and holds on to anything it references.</p><p><strong>Event Listeners:</strong> Another common mistake is adding an event listener but not removing it when the element is removed from the DOM.</p><p><strong>Unmanaged Subscriptions (especially in Angular):</strong> In Angular, if you subscribe to an Observable and forget to unsubscribe when the component is destroyed, the subscription can keep your component in memory forever.</p><h4><strong>Example: Detecting a Memory Leak in an Angular To-Do List App</strong></h4><p>Let’s look at a simple Angular app that shows a list of to-do items. Each time we add a new item, a small component (TodoItemComponent) is created. When we delete an item, the component should be destroyed.</p><p><strong>Here’s a simple version:</strong></p><pre>// todo-list.component.ts<br>@Component({<br>  selector: &#39;app-todo-list&#39;,<br>  template: `<br>    &lt;button (click)=&quot;addTodo()&quot;&gt;Add Todo&lt;/button&gt;<br>    &lt;div *ngFor=&quot;let todo of todos&quot;&gt;<br>      &lt;app-todo-item [todo]=&quot;todo&quot; (remove)=&quot;removeTodo(todo)&quot;&gt;&lt;/app-todo-item&gt;<br>    &lt;/div&gt;<br>  `<br>})<br>export class TodoListComponent {<br>  todos: string[] = [];<br><br>  addTodo() {<br>    this.todos.push(`Task ${this.todos.length + 1}`);<br>  }<br><br>  removeTodo(todo: string) {<br>    this.todos = this.todos.filter(t =&gt; t !== todo);<br>  }<br>}</pre><p>And the child component:</p><pre>// todo-item.component.ts<br>@Component({<br>  selector: &#39;app-todo-item&#39;,<br>  template: `<br>    &lt;div&gt;{{ todo }}&lt;/div&gt;<br>    &lt;button (click)=&quot;remove.emit()&quot;&gt;Remove&lt;/button&gt;<br>  `<br>})<br>export class TodoItemComponent implements OnInit, OnDestroy {<br>  @Input() todo!: string;<br>  @Output() remove = new EventEmitter&lt;void&gt;();<br>  private sub!: Subscription;<br><br>  ngOnInit() {<br>    // Simulate a data stream (leak if not unsubscribed)<br>    this.sub = interval(1000).subscribe(() =&gt; console.log(this.todo));<br>  }<br><br>  ngOnDestroy() {<br>    // Commenting this out causes a memory leak!<br>    // this.sub.unsubscribe();<br>  }<br>}</pre><p>If we forget to unsubscribe in <em>ngOnDestroy</em>, each deleted to-do item stays in memory.</p><h4><strong>How to Detect Memory Leaks Using Chrome DevTools</strong></h4><p>Here’s how you can find these leaks, step by step:</p><p><strong>1. Open the Performance Tab</strong></p><p>In Chrome, open <strong>DevTools and go to the Performance tab.</strong><br>Check the <strong>Memory</strong> option, then click <strong>Record</strong>.</p><p>Now, do some repetitive actions in your app, like adding and deleting to-do items several times. Then stop recording.</p><p>If you see the blue memory usage line keep rising, even after you undo your actions, that’s a warning sign.</p><p>This means your app is holding on to memory it shouldn’t.</p><p><strong>2. Use the Memory Tab and Take Snapshots</strong></p><p>Next, go to the <strong>Memory</strong> tab and click <strong>“Take Snapshot.”</strong></p><ol><li>Interact with your app by adding or removing to-dos.</li><li>Then, take another snapshot.</li><li>Compare the two snapshots.</li></ol><p>If you see objects like TodoItemComponent or Subscriber increasing each time, that’s a clear sign of a memory leak.</p><p><strong>3. Identify What’s Holding the Reference</strong></p><p>Select one of the leaked objects in the snapshot and open the <strong>Retainers</strong> section.<br>This will show the chain of references keeping it alive.</p><p>You’ll probably find something like an RxJS subscription or an event listener still connected to the deleted component. That’s your leak.</p><p><strong>Fixing the Leak</strong></p><p>In our Angular example, the fix is simple: unsubscribe when the component is destroyed.</p><pre>ngOnDestroy() {<br>  this.sub.unsubscribe();<br>}</pre><p>Or even better, use the <em>takeUntilDestroyed()</em> operator if you have Angular 16 or newer. If you’re on an older version, use <em>takeUntil()</em> with a Subject.</p><p>After you fix the issue, rebuild your app and test it again. You should see the memory line stay flat, with no more creeping blue line.</p><p>Memory leaks can be tough to deal with at first, but once you know how to find them, managing them gets a lot easier.</p><p>The main thing to remember is to always clean up after yourself. Unsubscribe from Observables, remove event listeners, and clear timers. These small habits can save your app from big problems down the road.</p><p>Happy coding, and may your memory always be garbage-collected!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b9f35545a91c" width="1" height="1" alt=""><hr><p><a href="https://javascript.plainenglish.io/how-to-find-and-fix-memory-leaks-in-your-angular-or-javascript-app-b9f35545a91c">How to Find and Fix Memory Leaks in Your Angular or JavaScript App</a> was originally published in <a href="https://javascript.plainenglish.io/">JavaScript in Plain English</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Mastering TypeScript: Your Secret Weapon for Building Better Angular Apps]]></title>
            <link>https://javascript.plainenglish.io/mastering-typescript-your-secret-weapon-for-building-better-angular-apps-1286d3f27586?source=rss-9e0b6a412a2d------2</link>
            <guid isPermaLink="false">https://medium.com/p/1286d3f27586</guid>
            <category><![CDATA[typescript]]></category>
            <category><![CDATA[building-angular-apps]]></category>
            <category><![CDATA[mastering-typescript]]></category>
            <category><![CDATA[angular]]></category>
            <dc:creator><![CDATA[sankar marimuthu]]></dc:creator>
            <pubDate>Mon, 03 Nov 2025 17:44:19 GMT</pubDate>
            <atom:updated>2025-11-03T17:44:19.124Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*edKnM8JK1hEkGgnXMtMHvg.png" /><figcaption>Mastering TypeScript</figcaption></figure><p>Hey there, <br>If you’ve been working with Angular, you already know — <strong>TypeScript is where the magic happens</strong>.</p><p>But here’s a question worth asking yourself:<br> 👉 Are you just <em>using</em> TypeScript, or are you really <em>mastering</em> it?</p><p>Because once you start tapping into its deeper features, you’ll notice your apps become <strong>safer, cleaner, and way more professional</strong>. So let’s explore how you can get there — step by step.</p><h4>Step 1: Build Your Foundation with Strong Typing</h4><p>Think of <strong>strong typing</strong> as your app’s <strong>safety helmet</strong> — it protects your code from breaking before it even runs.<br>For example:</p><pre>const userIds = [1, 2, 3];</pre><p>TypeScript already knows this is an array of numbers. Try to add a string, and it’ll stop you immediately.</p><p>That’s called <strong>type inference</strong> — TypeScript figures things out for you while keeping your code safe and neat. No extra clutter, no hidden bugs.</p><h4>Step 2: Use Interfaces — Your Data Blueprints</h4><p>When your data gets more complex (like users, orders, or products), <strong>interfaces</strong> step in as your <strong>blueprint</strong>.</p><p>Here’s what that looks like:</p><pre>interface Product {<br>  id: number;<br>  name: string;<br>  price: number;<br>}</pre><p>Now your code knows exactly what a Product should look like.<br>If you accidentally pass something else, TypeScript catches it early — before it ruins your weekend debugging session.</p><p>Interfaces are especially powerful when working in teams — everyone follows the same structure, so your data always makes sense.</p><h4>Step 3: Reuse Code Smartly with Generics</h4><p>Ever feel like you’re writing the same function again and again — one for users, another for products, and so on?</p><p>That’s where <strong>generics</strong> come to the rescue!</p><p>With generics, you can write one flexible, reusable function that safely handles all kinds of data:</p><pre>function fetchData&lt;T&gt;(url: string): Promise&lt;T&gt; {<br>  return fetch(url).then(res =&gt; res.json());<br>}</pre><p>Now you can call fetchData&lt;User&gt;(), fetchData&lt;Product&gt;(), or fetchData&lt;Article&gt;() — and TypeScript will make sure you get exactly what you expect.</p><p>It’s like writing one tool that magically adapts to every job.</p><h4>Step 4: Power Up with Utility Types</h4><p>If interfaces are your blueprints, <strong>utility types</strong> are your <strong>power tools</strong>.</p><p>They help you modify existing types on the fly — no need to rewrite from scratch.</p><p>Here are two you’ll use all the time:</p><ul><li><strong>Partial&lt;T&gt;</strong> — makes every property optional (perfect for multi-step forms).</li><li><strong>Readonly&lt;T&gt;</strong> — locks properties so no one can change them (ideal for app configs or constants).</li></ul><p>Example:</p><pre>const config: Readonly&lt;{ version: string }&gt; = { version: &quot;1.0&quot; };<br>// config.version = &quot;2.0&quot; ❌ Not allowed</pre><p>These tiny helpers can prevent hours of bug-hunting later on.</p><p>Step 5: Say Goodbye to Typos with keyof</p><p>We’ve all done this one:</p><pre>user[&quot;nmae&quot;]</pre><p>just one small typo and — boom — your app breaks. 😩</p><p>Enter <strong>keyof</strong> — a feature that ensures you only use real property names.</p><pre>function getValue&lt;T, K extends keyof T&gt;(obj: T, key: K) {<br>  return obj[key];<br>}</pre><p>Now TypeScript will complain if you try to access a key that doesn’t exist. No more “magic strings,” no more silent bugs.</p><h4>Step 6: The Magic of Decorators</h4><p>If Angular feels magical sometimes, it’s because of <strong>decorators</strong>.</p><p>You’ve seen them before — @Component, @Injectable, and others. They look fancy but are actually simple labels that tell Angular how to treat your class.</p><p>For example:</p><pre>@Component({<br>  selector: &#39;app-hero&#39;,<br>  templateUrl: &#39;./hero.component.html&#39;<br>})<br>export class HeroComponent {}</pre><p>Angular reads that @Component decorator and instantly knows — this is a component.</p><p>And the coolest part? You can <strong>make your own decorators</strong>!</p><pre>function Log(target, name, descriptor) {<br>  const original = descriptor.value;<br>  descriptor.value = function(...args) {<br>    console.log(`Called ${name} with`, args);<br>    return original.apply(this, args);<br>  };<br>}</pre><p>Add @Log above any method, and it’ll automatically print logs whenever that method runs.<br> That means cleaner code, fewer console.log lines, and better debugging!</p><p>Let’s take a quick breath — we’ve covered a lot!</p><p>From <strong>strong typing</strong> and <strong>interfaces</strong>, to <strong>generics</strong>, <strong>utility types</strong>, and <strong>decorators</strong> — you now have a full TypeScript toolkit to build safer, smarter, and more maintainable Angular apps.</p><p>The big idea?<br> 👉 Mastering TypeScript isn’t just a “resume skill.”<br> It’s how you write <strong>reliable, professional code</strong> that your whole team will thank you for.</p><p>So, here’s a small challenge for you today:</p><ul><li>Pick one Angular component or service you’re working on.</li><li>Try adding an interface, a generic, or maybe a decorator.</li><li>See how much smoother your code feels.</li></ul><p>Remember — mastering TypeScript isn’t about giant leaps. It’s about small, steady improvements that add up over time.</p><h3>A message from our Founder</h3><p><strong>Hey, </strong><a href="https://linkedin.com/in/sunilsandhu"><strong>Sunil</strong></a><strong> here.</strong> I wanted to take a moment to thank you for reading until the end and for being a part of this community.</p><p>Did you know that our team run these publications as a volunteer effort to over 3.5m monthly readers? <strong>We don’t receive any funding, we do this to support the community. ❤️</strong></p><p>If you want to show some love, please take a moment to <strong>follow me on </strong><a href="https://linkedin.com/in/sunilsandhu"><strong>LinkedIn</strong></a><strong>, </strong><a href="https://tiktok.com/@messyfounder"><strong>TikTok</strong></a>, <a href="https://instagram.com/sunilsandhu"><strong>Instagram</strong></a>. You can also subscribe to our <a href="https://newsletter.plainenglish.io/"><strong>weekly newsletter</strong></a>.</p><p>And before you go, don’t forget to <strong>clap</strong> and <strong>follow</strong> the writer️!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1286d3f27586" width="1" height="1" alt=""><hr><p><a href="https://javascript.plainenglish.io/mastering-typescript-your-secret-weapon-for-building-better-angular-apps-1286d3f27586">Mastering TypeScript: Your Secret Weapon for Building Better Angular Apps</a> was originally published in <a href="https://javascript.plainenglish.io/">JavaScript in Plain English</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[I Finally Understood What [Owned] Means in EF Core — Here’s the Simple Explanation]]></title>
            <link>https://medium.com/@sankarums/i-finally-understood-what-owned-means-in-ef-core-heres-the-simple-explanation-5db41d19fec4?source=rss-9e0b6a412a2d------2</link>
            <guid isPermaLink="false">https://medium.com/p/5db41d19fec4</guid>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[entity-framework-core]]></category>
            <category><![CDATA[api-development]]></category>
            <category><![CDATA[dotnet]]></category>
            <category><![CDATA[csharp]]></category>
            <dc:creator><![CDATA[sankar marimuthu]]></dc:creator>
            <pubDate>Mon, 27 Oct 2025 07:52:35 GMT</pubDate>
            <atom:updated>2025-10-27T07:52:35.207Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*pESPICMD06HwwHcSHMkshQ.png" /></figure><h3>I Finally Understood What [Owned] Means in EF Core — Here’s the Simple Explanation</h3><p>If you’ve been exploring <strong>Entity Framework Core</strong>, you might have seen the [Owned] attribute and wondered what it really does.</p><p>It often pops up when working with <strong>value objects</strong>, <strong>complex types</strong>, or <strong>domain-driven design</strong> concepts — but it’s not immediately obvious how it affects your database or entities.</p><p>In this article, I’ll break it down in simple terms, with examples you can relate to and use in your own .NET Core projects.</p><h4>What Is an Owned Entity?</h4><p>An <strong>owned entity</strong> in EF Core is a type that <strong>doesn’t have its own table</strong> in the database.</p><p>Instead, it’s <em>owned</em> by another entity — which means it lives and dies with its owner.</p><p>You can think of it like a “value object” in Domain-Driven Design.<br>It doesn’t have an independent identity or primary key. It only makes sense as part of another entity.</p><h4>The Address Example</h4><p>Here’s a common example — an Address class:</p><pre>using Microsoft.EntityFrameworkCore;<br>using System;<br><br>namespace MYPROJ.Domain.Entities<br>{<br>    [Owned]<br>    public class Address<br>    {<br>        public string? Address1 { get; set; }<br>        public string? Address2 { get; set; }<br>        public string? City { get; set; }<br>        public string? State { get; set; }<br>        public Guid? CountryId { get; set; }<br>        public string? PostalCode { get; set; }<br>        public string? Phone { get; set; }<br>        public string? Mobile { get; set; }<br>        public string? MailAddress { get; set; }<br>    }<br>}</pre><p>Notice the [Owned] attribute above the class.<br>That small tag completely changes how EF Core treats this type.</p><h4>Using It in an Entity</h4><p>Let’s say we have a Customer entity that uses the Address type:</p><pre>public class Customer<br>{<br>    public Guid Id { get; set; }<br>    public string Name { get; set; }<br><br>    public Address BillingAddress { get; set; }<br>    public Address ShippingAddress { get; set; }<br>}</pre><p>Now, we have two address fields — one for billing, one for shipping.<br>Here’s where EF Core does something really smart.</p><h4>How It’s Stored in the Database</h4><p>When you run your migration, EF Core <strong>doesn’t create a separate </strong><strong>Address table</strong>.</p><p>Instead, it “flattens” all the address properties into the same Customer table.</p><p>The resulting table looks something like this:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/610/1*PD0olZrNyiysGhEgsV_6tQ.png" /></figure><p>In other words, all the properties of the Address object are prefixed and stored alongside the customer data.</p><p>No joins, no foreign keys — just one flat table.</p><h4>Configuring Ownership in the DbContext</h4><p>In your DbContext, you tell EF Core which entity owns the Address type:</p><pre>protected override void OnModelCreating(ModelBuilder modelBuilder)<br>{<br>    modelBuilder.Entity&lt;Customer&gt;().OwnsOne(c =&gt; c.BillingAddress);<br>    modelBuilder.Entity&lt;Customer&gt;().OwnsOne(c =&gt; c.ShippingAddress);<br>}</pre><p>This makes it crystal clear that these two address objects belong to the Customer entity.</p><h4>Why This Is Useful</h4><p>Owned entities are perfect when:</p><ul><li>The data is <strong>part of</strong> another entity (not independent)</li><li>You don’t need a separate table or primary key</li><li>You want to follow <strong>clean domain modeling</strong> principles</li></ul><p>Common examples:</p><ul><li>Address</li><li>Money (Amount + Currency)</li><li>GeoLocation (Latitude + Longitude)</li><li>AuditInfo (CreatedBy, CreatedDate, etc.)</li></ul><h4>Things to Keep in Mind</h4><ul><li>Owned types <strong>cannot exist on their own</strong> — deleting the owner deletes them.</li><li>EF Core automatically prefixes columns with the property name.</li><li>You can reuse the same owned type across different entities.</li><li>Owned entities can even have their own owned properties (nested ownership).</li></ul><h3>Wrapping Up</h3><p>[Owned] might look like a small attribute, but it helps you design much cleaner models.</p><p>It keeps your database schema simple and your code closer to real-world concepts.</p><p>Next time you have a piece of data that only makes sense <em>as part of</em> something else, consider marking it as [Owned].</p><p>It’s one of those EF Core features that quietly makes your codebase more elegant — once you know it exists.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5db41d19fec4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Stop Risky Uploads! Validate File Contents in Angular for Better Security]]></title>
            <link>https://medium.com/@sankarums/stop-risky-uploads-validate-file-contents-in-angular-for-better-security-2b7ea618b0d5?source=rss-9e0b6a412a2d------2</link>
            <guid isPermaLink="false">https://medium.com/p/2b7ea618b0d5</guid>
            <category><![CDATA[file-validation]]></category>
            <category><![CDATA[validate-file-content]]></category>
            <category><![CDATA[risky-upload]]></category>
            <category><![CDATA[angular]]></category>
            <category><![CDATA[file-upload]]></category>
            <dc:creator><![CDATA[sankar marimuthu]]></dc:creator>
            <pubDate>Fri, 24 Oct 2025 08:59:36 GMT</pubDate>
            <atom:updated>2025-10-24T08:59:36.742Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uFmD-VLzhyJ12Z8b-h7g7Q.png" /></figure><p>We often let users upload files — profile pictures, documents, reports, or spreadsheets — without thinking much about it. But here’s the truth: <strong>file uploads are one of the most common ways attackers sneak in malicious data</strong>.</p><p>Even if your backend validates uploads, it’s always a good idea to add an <strong>extra layer of defense</strong> on the frontend. In this article, let’s see how we can <strong>validate file contents in Angular</strong> before sending them to the server — safely and smartly.</p><h4>Why Should You Validate Files in the Frontend?</h4><p>Imagine your Angular app allows users to upload images. What if someone tries to upload a script or an executable file pretending to be a .jpg?</p><p>Sure, your backend should reject it — but if you catch it early on the frontend, you can:</p><ul><li>Save bandwidth (no need to send invalid files)</li><li>Improve user experience (instant feedback)</li><li>Add an extra layer of protection</li></ul><p>So let’s see how to build this step by step.</p><h4>Step 1: Create a Simple File Upload Component</h4><p>Start with a basic file input in your Angular component.</p><pre>&lt;!-- file-upload.component.html --&gt;<br>&lt;div class=&quot;upload-box&quot;&gt;<br>  &lt;h3&gt;Upload File&lt;/h3&gt;<br>  &lt;input type=&quot;file&quot; (change)=&quot;onFileSelected($event)&quot; /&gt;<br>  &lt;p *ngIf=&quot;errorMessage&quot; class=&quot;error&quot;&gt;{{ errorMessage }}&lt;/p&gt;<br>  &lt;p *ngIf=&quot;successMessage&quot; class=&quot;success&quot;&gt;{{ successMessage }}&lt;/p&gt;<br>&lt;/div&gt;</pre><p>A clean, minimal setup — users pick a file, and we respond.</p><h4>Step 2: Handle the File in TypeScript</h4><p>Now, let’s process the uploaded file inside the component.</p><pre>// file-upload.component.ts<br>import { Component } from &#39;@angular/core&#39;;<br><br>@Component({<br>  selector: &#39;app-file-upload&#39;,<br>  templateUrl: &#39;./file-upload.component.html&#39;,<br>  styleUrls: [&#39;./file-upload.component.css&#39;]<br>})<br>export class FileUploadComponent {<br>  errorMessage = &#39;&#39;;<br>  successMessage = &#39;&#39;;<br><br>  onFileSelected(event: any) {<br>    const file = event.target.files[0];<br>    this.errorMessage = &#39;&#39;;<br>    this.successMessage = &#39;&#39;;<br><br>    if (!file) return;<br><br>    // Validate file type and size<br>    if (!this.isValidFileType(file)) {<br>      this.errorMessage = &#39;Invalid file type. Please upload an image or PDF.&#39;;<br>      return;<br>    }<br><br>    if (file.size &gt; 2 * 1024 * 1024) { // 2 MB limit<br>      this.errorMessage = &#39;File size exceeds 2 MB.&#39;;<br>      return;<br>    }<br><br>    // Validate file content (advanced check)<br>    this.validateFileContent(file);<br>  }<br><br>  isValidFileType(file: File): boolean {<br>    const allowedTypes = [&#39;image/png&#39;, &#39;image/jpeg&#39;, &#39;application/pdf&#39;];<br>    return allowedTypes.includes(file.type);<br>  }<br><br>  async validateFileContent(file: File) {<br>    const buffer = await file.arrayBuffer();<br>    const bytes = new Uint8Array(buffer.slice(0, 4));<br><br>    // Basic signature (magic number) checks<br>    const pngHeader = [0x89, 0x50, 0x4E, 0x47];<br>    const jpgHeader = [0xFF, 0xD8, 0xFF];<br>    const pdfHeader = [0x25, 0x50, 0x44, 0x46];<br><br>    if (this.startsWith(bytes, pngHeader)) {<br>      this.successMessage = &#39;Valid PNG image uploaded!&#39;;<br>    } else if (this.startsWith(bytes, jpgHeader)) {<br>      this.successMessage = &#39;Valid JPG image uploaded!&#39;;<br>    } else if (this.startsWith(bytes, pdfHeader)) {<br>      this.successMessage = &#39;Valid PDF document uploaded!&#39;;<br>    } else {<br>      this.errorMessage = &#39;Invalid file content detected!&#39;;<br>    }<br>  }<br><br>  private startsWith(bytes: Uint8Array, header: number[]): boolean {<br>    return header.every((b, i) =&gt; bytes[i] === b);<br>  }<br>}</pre><p><strong>What this code does:</strong></p><ul><li>Checks the file <strong>type and size</strong></li><li>Reads the file’s first few bytes (called a “magic number”)</li><li>Compares them with known file signatures for PNG, JPG, and PDF</li><li>Prevents suspicious files before upload</li></ul><h4>Step 3: Make It Look Nice</h4><p>You can add a simple CSS touch to make the upload UI clean and readable.</p><pre>/* file-upload.component.css */<br>.upload-box {<br>  width: 300px;<br>  margin: 20px auto;<br>  padding: 16px;<br>  border: 1px solid #ddd;<br>  border-radius: 12px;<br>  text-align: center;<br>  background-color: #fafafa;<br>}<br><br>.error {<br>  color: #e63946;<br>  font-weight: bold;<br>}<br><br>.success {<br>  color: #2a9d8f;<br>  font-weight: bold;<br>}</pre><h4>Step 4: What Happens Next?</h4><p>Once the file passes validation, you can safely send it to your backend using Angular’s HttpClient:</p><pre>// Example (optional)<br>uploadFile(file: File) {<br>  const formData = new FormData();<br>  formData.append(&#39;file&#39;, file);<br><br>  this.http.post(&#39;/api/upload&#39;, formData).subscribe({<br>    next: () =&gt; this.successMessage = &#39;File uploaded successfully!&#39;,<br>    error: () =&gt; this.errorMessage = &#39;Upload failed. Please try again.&#39;<br>  });<br>}</pre><h4>Don’t Rely on Frontend Validation Alone</h4><p>Frontend validation helps protect users and optimize the experience — but it’s <strong>not a replacement</strong> for backend validation.</p><p>Always validate and sanitize uploads on the server as well, because a smart attacker can bypass your UI and send files directly via an API.</p><p><strong>Your turn!</strong><br>Have you ever faced file upload security issues in your projects?<br>Drop a comment below — I’d love to hear how you tackled them.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2b7ea618b0d5" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Unlocking the Power of Custom Event Manager Plugins in Angular]]></title>
            <link>https://medium.com/@sankarums/unlocking-the-power-of-custom-event-manager-plugins-in-angular-91a9fdc1c0ca?source=rss-9e0b6a412a2d------2</link>
            <guid isPermaLink="false">https://medium.com/p/91a9fdc1c0ca</guid>
            <category><![CDATA[angular]]></category>
            <category><![CDATA[custom-plugin-development]]></category>
            <category><![CDATA[event-manager]]></category>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[sankar marimuthu]]></dc:creator>
            <pubDate>Wed, 22 Oct 2025 15:11:04 GMT</pubDate>
            <atom:updated>2025-10-22T15:11:04.146Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fKqXKgce3hZ4VZhlO4jqoA.png" /></figure><p>Hey there!</p><p>If you’ve been working with Angular for a while, you’ve probably used keyup or keydown events before. You know — that handy syntax like (keyup.enter) or (keydown.escape) that lets you react to specific keys on your keyboard. Pretty cool, right?</p><p>But here’s something even cooler:<br><strong>You can actually create your own custom events just like that!</strong><br>Yes — this isn’t some mysterious Angular magic. It’s powered by something called the <strong>Event Manager</strong> and <strong>Event Manager Plugins</strong>.</p><p>Let’s explore what they are, how they work, and how you can create your own custom event plugin to handle events (and even prevent default behaviors) in a clean, scalable way.</p><h4>The Problem: Default Behaviors That Break Your Flow</h4><p>To demonstrate, imagine you have a simple web form. Users type in their email address and click <strong>Subscribe</strong> to join your newsletter.</p><p>Simple enough. But there’s a catch — every time you click that Subscribe button, the page reloads. 😩<br> That’s just the browser’s <strong>default behavior</strong> when submitting a form.</p><p>Usually, we fix this by adding a little line of code like:</p><pre>event.preventDefault();</pre><p>This stops the page from reloading. Easy fix, right?</p><p>Sure — but as your app grows, you might need to do this dozens of times. Writing preventDefault() over and over becomes repetitive and messy. And it clutters your code, especially when all you want is a clean, declarative way to say, “Hey, stop that default behavior.”</p><p>Wouldn’t it be great if Angular could just handle that automatically for you?</p><h4>Behind the Scenes: How Angular Handles Events</h4><p>Before we jump to the solution, it helps to understand what happens when Angular listens to events under the hood.</p><p>When you write something like:</p><pre>&lt;button (click)=&quot;onClick()&quot;&gt;Click Me&lt;/button&gt;</pre><p>Angular doesn’t attach that listener directly to the DOM element. Instead, it uses an <strong>Event Manager</strong>, which works as a middle layer. The Event Manager decides <em>which plugin</em> should handle each type of event.</p><p>For example:</p><ul><li>Standard events like click, submit, or input → handled by the <strong>DOM Events Plugin</strong></li><li>Keyboard events like (keyup.enter) → handled by the <strong>Key Events Plugin</strong></li></ul><p>Pretty neat, right?<br>Even better — Angular lets you <strong>add your own plugin</strong> to this system!<br>That means you can extend the event system to do whatever you want.</p><h4>Building Your Own Event Plugin</h4><p>Let’s say you want to create a custom event syntax like this:</p><pre>&lt;form (submit.prevent)=&quot;onSubmit($event)&quot;&gt;</pre><p>Here, .prevent is your modifier — it tells Angular to prevent the default behavior when this event fires.</p><p>To do this, you’ll create a <strong>custom Event Manager Plugin</strong>.</p><p>Start by creating a new TypeScript file, maybe called prevent-default.plugin.ts.<br>Inside it, create a class like this:</p><pre>export class PreventDefaultEventPlugin extends EventManagerPlugin {<br>  supports(eventName: string): boolean {<br>    return eventName.endsWith(&#39;.prevent&#39;);<br>  }<br><br>  addEventListener(element: HTMLElement, eventName: string, handler: Function) {<br>    const [actualEvent] = eventName.split(&#39;.&#39;);<br><br>    const callback = (event: Event) =&gt; {<br>      event.preventDefault();<br>      handler(event);<br>    };<br><br>    element.addEventListener(actualEvent, callback);<br><br>    return () =&gt; {<br>      element.removeEventListener(actualEvent, callback);<br>    };<br>  }<br>}</pre><p>Let’s break that down:</p><ul><li>The <strong>supports()</strong> method tells Angular when your plugin should handle an event. In this case, whenever the event name ends with .prevent, your plugin kicks in.</li><li>The <strong>addEventListener()</strong> method actually attaches the listener to the DOM. It also handles calling preventDefault() for you before executing your handler.</li></ul><p>And just like that, you’ve created a <strong>custom event plugin</strong> that can intercept events and prevent their default behavior — no extra code needed in your components!</p><h4>Registering the Plugin</h4><p>Next, you need to tell Angular about your new plugin.<br>In your app configuration (for example, inside app.config.ts), add this provider:</p><pre>{<br>  provide: EVENT_MANAGER_PLUGINS,<br>  useClass: PreventDefaultEventPlugin,<br>  multi: true,<br>}</pre><p>That’s it. Now Angular knows your plugin exists and when to use it.</p><h4>Testing It Out</h4><p>Now, when you write something like:</p><pre>&lt;form (submit.prevent)=&quot;onSubmit($event)&quot;&gt;</pre><p>Your page will no longer reload automatically — even though you didn’t call preventDefault() manually.</p><p>Your custom plugin caught the event, handled it, and kept your app logic nice and clean.</p><h3>Don’t Forget Cleanup (Avoiding Memory Leaks)</h3><p>There’s just one more important detail: <strong>cleaning up event listeners.</strong></p><p>Whenever you attach an event listener, you should also remove it when the element is destroyed. Otherwise, you risk memory leaks — invisible bugs that can slow down your app over time.</p><p>Luckily, in Angular’s plugin system, cleanup is simple.<br> The addEventListener() method returns a function that Angular calls automatically when it needs to remove the listener.</p><p>In our example, we already returned a cleanup function:</p><pre>return () =&gt; {<br>  element.removeEventListener(actualEvent, callback);<br>};</pre><h4>Wrapping Up</h4><p>And there you have it — your own <strong>custom Angular event plugin</strong>!<br> By using Event Manager Plugins, you can make your app cleaner, more scalable, and much easier to maintain.</p><p>Instead of writing repetitive logic everywhere, you can centralize event behavior — like preventing defaults, debouncing, or even custom shortcuts — all in one reusable plugin.</p><p>Pretty powerful, right?</p><p>If you’re curious to dig deeper, Angular’s event system is full of cool possibilities — you could even integrate RxJS or create debounced event streams.</p><p>So next time you find yourself writing the same event logic again and again, take a step back and think:<br>“Maybe it’s time to build a custom event plugin.”</p><p>Until next time, happy coding!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=91a9fdc1c0ca" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Writing Clean, Composable Sorting Logic in TypeScript]]></title>
            <link>https://medium.com/@sankarums/writing-clean-composable-sorting-logic-in-typescript-484a9a39cc66?source=rss-9e0b6a412a2d------2</link>
            <guid isPermaLink="false">https://medium.com/p/484a9a39cc66</guid>
            <category><![CDATA[sorting-logic-typescript]]></category>
            <category><![CDATA[sorting-techniques]]></category>
            <category><![CDATA[typescript]]></category>
            <category><![CDATA[angular-typescript]]></category>
            <dc:creator><![CDATA[sankar marimuthu]]></dc:creator>
            <pubDate>Thu, 16 Oct 2025 06:43:46 GMT</pubDate>
            <atom:updated>2025-10-16T06:43:46.542Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*LcpNai8Ht3qy7bNx9ZZzIg.png" /></figure><p>Hey folks</p><p>If you’ve worked on a few TypeScript projects, you’ve probably seen sorting logic turn into a mess — long functions, nested conditionals, and callbacks you never want to read again.</p><p>I’ve been there too. Over time, I found a better way — one that’s <strong>clean, reusable, and declarative</strong>.<br>In this post, I’ll show you how to build your own composable sorting system in TypeScript, step by step.</p><h4>The Problem: Sorting Gets Messy Fast</h4><p>Let’s start simple.<br>You have an array of numbers:</p><pre>const numbers = [3, 1, 5, 2];<br>numbers.sort(); // ascending order</pre><p>If you want descending order:</p><pre>numbers.sort((a, b) =&gt; b - a);</pre><p>Easy enough.</p><p>But what happens when you’re sorting objects?</p><pre>const people = [<br>  { name: &quot;Alice&quot;, createdAt: new Date(&quot;2023-01-01&quot;) },<br>  { name: &quot;Bob&quot;, createdAt: new Date(&quot;2023-02-15&quot;) },<br>  { name: &quot;Alice&quot;, createdAt: new Date(&quot;2023-03-10&quot;) }<br>];</pre><p>Let’s say you want to sort them by name, and if two names are the same, then by date.<br>You might do something like this:</p><pre>people.sort((a, b) =&gt; {<br>  const byName = a.name.localeCompare(b.name);<br>  if (byName !== 0) return byName;<br>  return a.createdAt.getTime() - b.createdAt.getTime();<br>});</pre><p>It works… but it’s messy.<br>You’ve mixed logic, repeated code, and made it hard to reuse.</p><p>Let’s fix that.</p><h4>Step 1: Define an Order Type</h4><p>We’ll start by defining what an “order” really is — a simple function that compares two things:</p><pre>type Order&lt;T&gt; = (a: T, b: T) =&gt; number;</pre><p>This gives us a reusable shape to work with.</p><h4>Step 2: The make Function</h4><p>Almost every comparison function checks for equality first.<br>Instead of repeating that, let’s wrap it up in a helper:</p><pre>const make = &lt;T&gt;(compare: Order&lt;T&gt;): Order&lt;T&gt; =&gt; (a, b) =&gt; {<br>  if (a === b) return 0;<br>  return compare(a, b);<br>};</pre><p>Now we can define new orders without worrying about equality checks every time.</p><h4>Step 3: Reusable Orders for Common Types</h4><p>Here’s how easy it is now to define standard comparisons:</p><pre>const stringOrder: Order&lt;string&gt; = make((a, b) =&gt; a.localeCompare(b));<br>const numberOrder: Order&lt;number&gt; = make((a, b) =&gt; (a &lt; b ? -1 : 1));<br>const booleanOrder: Order&lt;boolean&gt; = make((a, b) =&gt; (a === false ? -1 : 1));<br>const dateOrder: Order&lt;Date&gt; = make((a, b) =&gt; (a.getTime() &lt; b.getTime() ? -1 : 1));</pre><p>Nice and tidy.<br>No boilerplate, no confusion.</p><h4>Step 4: Sorting by Object Properties with mapInput</h4><p>When you’re sorting objects, you often care about one property — like person.name.</p><p>Let’s create a function that maps an Order to a property getter:</p><pre>const mapInput = &lt;T, U&gt;(<br>  order: Order&lt;U&gt;,<br>  getter: (item: T) =&gt; U<br>): Order&lt;T&gt; =&gt;<br>  make((a, b) =&gt; order(getter(a), getter(b)));</pre><p>Now you can do this:</p><pre>const byName = mapInput(stringOrder, person =&gt; person.name);<br>const byDate = mapInput(dateOrder, person =&gt; person.createdAt);</pre><p>That’s already more declarative and readable.</p><h4>Step 5: Combining Multiple Orders</h4><p>Need to sort by multiple fields — say, name <em>then</em> date?<br>Let’s make a helper for that:</p><pre>const combine = &lt;T&gt;(...orders: Order&lt;T&gt;[]): Order&lt;T&gt; =&gt;<br>  make((a, b) =&gt; {<br>    for (const order of orders) {<br>      const result = order(a, b);<br>      if (result !== 0) return result;<br>    }<br>    return 0;<br>  });</pre><p>Now you can do:</p><pre>const byNameThenDate = combine(byName, byDate);<br>people.sort(byNameThenDate);</pre><p>Readable. Reusable. Beautiful.</p><h4>Step 6: Reverse Any Order</h4><p>Want to sort descending? No need to rewrite logic — just reverse it:</p><pre>const reverse = &lt;T&gt;(order: Order&lt;T&gt;): Order&lt;T&gt; =&gt;<br>  make((a, b) =&gt; order(b, a));</pre><p>Now:</p><pre>const byNameDesc = reverse(byName);<br>people.sort(byNameDesc);</pre><p>Simple and expressive.</p><h4>The Final Version</h4><p>Here’s what your sorting code could look like now:</p><pre>const byName = mapInput(stringOrder, p =&gt; p.name);<br>const byDate = mapInput(dateOrder, p =&gt; p.createdAt);<br>const byNameThenDate = combine(byName, byDate);<br><br>people.sort(byNameThenDate);</pre><p>So much cleaner, right?<br>No tangled callbacks. No redoing logic.<br>Just pure composability.</p><p>If you enjoyed this article, follow me for more posts on <strong>clean TypeScript design, functional patterns, and practical code architecture.</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=484a9a39cc66" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>