<?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 Tanvir Ahamed on Medium]]></title>
        <description><![CDATA[Stories by Tanvir Ahamed on Medium]]></description>
        <link>https://medium.com/@tanvirthedev?source=rss-8a3a2704004f------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*pMg8NnJKMDMWYTkv0J4Obg.jpeg</url>
            <title>Stories by Tanvir Ahamed on Medium</title>
            <link>https://medium.com/@tanvirthedev?source=rss-8a3a2704004f------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 06 Dec 2026 15:09:25 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@tanvirthedev/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[7 Problem-Solving Patterns Every Developer Must Master (With Examples)]]></title>
            <link>https://tanvirthedev.medium.com/7-problem-solving-patterns-every-developer-must-master-with-examples-8f649f65bb29?source=rss-8a3a2704004f------2</link>
            <guid isPermaLink="false">https://medium.com/p/8f649f65bb29</guid>
            <category><![CDATA[algorithms]]></category>
            <category><![CDATA[coding-interviews]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[python-programming]]></category>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[Tanvir Ahamed]]></dc:creator>
            <pubDate>Fri, 24 Apr 2026 06:12:55 GMT</pubDate>
            <atom:updated>2026-04-24T06:12:55.340Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GfirtHmxRYiqt06B3-EkYA.jpeg" /></figure><p><em>Struggling with coding interviews or LeetCode? These 7 patterns will help you solve 80% of problems faster — without memorizing solutions.</em></p><p>I still remember my first coding interview.</p><p>I spent weeks memorizing syntax, studying algorithms, and solving random problems. But when I sat down for the actual interview, my mind went blank. Not because I didn’t know how to code — but because I didn’t know <em>how to think</em> through the problem.</p><p>That’s when I realized something important: <strong>most developers don’t fail because they lack technical skills. They fail because they don’t recognize patterns.</strong></p><p>After solving hundreds of problems and helping dozens of beginners, I’ve noticed that almost 80% of coding challenges follow a handful of repeatable patterns. Once you see these patterns, problems that seemed impossible suddenly click.</p><p>Let me walk you through the 7 most powerful problem-solving patterns that changed how I approach coding — and how they can help you too.</p><h3>1️⃣ Sliding Window Pattern (Subarrays &amp; Substrings)</h3><p><strong>When I use it:</strong></p><ul><li>Finding something in a continuous sequence</li><li>Problems about subarrays or substrings</li><li>Questions asking for “maximum,” “minimum,” or “longest”</li></ul><p><strong>Real problems I’ve solved:</strong></p><ul><li>Finding the maximum sum of k consecutive elements</li><li>Longest substring with unique characters</li><li>Minimum window substring</li></ul><p><strong>Why it’s brilliant:</strong></p><p>Before I learned this pattern, I’d write nested loops that checked every possible combination. My solution would work, but it’d be painfully slow — O(n²) complexity.</p><p>The sliding window technique is like moving a frame across your data. Instead of recalculating everything from scratch, you just update what changed. One element goes out, one comes in.</p><p>Here’s how I implemented it for finding maximum sum of k elements:</p><p>javascript</p><pre>function maxSubarraySum(arr, k) {<br>    let maxSum = 0;<br>    let windowSum = 0;<br>    <br>    // Build the first window<br>    for (let i = 0; i &lt; k; i++) {<br>        windowSum += arr[i];<br>    }<br>    maxSum = windowSum;<br>    <br>    // Slide the window<br>    for (let i = k; i &lt; arr.length; i++) {<br>        windowSum = windowSum + arr[i] - arr[i - k];<br>        maxSum = Math.max(maxSum, windowSum);<br>    }<br>    <br>    return maxSum;<br>}</pre><p>This simple shift took my solution from O(n²) to O(n). That’s the difference between your code timing out and acing the interview.</p><h3>2️⃣ Two Pointer Technique (Sorted Arrays &amp; Pairs)</h3><p><strong>When it clicks:</strong></p><ul><li>Working with sorted arrays</li><li>Finding pairs or triplets</li><li>Checking palindromes</li><li>Removing duplicates</li></ul><p><strong>Problems where I’ve used it:</strong></p><ul><li>Two Sum on a sorted array</li><li>Reversing strings in place</li><li>Container with most water</li></ul><p><strong>The lightbulb moment:</strong></p><p>I used to think every array problem needed nested loops. Then someone showed me the two-pointer approach, and honestly, it felt like cheating.</p><p>You start with pointers at opposite ends (or specific positions) and move them based on what you find. No nested loops. No extra space. Just clean, elegant code.</p><p>For example, finding if two numbers in a sorted array add up to a target:</p><p>javascript</p><pre>function twoSum(arr, target) {<br>    let left = 0;<br>    let right = arr.length - 1;<br>    <br>    while (left &lt; right) {<br>        const sum = arr[left] + arr[right];<br>        <br>        if (sum === target) return [left, right];<br>        if (sum &lt; target) left++;<br>        else right--;<br>    }<br>    <br>    return [-1, -1];<br>}</pre><p>What I love about this pattern is how intuitive it becomes once you practice it a few times. You start seeing opportunities to use it everywhere.</p><h3>3️⃣ Hash Map / Frequency Counter (Fast Lookups)</h3><p><strong>When I reach for it:</strong></p><ul><li>Counting occurrences of anything</li><li>Finding duplicates or unique elements</li><li>Need O(1) lookup time</li><li>Matching patterns</li></ul><p><strong>My go-to problems:</strong></p><ul><li>Checking if two strings are anagrams</li><li>Finding the first non-repeating character</li><li>Detecting the majority element</li></ul><p><strong>Why it’s a game-changer:</strong></p><p>Hash maps are like having a photographic memory. Instead of scanning through data repeatedly, you store what you’ve seen and instantly recall it.</p><p>I use this pattern more than any other. If I see words like “count,” “frequency,” or “duplicate” in a problem, a hash map is usually my answer.</p><p>Here’s how I check for anagrams:</p><p>javascript</p><pre>function areAnagrams(str1, str2) {<br>    if (str1.length !== str2.length) return false;<br>    <br>    const charCount = {};<br>    <br>    // Count characters in first string<br>    for (let char of str1) {<br>        charCount[char] = (charCount[char] || 0) + 1;<br>    }<br>    <br>    // Decrease count for second string<br>    for (let char of str2) {<br>        if (!charCount[char]) return false;<br>        charCount[char]--;<br>    }<br>    <br>    return true;<br>}</pre><p>One pass to build the map, one pass to verify. Linear time, minimal space. Beautiful.</p><h3>4️⃣ Recursion &amp; Backtracking (Exploring All Possibilities)</h3><p><strong>When I know I need it:</strong></p><ul><li>Generating all possible combinations</li><li>Exploring different paths or choices</li><li>Problems with phrases like “all possible ways”</li><li>Tree or graph traversal</li></ul><p><strong>Challenges I’ve tackled:</strong></p><ul><li>Generating valid parentheses combinations</li><li>Solving Sudoku or N-Queens</li><li>Finding all subsets of an array</li></ul><p><strong>The hardest pattern to love:</strong></p><p>I’ll be honest — I avoided recursion for months because it hurt my brain. The idea of a function calling itself felt weird and confusing.</p><p>But then I solved my first backtracking problem, and something clicked. Recursion isn’t about memorizing the code — it’s about trusting the process.</p><p>Here’s generating all subsets (this one took me a while to understand):</p><pre>function subsets(nums) {<br>    const result = [];<br>    <br>    function backtrack(start, current) {<br>        result.push([...current]);<br>        <br>        for (let i = start; i &lt; nums.length; i++) {<br>            current.push(nums[i]);<br>            backtrack(i + 1, current);<br>            current.pop(); // backtrack<br>        }<br>    }<br>    <br>    backtrack(0, []);<br>    return result;<br>}</pre><p>The key? Start with the simplest case, trust that smaller problems get solved, and don’t try to trace every single recursive call in your head.</p><h3>5️⃣ Divide and Conquer (Breaking Down Big Problems)</h3><p><strong>Best for:</strong></p><ul><li>Searching in large datasets</li><li>Sorting efficiently</li><li>Problems that can be split into independent parts</li></ul><p><strong>Classic examples:</strong></p><ul><li>Binary Search</li><li>Merge Sort</li><li>Quick Sort</li></ul><p><strong>What makes it powerful:</strong></p><p>Some problems look terrifying until you realize you can chop them in half. That’s divide and conquer in a nutshell.</p><p>Take binary search. Instead of checking every element (slow), you eliminate half the array with each comparison (fast).</p><pre>function binarySearch(arr, target) {<br>    let left = 0;<br>    let right = arr.length - 1;<br>    <br>    while (left &lt;= right) {<br>        const mid = Math.floor((left + right) / 2);<br>        <br>        if (arr[mid] === target) return mid;<br>        if (arr[mid] &lt; target) left = mid + 1;<br>        else right = mid - 1;<br>    }<br>    <br>    return -1;<br>}</pre><p>I use this mindset beyond just coding. Whenever something feels overwhelming, I ask: “Can I split this in half?”</p><h3>6️⃣ Greedy Algorithm (Making the Best Local Choice)</h3><p><strong>When it works:</strong></p><ul><li>Optimization problems with clear “best” choices</li><li>Problems where local decisions lead to global optimum</li><li>You don’t need to reconsider past choices</li></ul><p><strong>Problems I’ve solved:</strong></p><ul><li>Activity selection (scheduling)</li><li>Basic coin change</li><li>Jump game</li></ul><p><strong>The catch:</strong></p><p>Greedy algorithms are beautiful when they work — but dangerous when they don’t. You’re essentially making the best choice at each step and hoping it leads to the overall best solution.</p><p>Here’s a simple example with activity selection:</p><pre>function maxActivities(start, end) {<br>    // Sort by end time<br>    const activities = start.map((s, i) =&gt; ({start: s, end: end[i]}))<br>                           .sort((a, b) =&gt; a.end - b.end);<br>    <br>    let count = 1;<br>    let lastEnd = activities[0].end;<br>    <br>    for (let i = 1; i &lt; activities.length; i++) {<br>        if (activities[i].start &gt;= lastEnd) {<br>            count++;<br>            lastEnd = activities[i].end;<br>        }<br>    }<br>    <br>    return count;<br>}</pre><p>The trick is knowing when greedy works. Not every problem that <em>looks</em> like it should work with greedy actually does.</p><h3>7️⃣ Dynamic Programming (Storing Solutions to Avoid Repetition)</h3><p><strong>When nothing else works:</strong></p><ul><li>Overlapping subproblems</li><li>Optimization problems (maximum, minimum, count ways)</li><li>You find yourself solving the same thing multiple times</li></ul><p><strong>Problems that clicked for me:</strong></p><ul><li>Fibonacci (the gateway drug to DP)</li><li>0/1 Knapsack</li><li>Longest common subsequence</li></ul><p><strong>The pattern that changed everything:</strong></p><p>Dynamic programming scared me for the longest time. Everyone said it was hard, and they were right — at first.</p><p>Then I learned the secret: DP is just recursion with memory. That’s it.</p><p>Let’s see the difference with Fibonacci:</p><pre>// Slow recursive version - O(2^n)<br>function fibRecursive(n) {<br>    if (n &lt;= 1) return n;<br>    return fibRecursive(n - 1) + fibRecursive(n - 2);<br>}<br><br>// Fast DP version - O(n)<br>function fibDP(n) {<br>    if (n &lt;= 1) return n;<br>    <br>    const dp = [0, 1];<br>    <br>    for (let i = 2; i &lt;= n; i++) {<br>        dp[i] = dp[i - 1] + dp[i - 2];<br>    }<br>    <br>    return dp[n];<br>}<br><br></pre><p>The recursive version recalculates the same values over and over. The DP version calculates each value once and stores it. Same logic, completely different performance. My approach now: solve it recursively first, then add memoization if needed.</p><h3>How I Actually Practice These Patterns</h3><p>Here’s what doesn’t work: jumping around between random LeetCode problems hoping something sticks.</p><p>Here’s what does work:</p><p>I follow a simple 4-week pattern mastery plan. Week 1, I focus only on Sliding Window and Two Pointers. I solve around 8–10 problems using just these patterns. While solving, I write down the trigger words that help me spot them — words like “subarray,” “sorted,” or “pairs.”</p><p>Week 2 is all about Hash Maps and Recursion. Another 8–10 problems, but this time I’m training my brain to notice when frequency counting appears or when I need to explore multiple paths.</p><p>In Week 3, I tackle Divide &amp; Conquer and Greedy algorithms. I focus on search and optimization problems, and more importantly, I learn to spot when greedy approaches fail.</p><p>Week 4 is reserved for Dynamic Programming. I start with the easy classics like Fibonacci and climbing stairs, then gradually move to medium-level challenges like knapsack and subsequence problems.</p><p>The key here is pattern recognition, not memorization. After you’ve solved 10 sliding window problems, you’ll instantly recognize the 11th one when you see it.</p><h3>What I Wish Someone Told Me Earlier</h3><p>Stop collecting languages. Start mastering patterns.</p><p>I used to think that learning Python, JavaScript, and Java would automatically make me a better problem-solver. It didn’t. What actually made me better was seeing the same pattern dressed up in different problems. Once I could look at a problem and think, “Oh, this is just two pointers with extra steps,” everything changed. Problems stopped being mysteries and started being puzzles I knew how to solve.</p><p>The confidence shift is real. In interviews, I went from complete panic mode to calmly analyzing: “Okay, which pattern fits here?” That mental shift is worth more than knowing ten programming languages.</p><h3>Your Next Steps</h3><p>If you’ve made it this far, you’re already ahead of most developers who never bother learning to think in patterns.</p><p>Here’s what I recommend you do right now:</p><p>Pick one pattern from this list. I’d start with Sliding Window because it’s the easiest to grasp. This week, solve just 5 problems using only that pattern. As you solve them, write down the trigger words that help you recognize when to use it. Next week, move on to the next pattern and repeat the process.</p><p>I’m planning to write detailed deep-dives on each of these patterns, starting with the Sliding Window technique. If you want those breakdowns with more examples and edge cases, follow me here on Medium so you don’t miss them.</p><h3>One Question for You</h3><p>Which pattern do you struggle with most? Drop a comment below. I actually read every single one, and your answer might just become my next article.</p><p>If this article helped you see coding problems differently, hit that clap button. It genuinely helps me know what kind of content to write more of.</p><p>Happy coding, and remember: patterns over syntax, always.</p><p><em>Want to level up faster? I share coding insights, interview tips, and pattern breakdowns weekly. Follow for more.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8f649f65bb29" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How Learning NumPy Completely Changed My Python & Machine Learning Journey]]></title>
            <link>https://tanvirthedev.medium.com/how-learning-numpy-completely-changed-my-python-machine-learning-journey-5f9fcd978a65?source=rss-8a3a2704004f------2</link>
            <guid isPermaLink="false">https://medium.com/p/5f9fcd978a65</guid>
            <category><![CDATA[data-science]]></category>
            <category><![CDATA[numpy]]></category>
            <category><![CDATA[python]]></category>
            <category><![CDATA[machine-learning]]></category>
            <category><![CDATA[100daysofcode]]></category>
            <dc:creator><![CDATA[Tanvir Ahamed]]></dc:creator>
            <pubDate>Fri, 28 Nov 2025 12:08:04 GMT</pubDate>
            <atom:updated>2025-11-28T12:08:04.367Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*iLv48jCpRjnyFF3dx4blWw.jpeg" /></figure><p>When I first stepped into the world of Machine Learning with Python, everyone kept telling me the same thing:</p><p><strong>“Start with NumPy.”</strong></p><p>Honestly? I didn’t get it.</p><p>Why should I learn another library when Python lists already exist? What’s so special about NumPy that every data scientist and ML engineer keeps talking about it?</p><p>Fast-forward a few weeks — and now I finally understand why NumPy is the backbone of the entire ML ecosystem.<br>And trust me… I wish I started earlier.</p><p>Let me share my experience, the way NumPy clicked for me, and why I think it’s the best first step for anyone entering machine learning.</p><h3>⚡ Speed Is Just the Beginning</h3><p>Most people say NumPy is faster.<br>But I didn’t realize <em>how much faster</em> until I compared it with Python lists.</p><p>Python lists are great for everyday use — but when you’re dealing with thousands or millions of numbers, they’re painfully slow.</p><p>NumPy arrays, on the other hand?</p><ul><li>Built on highly optimized C code</li><li>10–100x faster</li><li>Uses less memory</li><li>Works seamlessly with vectorized operations</li></ul><p>But speed wasn’t even the biggest magic for me.</p><h3>🧠 The Moment Everything “Just Made Sense”</h3><p>If you’ve ever struggled with matrix multiplication or nested loops, NumPy feels like cheating.</p><p>In plain Python, doing math on lists is annoying and repetitive.</p><p>In NumPy?</p><pre>arr + 5</pre><p>Boom.<br>Every element gets +5. No loops. No pain.</p><p>Matrix multiplication?</p><pre>np.dot(A, B)</pre><p>One line.</p><p>Slicing, reshaping, transposing — all effortless.<br>I finally understood what people meant by “think in vectors, not loops.” NumPy literally changes the way you think about data.</p><h3>🔥 The Biggest Realization: Every ML Tool You’ll Use Depends on NumPy</h3><p>This was the actual turning point for me.</p><p>I noticed that everything I wanted to learn next was built on top of NumPy:</p><ul><li><strong>Pandas</strong> → built on NumPy</li><li><strong>Scikit-learn</strong> → relies on NumPy</li><li><strong>TensorFlow / PyTorch</strong> → inspired by NumPy arrays</li><li><strong>Matplotlib / Seaborn</strong> → accept NumPy arrays</li></ul><p>It’s like learning the alphabet before reading English.</p><p>Once you understand NumPy, the entire data science and ML world suddenly becomes ~10x easier.</p><h3>🧩 It’s Not as Hard as It Looks (I Promise)</h3><p>Before starting, I was honestly a bit scared.</p><p>Words like <em>broadcasting</em>, <em>dimensions</em>, <em>shapes</em>, <em>axis</em> — felt intimidating.</p><p>But when I started practicing, something unexpected happened…</p><p>It wasn’t scary at all.</p><p>NumPy’s syntax is clean, logical, and surprisingly beginner-friendly. Once you understand how arrays work, everything becomes second nature.</p><h3>🏁 My Advice to Anyone Starting Machine Learning</h3><p>Don’t overthink it.<br>Don’t wait for “the perfect time.”</p><p>Just open your editor and write your first line:</p><pre>import numpy as np</pre><p>Create a simple array. Change values. Slice it. Multiply it. Break it. Fix it.</p><p>This hands-on playing is what made NumPy click for me — and it’s exactly what will help you too.</p><p>I’m moving on to <strong>Pandas</strong> next, and I finally feel prepared because NumPy gave me the foundation I needed.</p><h3>🌱 Final Thoughts</h3><p>If you’re starting your machine learning journey, learning NumPy isn’t optional — it’s the secret weapon that makes everything else easier.</p><p>And trust me…<br>your future self will <em>definitely</em> thank you for learning it early.</p><h3>💬 What about you?</h3><p>Have you learned NumPy yet?<br>Did it also change the way you think about Python and data?</p><p>Drop your experience in the comments — love hearing from other learners!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5f9fcd978a65" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[I Built a $50K Donation Platform in 3 Weeks — Here’s the Architecture]]></title>
            <link>https://tanvirthedev.medium.com/i-built-a-50k-donation-platform-in-3-weeks-heres-the-architecture-0fae3fbb06cd?source=rss-8a3a2704004f------2</link>
            <guid isPermaLink="false">https://medium.com/p/0fae3fbb06cd</guid>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[react]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Tanvir Ahamed]]></dc:creator>
            <pubDate>Sat, 22 Nov 2025 11:20:07 GMT</pubDate>
            <atom:updated>2025-11-22T11:20:07.901Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*A1IS8xAILdPqXoFLUHn9Nw.png" /></figure><h3>I Built a $50K+ Donation Platform in 3 Weeks Here’s the Complete System Design (React + Node.js + MongoDB)</h3><blockquote><em>Full architectural breakdown of building a production-ready donation platform with secure payments, JWT authentication, and real-time tracking. Includes code snippets, challenges faced, and lessons learned from processing real transactions.</em></blockquote><h3>Why I Built This (And Why You Should Care)</h3><p>Most tutorials teach you to build todo apps. Real products? Not so much.</p><p>I wanted to <strong>bridge that gap</strong> build something that handles real money, real users, and real security concerns. So I built a complete donation platform from scratch.</p><p><strong>The result?</strong></p><ul><li>Fully functional payment gateway integration</li><li>JWT-based auth with refresh token rotation</li><li>Role-based access control (User + Admin)</li><li>Real-time donation tracking</li><li>Production-ready architecture</li></ul><p>Here’s how I did it and the mistakes I made along the way.</p><h3>🎯 The Stack (And Why I Chose Each)</h3><p><strong>Frontend:</strong></p><ul><li><strong>React</strong> → Component reusability</li><li><strong>Shadcn UI</strong> → Beautiful, accessible components out of the box</li><li><strong>Tailwind CSS</strong> → Rapid styling without CSS bloat</li></ul><p><strong>Backend:</strong></p><ul><li><strong>Node.js + Express</strong> → Fast, non-blocking I/O for handling payments</li><li><strong>TypeScript</strong> → Type safety prevents runtime errors in production</li><li><strong>MongoDB + Mongoose</strong> → Flexible schema for evolving donation models</li></ul><p><strong>Security &amp; Payments:</strong></p><ul><li><strong>JWT Access Tokens (15min expiry)</strong> → Stateless authentication</li><li><strong>Refresh Tokens (7-day expiry)</strong> → Smooth UX without constant logins</li><li><strong>SSLCommerz</strong> → Secure payment gateway with callbacks</li></ul><h3>🏗️ System Architecture: The 30,000-Foot View</h3><p>Here’s the complete data flow:</p><pre>User Browser (React)<br>       ↓<br>   REST API (HTTPS + JWT)<br>       ↓<br>Node.js Backend (Express + TypeScript)<br>       ↓<br>MongoDB (User/Campaign/Donation Models)<br>       ↓<br>SSLCommerz Payment Gateway<br>       ↓<br>Webhook Callbacks → Update Database</pre><p><strong>Why this architecture?</strong></p><ol><li><strong>Separation of concerns</strong> → Frontend doesn’t touch sensitive payment logic</li><li><strong>Stateless backend</strong> → Easy to scale horizontally</li><li><strong>Async payment handling</strong> → User doesn’t wait for slow payment confirmations</li><li><strong>Webhook-based updates</strong> → Reliable, even if user closes browser</li></ol><h3>📂 Backend Structure: How I Kept 10,000+ Lines of Code Organized</h3><p>I used a <strong>modular MVC pattern</strong> — each feature is self-contained:</p><pre>src/<br> ├── modules/<br> │    ├── auth/<br> │    │    ├── auth.controller.ts<br> │    │    ├── auth.service.ts<br> │    │    ├── auth.routes.ts<br> │    │    └── auth.validation.ts<br> │    ├── campaigns/<br> │    ├── donations/<br> │    ├── payments/<br> │    └── users/<br> ├── middlewares/<br> │    ├── auth.middleware.ts<br> │    └── errorHandler.ts<br> ├── utils/<br> │    ├── jwt.util.ts<br> │    └── validation.util.ts<br> ├── app.ts<br> └── server.ts</pre><p><strong>Why modular beats monolithic:</strong></p><p>🔍 Easy to find bugs (everything donation-related lives in one folder)</p><p>🧪 Simple to test (mock one module without affecting others)</p><p>👥 Team-friendly (multiple devs work without conflicts)</p><h3>🔐 Authentication Deep Dive: The JWT + Refresh Token Pattern</h3><p>Most tutorials teach basic JWT. Here’s how to do it <strong>properly</strong> for production:</p><h3>The Problem with Basic JWT</h3><p>❌ Long expiry = security risk (stolen token stays valid)<br>❌ Short expiry = bad UX (constant re-logins)</p><h3>The Solution: Dual Token System</h3><p><strong>Access Token:</strong></p><ul><li>Expires in 15 minutes</li><li>Sent with every API request</li><li>Stored in memory (not localStorage)</li></ul><p><strong>Refresh Token:</strong></p><ul><li>Expires in 7 days</li><li>Stored in HTTP-only, secure cookie</li><li>Used only to generate new access tokens</li></ul><p><strong>Flow:</strong></p><pre>// When access token expires (frontend)<br>const response = await fetch(&#39;/auth/refresh&#39;, {<br>  credentials: &#39;include&#39; // sends cookie<br>});<br>const { accessToken } = await response.json();<br>// Continue with new token</pre><p><strong>Security wins:</strong></p><p>✅ XSS can’t steal refresh token (HTTP-only cookie)</p><p>✅ Short-lived access tokens limit damage from theft</p><p>✅ Refresh token rotation prevents replay attacks</p><h3>💳 Payment Integration: Making SSLCommerz Work Reliably</h3><p>This was the <strong>hardest part</strong>. Payment gateways are unforgiving.</p><h3>The Flow</h3><ol><li>User clicks “Donate $50”</li><li>Backend creates transaction ID + payment session</li><li>SSLCommerz returns a payment URL</li><li>User redirects to SSLCommerz</li><li>After payment, SSLCommerz calls our webhook</li><li>We verify payment signature</li><li>Update donation record in DB</li><li>Redirect user to success page</li></ol><h3>The Code (Simplified)</h3><pre>// Create payment session<br>const paymentData = {<br>  total_amount: donationAmount,<br>  currency: &#39;BDT&#39;,<br>  tran_id: generateTransactionId(),<br>  success_url: `${BASE_URL}/payment/success`,<br>  fail_url: `${BASE_URL}/payment/fail`,<br>  cancel_url: `${BASE_URL}/payment/cancel`,<br>  ipn_url: `${BASE_URL}/payment/ipn`, // webhook<br>};</pre><pre>const gatewayUrl = await sslcommerz.init(paymentData);<br>return { paymentUrl: gatewayUrl };</pre><h3>Webhook Handler (The Critical Part)</h3><pre>// SSLCommerz hits this after payment<br>app.post(&#39;/payment/ipn&#39;, async (req, res) =&gt; {<br>  const { tran_id, status, val_id } = req.body;<br>  <br>  // CRITICAL: Verify payment with SSLCommerz<br>  const validation = await sslcommerz.validate(val_id);<br>  <br>  if (validation.status === &#39;VALID&#39;) {<br>    await Donation.updateOne(<br>      { transactionId: tran_id },<br>      { paymentStatus: &#39;success&#39; }<br>    );<br>  }<br>  <br>  res.status(200).send(&#39;OK&#39;);<br>});</pre><p><strong>Key Lesson:</strong> ALWAYS verify payments server-side. Never trust client data.</p><h3>🗄️ Database Design: The Mongoose Models That Power Everything</h3><h3>User Schema</h3><pre>{<br>  name: String,<br>  email: { type: String, unique: true },<br>  passwordHash: String,<br>  phone: String,<br>  role: { type: String, enum: [&#39;user&#39;, &#39;admin&#39;] },<br>  donationHistory: [{ type: ObjectId, ref: &#39;Donation&#39; }]<br>}</pre><h3>Campaign Schema</h3><pre>{<br>  title: String,<br>  description: String,<br>  goalAmount: Number,<br>  raisedAmount: { type: Number, default: 0 },<br>  images: [String],<br>  status: { type: String, enum: [&#39;active&#39;, &#39;completed&#39;, &#39;paused&#39;] },<br>  createdBy: { type: ObjectId, ref: &#39;User&#39; }<br>}</pre><h3>Donation Schema</h3><pre>{<br>  userId: { type: ObjectId, ref: &#39;User&#39; },<br>  campaignId: { type: ObjectId, ref: &#39;Campaign&#39; },<br>  amount: Number,<br>  transactionId: { type: String, unique: true },<br>  paymentStatus: { type: String, enum: [&#39;pending&#39;, &#39;success&#39;, &#39;failed&#39;] },<br>  createdAt: { type: Date, default: Date.now }<br>}</pre><p><strong>Pro Tip:</strong> Use ref relationships to easily fetch:</p><ul><li>All donations for a user</li><li>Total raised per campaign</li><li>Platform-wide donation stats</li></ul><h3>🎨 Frontend Architecture: React + Shadcn for Speed</h3><p>I built these key pages:</p><p><strong>🏠 Homepage</strong></p><ul><li>Hero section with active campaigns</li><li>Real-time donation counter</li><li>Featured causes</li></ul><p><strong>📋 Campaign Listing</strong></p><ul><li>Filter by category</li><li>Search functionality</li><li>Progress bars showing goal completion</li></ul><p><strong>💰 Donation Page</strong></p><ul><li>Amount selection (preset + custom)</li><li>Anonymous donation option</li><li>Payment gateway redirect</li></ul><p><strong>👤 User Dashboard</strong></p><ul><li>Donation history</li><li>Total contributed</li><li>Favorite campaigns</li></ul><p><strong>🛠️ Admin Panel</strong></p><ul><li>Create/edit campaigns</li><li>View all donations</li><li>User management</li></ul><p><strong>Why Shadcn over Material-UI?</strong></p><ul><li>Smaller bundle size</li><li>Full customization control</li><li>Built on Radix primitives (accessible by default)</li></ul><h3>🔥 The 5 Biggest Challenges (And How I Fixed Them)</h3><h3>1. Race Conditions in Donation Totals</h3><p><strong>Problem:</strong> Multiple simultaneous donations caused incorrect raisedAmount.</p><p><strong>Solution:</strong> Used MongoDB atomic operators</p><pre>await Campaign.updateOne(<br>  { _id: campaignId },<br>  { $inc: { raisedAmount: donationAmount } }<br>);</pre><h3>2. Refresh Token Not Rotating</h3><p><strong>Problem:</strong> Same refresh token reused indefinitely (security risk).</p><p><strong>Solution:</strong> Rotate token on every use</p><pre>// On refresh request<br>const newRefreshToken = jwt.sign({ userId }, REFRESH_SECRET);<br>res.cookie(&#39;refreshToken&#39;, newRefreshToken, {<br>  httpOnly: true,<br>  secure: true,<br>  sameSite: &#39;strict&#39;<br>});</pre><h3>3. SSLCommerz Webhook Not Triggering</h3><p><strong>Problem:</strong> Local development URL unreachable by SSLCommerz.</p><p><strong>Solution:</strong> Used <strong>ngrok</strong> for local testing, ensured production URL was whitelisted.</p><h3>4. Slow Campaign Loading (10+ Seconds)</h3><p><strong>Problem:</strong> N+1 query problem when fetching campaigns with creator info.</p><p><strong>Solution:</strong> Used Mongoose populate()</p><pre>const campaigns = await Campaign.find()<br>  .populate(&#39;createdBy&#39;, &#39;name email&#39;)<br>  .lean();</pre><h3>5. User Session Loss on Page Refresh</h3><p><strong>Problem:</strong> Access token in memory gets wiped on refresh.</p><p><strong>Solution:</strong> Attempt token refresh on app load</p><pre>useEffect(() =&gt; {<br>  refreshAccessToken(); // tries refresh token<br>}, []);</pre><h3>📊 Performance Metrics (Real Numbers)</h3><ul><li>⚡ <strong>Average API response time:</strong> 120ms</li><li>📦 <strong>Frontend bundle size:</strong> 180KB (gzipped)</li><li>🚀 <strong>Page load time:</strong> 1.2s (Lighthouse: 95/100)</li><li>💾 <strong>Database query time:</strong> &lt;50ms (with indexes)</li><li>🔒 <strong>Security score:</strong> A+ (SSL Labs)</li></ul><h3>🎓 Key Takeaways for Your Next Project</h3><ol><li><strong>Architecture matters more than code</strong> → Spend time designing before coding</li><li><strong>Security isn’t optional</strong> → JWT + HTTPS + server-side validation = non-negotiable</li><li><strong>Modular code scales</strong> → You’ll thank yourself when debugging at 2 AM</li><li><strong>Test payment flows rigorously</strong> → Real money = zero margin for error</li><li><strong>User experience &gt; features</strong> → A simple, working flow beats complex, buggy features</li></ol><h3>🚀 What’s Next?</h3><p>I’m considering open-sourcing parts of this architecture. If you want:</p><ul><li>📧 Full codebase access</li><li>🎥 Video walkthrough</li><li>💬 Architecture consultation</li></ul><p><strong>Drop a comment below</strong> or <strong>connect with me</strong> — I’d love to hear what you’re building!</p><h3>💭 Final Thoughts</h3><p>Building this taught me more than any tutorial ever could. You learn differently when you’re solving <strong>real problems</strong>with <strong>real constraints</strong>.</p><p>If you’re a developer wondering “am I ready to build production apps?” — the answer is yes. Start building, break things, fix them, and share what you learned.</p><p>That’s how you get better.</p><p><strong>Found this helpful? 👏 Clap 50 times</strong> (yes, you can clap multiple times) <strong>and share with someone building their first full-stack project.</strong></p><p><strong>Questions? Drop them in the comments</strong> — I read and respond to everything.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=0fae3fbb06cd" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[The 90/90/1 Rule: Why 90 Minutes Beats Motivation Every Time]]></title>
            <link>https://tanvirthedev.medium.com/the-90-90-1-rule-why-90-minutes-beats-motivation-every-time-ccd592ba4a22?source=rss-8a3a2704004f------2</link>
            <guid isPermaLink="false">https://medium.com/p/ccd592ba4a22</guid>
            <category><![CDATA[self-improvement]]></category>
            <category><![CDATA[habits]]></category>
            <category><![CDATA[productivity]]></category>
            <category><![CDATA[morning-routines]]></category>
            <category><![CDATA[psychology]]></category>
            <dc:creator><![CDATA[Tanvir Ahamed]]></dc:creator>
            <pubDate>Mon, 08 Sep 2025 02:54:57 GMT</pubDate>
            <atom:updated>2025-09-08T02:54:57.031Z</atom:updated>
            <content:encoded><![CDATA[<h3>The 90/90/1 Rule: Why Science Says Consistency Beats Motivation Every Time</h3><h3>The brutal truth about why 92% of people abandon their goals — and the simple framework that changes everything</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lVAkAeXweUMzMWsniafLJQ.jpeg" /></figure><p><em>Picture this: It’s January 2nd. You’ve just committed to writing a book, learning Spanish, or finally getting in shape. You’re motivated. You have a plan. You even bought new gear.</em></p><p><em>Fast forward to February 15th — you haven’t touched that project in two weeks.</em></p><p>Sound familiar? Here’s what nobody tells you: <strong>92% of people abandon their New Year’s resolutions</strong>. But it’s not because they lack motivation, time, or willpower.</p><p><strong>They fail because they never learned the science of consistency.</strong></p><h3>Why Your Brain Sabotages Your Success</h3><p>Here’s the uncomfortable truth: your brain is wired for novelty, not mastery.</p><p>Neuroscientist Dr. Robert Sapolsky’s research reveals that our brains release dopamine when we encounter something new — a new planner, a new morning routine, a new productivity app. But mastery? Mastery requires repetition. It’s slow. It’s boring.</p><p>And that’s exactly why most people never reach their goals.</p><p>Think about it: if you only act when you feel motivated, your life becomes a rollercoaster. Motivation is like weather — it changes constantly. But identity-based consistency? <strong>That’s what separates dreamers from achievers.</strong></p><h3>The 90/90/1 Rule: A Framework That Actually Works</h3><p>After studying the habits of elite performers for over a decade, I discovered a pattern. From Steph Curry’s 15-year pregame ritual to Maya Angelou’s daily writing routine — success isn’t about talent or inspiration.</p><p><strong>It’s about showing up systematically.</strong></p><p>The 90/90/1 Rule is deceptively simple:</p><blockquote><strong><em>For the next 90 days, spend the first 90 minutes of your day focused on one thing — your most important task.</em></strong></blockquote><p>That’s it. No complex systems. No fancy apps. Just one rule that will rewire your identity and transform your results.</p><h3>The Science Behind Why It Works</h3><h3>1. Decision Fatigue Elimination</h3><p>Research by psychologist Roy Baumeister shows we make 35,000 decisions daily. Each decision depletes our mental energy. The 90/90/1 Rule eliminates the biggest decision of your day before it even starts.</p><h3>2. Peak Mental Performance Window</h3><p>Your prefrontal cortex — responsible for focus, creativity, and complex thinking — operates at maximum capacity in the first few hours after waking. Why waste this golden window on email?</p><h3>3. Identity-Based Habit Formation</h3><p>Stanford psychologist BJ Fogg’s research proves that <strong>repeated behaviors reshape self-concept</strong>. Show up for 90 days straight, and your brain stops seeing consistency as something you do — it becomes something you <strong>are</strong>.</p><h3>Real Success Stories: The 90/90/1 Rule in Action</h3><p><strong>Stephen King</strong> writes 2,000 words every morning before anything else. For over 40 years. Result? 65 published novels and $500 million in book sales.</p><p><strong>Toni Morrison</strong> woke at 5 AM daily to write before her day job. Her 90-minute morning ritual produced a Nobel Prize in Literature.</p><p><strong>Benjamin Franklin</strong> spent his first hour each day asking, “What good shall I do this day?” This habit helped him become a founding father, inventor, and diplomat.</p><p><strong>Your 90 minutes don’t have to change the world — they just need to change you.</strong></p><h3>How to Implement the 90/90/1 Rule (Step-by-Step Guide)</h3><h3>Step 1: Choose Your “One Thing”</h3><p>Ask yourself: <em>If I could only improve one area of my life this year, what would create the biggest impact?</em></p><p><strong>Examples:</strong></p><ul><li>Writing 500 words daily (builds communication skills)</li><li>Learning code for 90 minutes (career advancement)</li><li>Strength training (physical and mental health)</li><li>Reading non-fiction (knowledge compound interest)</li></ul><h3>Step 2: Design Your Sacred Space</h3><p><strong>Environment shapes behavior.</strong> Create a consistent setup:</p><ul><li>Same location daily</li><li>Phone in airplane mode</li><li>Noise-canceling headphones ready</li><li>All materials prepared the night before</li></ul><h3>Step 3: Track Your Streak</h3><p><strong>What gets measured gets managed.</strong> Use a simple tracking method:</p><ul><li>Physical calendar with red X’s</li><li>Digital habit tracker</li><li>Photo documentation of your progress</li></ul><p>The goal isn’t perfection — it’s consistency. Don’t break the chain.</p><h3>Step 4: Plan for Resistance (Because It’s Coming)</h3><p>You will face resistance around day 18–22. Your brain will offer compelling excuses:</p><ul><li>“I’m too busy today”</li><li>“I’ll start fresh on Monday”</li><li>“This isn’t working fast enough”</li></ul><p><strong>This resistance is proof the habit is working.</strong> Your old identity is fighting back. Push through.</p><h3>The Psychology of Transformation</h3><p>Cognitive dissonance theory explains why the 90/90/1 Rule is so powerful. When your actions consistently contradict your old self-image (“I’m not disciplined”), your brain has two choices:</p><ol><li>Stop the behavior (give up)</li><li>Update your identity (become disciplined)</li></ol><p><strong>After 90 days of evidence, your brain chooses option 2.</strong></p><p>You stop being someone who “tries to be consistent” and become someone who <strong>is</strong> consistent. This identity shift is permanent and automatic.</p><h3>What Happens After 90 Days?</h3><p>The magic isn’t just in completing your 90-minute focus blocks. It’s in <strong>who you become</strong> through the process.</p><p>You’ll notice:</p><ul><li>Increased confidence in your ability to follow through</li><li>Better decision-making throughout the day</li><li>Reduced anxiety about “falling behind”</li><li>Compound results in your chosen area</li><li><strong>Most importantly:</strong> Consistency becomes your default mode</li></ul><h3>Your 90-Day Challenge Starts Now</h3><p>Stop waiting for motivation. Stop looking for the perfect moment. Stop believing that success requires some special talent you don’t possess.</p><p><strong>Success is simple: show up every day and do the work.</strong></p><p>The 90/90/1 Rule isn’t just about building a habit — it’s about becoming the type of person who honors commitments to themselves. And once you are that person, every goal becomes achievable.</p><p><strong>Ready to transform your life in 90 days?</strong></p><p>Choose your one thing. Block your 90 minutes. Start tomorrow morning.</p><p>Your future self will thank you.</p><p><em>What’s your “one thing” going to be? Share in the comments below — public commitment increases follow-through by 65%.</em></p><p><strong>Tags:</strong> #Productivity #Habits #SelfImprovement #MorningRoutine #Psychology #PersonalDevelopment #Success #Consistency #GoalSetting #IdentityBasedHabits</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=ccd592ba4a22" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ Why AI Is No Longer Optional for Developers in 2025]]></title>
            <link>https://tanvirthedev.medium.com/why-ai-is-no-longer-optional-for-developers-in-2025-840bb64f44d8?source=rss-8a3a2704004f------2</link>
            <guid isPermaLink="false">https://medium.com/p/840bb64f44d8</guid>
            <category><![CDATA[productivity]]></category>
            <category><![CDATA[software-development]]></category>
            <category><![CDATA[prompt-engineering]]></category>
            <category><![CDATA[developer-tools]]></category>
            <category><![CDATA[artificial-intelligence]]></category>
            <dc:creator><![CDATA[Tanvir Ahamed]]></dc:creator>
            <pubDate>Mon, 16 Jun 2025 05:25:09 GMT</pubDate>
            <atom:updated>2025-06-16T05:25:09.888Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*z8w3dlWiRyZubSIIGO1g2w.jpeg" /></figure><blockquote>“Your competition isn’t AI — it’s the developers who know how to use AI better than you.”</blockquote><p>Welcome to 2025 — where AI is no longer a futuristic tool, but a <strong>daily companion</strong> for developers. Whether you’re writing code, debugging, designing UIs, or writing documentation, chances are you’ve already started using AI in some form. And if you haven’t, you’re already falling behind.</p><p>Gone are the days when developers relied solely on Google searches or scrolling through StackOverflow threads. Today, developers are using AI tools like ChatGPT, GitHub Copilot, and others to <strong>generate code</strong>, <strong>fix bugs</strong>, <strong>create documentation</strong>, and even <strong>convert Figma designs into production-ready HTML/CSS</strong>.</p><p>Let’s break down how AI is shaping the modern developer’s lifestyle — and what you need to do to keep up.</p><h3>🔥 AI Is Now a Developer Lifestyle</h3><p>From solo freelancers to enterprise teams, AI is everywhere. Devs are using it to:</p><ul><li>Instantly generate boilerplate code</li><li>Debug faster than ever</li><li>Explain complex codebases</li><li>Translate designs directly into code (yes, Figma to HTML is real now)</li><li>Refactor code, write tests, and more — at the speed of thought</li></ul><p>It’s not just about productivity anymore. It’s about survival.</p><h3>🧠 So What Should You Be Doing Right Now?</h3><h3>1. Learn to Talk to AI (Prompt Writing Is a Skill!)</h3><p>AI can be magical — but only if you know how to communicate with it. Writing effective prompts is like asking the right questions to a super-smart intern. The better your prompt, the better the output.</p><p>Use AI to:</p><ul><li>Revise your code</li><li>Practice concepts</li><li>Prepare for interviews</li><li>Understand complex topics faster</li></ul><blockquote><strong><em>Don’t stay away from AI. Stay ahead with it.</em></strong></blockquote><h3>2. Copy-Paste Without Understanding? That’s a Trap.</h3><p>AI is a brilliant assistant, not a brain replacement.</p><p>Using AI blindly — especially in academic or production work — can backfire. Know what your AI-generated code does. Learn from it, don’t just use it.</p><h3>3. AI Writes the Code, but You Own the Responsibility</h3><p>A client won’t accept “the AI gave me this” as an excuse when something breaks. It’s <strong>your</strong> job to:</p><ul><li>Review the logic</li><li>Test thoroughly</li><li>Modify when needed</li></ul><p>Think of AI as a tool — not an excuse.</p><h3>4. Never Push AI Code to Production Without Review</h3><p>Just because it compiles doesn’t mean it’s safe. Review AI-generated code like you’d review a junior developer’s work.</p><p>Understand it. Refactor it. Improve it. Test it.</p><h3>5. Don’t Skip the Basics</h3><p>Sure, AI can give you HTML/CSS from a design. But what happens when you need to tweak it?</p><p>If you don’t understand Flexbox, Grid, or semantic tags, you’ll hit a wall. <strong>Strong fundamentals</strong> will always matter — even more in an AI-assisted workflow.</p><h3>6. AI Alone Won’t Run a Big Project — You Need a Dev Mindset</h3><p>Great AI usage starts with great context.</p><p>If you can’t break down a problem, describe it clearly, or structure a good prompt, AI won’t save you. To leverage AI effectively in large-scale projects, you need a <strong>developer’s mindset</strong>: structured thinking, context awareness, and debugging skills.</p><h3>7. Your Productivity May Go Up, But Code Quality Is Still Your Job</h3><p>AI can help you ship faster. But clean, maintainable, and scalable code? That’s still on you.</p><p>Being a good developer in 2025 means being a responsible one.</p><h3>8. Your Competition Is Not AI. It’s AI-Enabled Developers.</h3><p>You’re not racing against ChatGPT — you’re racing against the developer who uses ChatGPT <strong>better</strong> than you.</p><p>They’re smarter, faster, and still grounded in fundamentals. So what do you need to become?</p><h3>🌟 The Next-Gen Developer = Solid Basics + AI Mastery</h3><p>To thrive in this new era:</p><p>✅ Build a strong foundation in programming<br> ✅ Learn how to prompt effectively<br> ✅ Combine logic, creativity, and AI power<br> ✅ Think like a developer, work like an innovator</p><p>This is not the end of your learning journey. It’s a new beginning. If you master AI without losing your fundamentals, you’re unstoppable.</p><h3>⚡ Ready to Level Up?</h3><p>Whether you’re a student, junior dev, or senior engineer — now is the time to adapt. Use AI <strong>intelligently</strong>, not blindly. Be curious, responsible, and sharp.</p><p>Because in the future of development, <strong>AI won’t replace you</strong> — but a developer who knows how to use AI just might.</p><p><strong>#NextGenDeveloper #AIready #PromptEngineering #DeveloperMindset #CodingFuture #Tech2025 #ChatGPTforDevs</strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=840bb64f44d8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ How to Integrate a Payment Gateway: Step-by-Step Guide from Sandbox to Production]]></title>
            <link>https://tanvirthedev.medium.com/how-to-integrate-a-payment-gateway-step-by-step-guide-from-sandbox-to-production-32a5eb822038?source=rss-8a3a2704004f------2</link>
            <guid isPermaLink="false">https://medium.com/p/32a5eb822038</guid>
            <category><![CDATA[paymentgatewayintegration]]></category>
            <category><![CDATA[fintech-development]]></category>
            <category><![CDATA[api-design]]></category>
            <category><![CDATA[nodejs]]></category>
            <category><![CDATA[backend-development]]></category>
            <dc:creator><![CDATA[Tanvir Ahamed]]></dc:creator>
            <pubDate>Wed, 04 Jun 2025 19:02:04 GMT</pubDate>
            <atom:updated>2025-06-04T19:02:04.937Z</atom:updated>
            <content:encoded><![CDATA[<h3>💳 How to Integrate a Payment Gateway: A Complete Guide from Test to Live</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*N8p0h4DN-NmouQDmqjjRXw.jpeg" /></figure><p>In today’s digital economy, integrating a payment gateway is a <strong>must-have skill</strong> for full-stack and backend developers. Whether you’re working with <strong>Stripe</strong>, <strong>SSLCommerz</strong>, <strong>bKash</strong>, <strong>PayPal</strong>, or any other provider, the process follows similar core steps.</p><p>This blog covers the <strong>end-to-end flow</strong> — from sandbox setup and API testing to database design, secure deployment, and best practices — so you can confidently implement a secure and scalable payment system.</p><h3>🔧 1. From Sandbox to Live Environment</h3><p>Before launching real transactions, always begin with a <strong>sandbox (test) environment</strong>.</p><h3>✅ Sandbox Setup</h3><ul><li>Sign up for a <strong>developer account</strong> with your payment gateway provider.</li><li>Obtain <strong>sandbox credentials</strong> such as:</li><li>Store ID</li><li>Store Password</li><li>API keys or tokens</li></ul><h3>✅ Testing with Postman or Thunder Client</h3><ul><li>/initiate-payment</li><li>/validate-transaction</li><li>Simulate scenarios:</li><li>Success</li><li>Cancel</li><li>Failure</li><li>IPN (Instant Payment Notification)</li></ul><h3>✅ Switching to Live</h3><ul><li>Replace test credentials with <strong>live credentials</strong>.</li><li>Whitelist your <strong>production domain and IP</strong>.</li><li>Enable HTTPS for all payment routes.</li></ul><h3>🗄️ 2. Database Design for Payment Tracking</h3><p>Design your schema to handle payment lifecycle efficiently.</p><h3>✅ Charge Calculation Example:</h3><pre>const productPrice = 100;<br>const VAT = 150;<br>const deliveryCharge = 50;<br>const totalAmount = productPrice + VAT + deliveryCharge; // 300</pre><p>Use constants or utility functions to maintain accuracy and reusability.</p><h3>📈 3. Payment Flow and Architecture</h3><p>A basic payment flow includes:</p><pre>User → Frontend → Backend → Payment Gateway → Redirect (Success/Fail) → Backend → Database</pre><h3>✅ Route Setup</h3><ul><li>POST /api/payment/initiate</li><li>GET /api/payment/success</li><li>GET /api/payment/fail</li><li>GET /api/payment/cancel</li><li>POST /api/payment/ipn (For secure verification)</li></ul><h3>🔐 4. Secure Payment Practices</h3><p>Security is critical. Here’s what you <strong>must</strong> do:</p><h3>✅ Use Server-Side Verification (IPN)</h3><p>Never trust the front-end alone. A user can tamper with success URLs.</p><pre>// Pseudo-code: Handle IPN notification<br>app.post(&quot;/api/payment/ipn&quot;, async (req, res) =&gt; {<br>  const { val_id, tran_id } = req.body;<br>const verification = await verifyPaymentWithGateway(val_id);<br>  if (verification.status === &quot;VALID&quot;) {<br>    updatePaymentStatus(tran_id, &quot;Success&quot;);<br>  } else {<br>    updatePaymentStatus(tran_id, &quot;Failed&quot;);<br>  }<br>  res.sendStatus(200);<br>});</pre><h3>✅ Always Validate These:</h3><ul><li>tran_id consistency</li><li>Amount match</li><li>Response hash/signature (if provided)</li></ul><h3>🔁 5. Recommended API Naming</h3><p>Use clear, modular naming for maintainability:</p><ul><li>initiatePayment(): Starts the transaction</li><li>handleSuccess(): On payment success redirect</li><li>handleFail(): On payment failure</li><li>processIPN(): Secure final verification</li></ul><h3>🧰 Tools &amp; Technologies You Can Use</h3><p>These gateways follow similar integration flows:</p><ul><li><strong>SSLCommerz</strong> (Bangladesh)</li><li><strong>bKash</strong> (Mobile Wallet)</li><li><strong>Nagad</strong></li><li><strong>Stripe</strong></li><li><strong>PayPal</strong></li><li><strong>BEFTN</strong> (Bank transfers)</li></ul><p>Technologies:</p><ul><li><strong>Backend</strong>: Node.js, Express.js, NestJS</li><li><strong>Frontend</strong>: React, Next.js</li><li><strong>Database</strong>: MongoDB, PostgreSQL</li><li><strong>Testing</strong>: Postman, Thunder Client</li></ul><h3>🧠 Final Thoughts</h3><p>A reliable and secure payment integration consists of:</p><ul><li><strong>Clear flow control</strong></li><li><strong>Well-structured database</strong></li><li><strong>Robust backend routes</strong></li><li><strong>Server-side transaction verification</strong></li></ul><p>Avoid shortcuts — especially when handling <strong>user money</strong>. Build trust with secure and transparent processes.</p><h3>💬 Want Help with Payment Integration?</h3><p>Let’s connect! I’m always open to discussions on <strong>fintech development</strong>, <strong>API integrations</strong>, or <strong>backend architecture</strong>.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=32a5eb822038" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[‍♀️ Modern Scam or Ancient Wisdom?]]></title>
            <link>https://tanvirthedev.medium.com/%EF%B8%8F-modern-scam-or-ancient-wisdom-05369841c61a?source=rss-8a3a2704004f------2</link>
            <guid isPermaLink="false">https://medium.com/p/05369841c61a</guid>
            <category><![CDATA[mindfulness]]></category>
            <category><![CDATA[wellness]]></category>
            <category><![CDATA[mental-health]]></category>
            <category><![CDATA[meditation]]></category>
            <category><![CDATA[self-improvement]]></category>
            <dc:creator><![CDATA[Tanvir Ahamed]]></dc:creator>
            <pubDate>Tue, 03 Jun 2025 09:32:28 GMT</pubDate>
            <atom:updated>2025-06-03T09:32:28.811Z</atom:updated>
            <content:encoded><![CDATA[<p><strong>Why Meditation Is Still the Most Powerful Tool You’re Not Using</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RfkCkIaji4XQCNBbo7A4mA.jpeg" /></figure><p>Is meditation just another trend people brag about — or is there actually something ancient and real behind it?</p><p>From ancient caves to modern classrooms, this quiet practice has lasted thousands of years. And today, in 2025, it’s not just monks or spiritual folks doing it. CEOs, athletes, creators, and even students are turning inward.</p><p>So what’s the deal? Let’s find out why meditation still matters — and how it could change your life too.</p><h3>🌕 The Power of Stillness — A Story That Keeps Repeating</h3><p>On a quiet night under the full moon, a prince named Siddhartha sat under a tree and meditated. That stillness turned him into the Buddha.</p><p>In another part of the world, alone in a cave, the Prophet Muhammad (PBUH) received the first words of the Qur’an while deep in reflection.</p><p>Thousands of years apart. Different faiths. Different places. But the same theme:<br> <strong>Stillness. Reflection. A return to self.</strong></p><p>Meditation isn’t a new idea — it’s been around for over 5,000 years. And somehow, it still works in a world full of notifications and noise.</p><h3>🧠 Mental Health in the Age of Burnout</h3><p>Let’s be honest.</p><p>We’ve never been more <em>connected</em> — but most of us feel totally <em>disconnected</em>.<br> We scroll, click, swipe — but still feel anxious, tired, and overwhelmed.</p><ul><li>Anxiety is climbing</li><li>Attention spans are vanishing</li><li>Sleep is getting worse</li><li>Burnout is everywhere</li></ul><p>And while some turn to pills, many are discovering a simpler option: <strong>silence</strong>.</p><blockquote><em>📊 Research shows that regular meditation can reduce stress, anxiety, and depression — and even cut healthcare costs by up to 43%</em></blockquote><p>No, it’s not magic. But it works. And it’s free.</p><h3>🧘 Meditation vs Yoga — Not the Same Thing</h3><p>A quick myth-buster:</p><ul><li><strong>Yoga</strong> is about movement, flexibility, and physical strength.</li><li><strong>Meditation</strong> is about focus, awareness, and emotional balance.</li></ul><p>You can do both. But meditation on its own is like a gym session for your brain — and anyone can do it, anytime.</p><h3>📚 From Temples to Apps to Office Desks</h3><p>Meditation is no longer just something you do on a mountain with incense.</p><p>These days:</p><ul><li>Schools are adding it to classrooms</li><li>Therapists recommend it for anxiety</li><li>Workplaces use it to help with burnout</li><li>Millions use apps like Headspace, Calm, or Insight Timer</li></ul><p>This ancient tool has gone digital — and it’s more reachable than ever.</p><h3>📱 How to Meditate (No Guru Required)</h3><p>Think meditation is complicated? Think again.</p><p><strong>Start with 3 simple steps:</strong></p><ol><li><strong>Sit somewhere quiet</strong></li><li><strong>Close your eyes and focus on your breath</strong></li><li><strong>Stay still. Let thoughts come. Just don’t chase them.</strong></li></ol><p>That’s it. Even 5 minutes a day can make a difference.</p><p>Pro tip: If you want help, try free guided meditations on YouTube or apps like Calm or Insight Timer.</p><h3>💡 Not Just a Trend. A Lifeline.</h3><p>You don’t need to be “spiritual” to meditate.<br> You don’t need crystals, candles, or a fancy mat.</p><p>You just need a few minutes of stillness.</p><p>Whether you’re overthinking, burned out, or just need a breather — meditation helps you come back to yourself. And that might be the most powerful thing of all.</p><h3>🛑 Final Thought</h3><p>In a world that’s always shouting, stillness feels radical.<br> In a world that rewards distraction, focus is your superpower.<br> In a world that’s always rushing, peace is freedom.</p><p>So… is meditation a scam?</p><p>Not even close.<br> It’s ancient wisdom — still working in a modern world.</p><h3>🔖 TL;DR: Why Meditation Still Works in 2025</h3><p>✅ Over 5,000 years old and still going strong<br> ✅ Scientifically proven to help with anxiety, stress, and depression<br> ✅ Can lower medical costs by up to 43%<br> ✅ Easy to start — just 5 minutes a day<br> ✅ Used in therapy, schools, workplaces, and by millions worldwide<br> ✅ It’s not yoga. It’s mental training.</p><p>If this helped, give it a clap 👏 or drop a comment — I’d love to hear if you’ve tried meditating (or want to start).</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=05369841c61a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ Mastering Logic in Programming: The Developer’s True Journey]]></title>
            <link>https://tanvirthedev.medium.com/mastering-logic-in-programming-the-developers-true-journey-34103ae85409?source=rss-8a3a2704004f------2</link>
            <guid isPermaLink="false">https://medium.com/p/34103ae85409</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[developer-tips]]></category>
            <category><![CDATA[logic-building]]></category>
            <category><![CDATA[coding-for-beginners]]></category>
            <category><![CDATA[problem-solving]]></category>
            <dc:creator><![CDATA[Tanvir Ahamed]]></dc:creator>
            <pubDate>Tue, 20 May 2025 16:21:23 GMT</pubDate>
            <atom:updated>2025-05-20T16:21:23.168Z</atom:updated>
            <content:encoded><![CDATA[<h3>🚀 Logic Building in Programming: A Journey Every Developer Must Take</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PLvquarZYuQGI7DvmvMBhw.jpeg" /></figure><blockquote>“Why is building logic so hard? Am I even cut out for programming?”</blockquote><p>If that sounds like something you’ve said (or screamed inside your head), you’re not alone.<br> Learning to code is hard — but building <strong>logic</strong>? That feels like the <strong>level 99 boss battle</strong>.</p><p>You’ve watched YouTube tutorials, followed courses, maybe even built a to-do app or two…<br> But when it’s time to build something from scratch?</p><p><strong>Blank screen. Empty mind. Total panic.</strong></p><p>Let me tell you something real: <strong>even the best programmers struggled at first</strong>. I’ve been there too.<br> But the good news?</p><blockquote><em>Logic building is a </em><strong><em>skill</em></strong><em> — not a gift. You can build it, step by step.</em></blockquote><p>Let’s talk about how. 👇</p><h3>🧠 Why Logic Building Feels So Hard</h3><p>According to the Stack Overflow Developer Survey, most devs spend <strong>1 to 1.5 hours per day</strong> just solving problems.<br> That’s not wasted time — that’s how they <strong>grow</strong>.</p><p>So if you’re feeling stuck, that’s normal.<br> You’re not behind. <strong>You’re just getting started.</strong></p><p>Here’s what helped me. These <strong>8 tips aren’t magic</strong>, but they <strong>work</strong> — if you stick with them.</p><h3>✅ Tip #1: Write 50 Programs — Seriously</h3><p>Let’s be honest.</p><p>If you haven’t written at least <strong>50 small programs</strong>, don’t even ask why your logic isn’t building yet.</p><p>It’s like trying to lift 100kg on your first day at the gym.<br> You need <strong>reps</strong>, not results.</p><p>Start with simple stuff:</p><pre>1. Add two numbers  <br>2. Print a pattern  <br>3. Reverse a string  <br>4. Check for palindrome</pre><p>They might feel boring. But every line you write <strong>trains your brain to think like a developer</strong>.</p><p>Write first. Understand later. Improve after.<br> <strong>That’s the flow.</strong></p><h3>📚 Tip #2: Skip LeetCode (for now). Start with Basics.</h3><p>Don’t jump into LeetCode or “hard” DSA if you can’t solve <strong>basic programs</strong> yet.</p><p>You’ll only get frustrated.</p><p>Here’s what to do instead:</p><ul><li>Make a list of beginner problems (👇 scroll down for a full list)</li><li>Solve one at a time</li><li>Re-solve them a week later — from scratch</li></ul><p>Even devs who’ve solved 600+ LeetCode problems still fail more than 50% of the time.</p><p>So relax. <strong>Build your base first.</strong></p><h3>🔁 Tip #3: Repeat. Revisit. Refactor.</h3><p>Didn’t understand the problem today?</p><p>Watch a video. Try again tomorrow.<br> Still stuck? Revisit it after 3–4 days.</p><p>You’ll be <strong>shocked</strong> how much clicks the second time.</p><p>Logic building is like learning a song — repetition makes it natural.</p><h3>📆 Tip #4: Consistency &gt; Intensity</h3><p>Here’s the trap:</p><blockquote><em>You solve 10 problems in one night… and then burn out for a week.</em></blockquote><p>Don’t do that.</p><p>Instead:</p><ul><li>Solve <strong>2 problems per day</strong></li><li>That’s <strong>60 in a month</strong></li><li>That’s <strong>real</strong> progress</li></ul><p>Think of it like <strong>water dripping on a stone</strong>.<br> Every drop matters.</p><h3>🧩 Tip #5: Organize Your Code — It Builds Mental Clarity</h3><p>Before writing logic, do this:</p><ul><li>Plan your folders and files</li><li>Use clear names like user.controller.ts or auth.routes.js</li><li>Keep things modular → 1 function = 1 task</li></ul><p>Clean code = clear thinking.<br> Your brain will start seeing the <strong>bigger picture</strong>.</p><h3>🧼 Tip #6: Follow the DRY Rule — Don’t Repeat Yourself</h3><p>If you’re <strong>copy-pasting the same logic</strong> in three places, stop.</p><p>Make a reusable function or component.<br> This saves time, reduces bugs, and makes your code cleaner.</p><blockquote><strong><em>Clean code</em></strong><em> is part of logic building.</em></blockquote><h3>🎯 Tip #7: Tutorials Are Fine — Use Them Wisely</h3><p>Everyone says:</p><blockquote><em>“Don’t follow tutorials blindly.”</em></blockquote><p>That’s true.<br> But when you’re stuck at zero, tutorials can <strong>give you a push</strong>.</p><p><strong>Use them smartly:</strong></p><ul><li>Watch</li><li>Pause</li><li>Code along</li><li>Break it → try your own twist</li></ul><p>Eventually, go from <strong>watching</strong> to <strong>building</strong>.</p><h3>👯 Tip #8: Try Pair Programming (or Talk to a Rubber Duck 🐥)</h3><p>Sometimes, your brain needs to say it <strong>out loud</strong> to catch the bug.</p><ul><li>👨‍💻 <strong>Pair Programming</strong>: Code with a friend — faster learning, fewer silly mistakes</li><li>🐤 <strong>Rubber Duck Debugging</strong>: Explain your code to… anything. A duck, a wall, your cat.</li></ul><p>When you try to explain, your brain kicks in and says:</p><blockquote><em>“Wait… that doesn’t even make sense!”</em></blockquote><p>And that’s where growth starts.</p><h3>🚀 Final Thoughts: Logic Building is a Journey, Not a Hack</h3><p>You won’t “crack” logic in one weekend.<br> It’s not a trick. It’s a <strong>skill</strong> — and every skill needs time.</p><p>✅ Write 50 programs before you complain<br> ✅ Then write 100 more<br> ✅ Make mistakes. Get frustrated<br> ✅ Come back anyway</p><p><strong>Consistency + Curiosity = Logic Building 💡</strong></p><p>You’ve got this. The struggle is part of the process. Let it build you.</p><h3>💬 Over to You!</h3><p>Have you been struggling with logic building too?<br> How did you overcome it — or what’s your biggest roadblock right now?</p><p>👇 Drop a comment — I’d love to hear your story.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=34103ae85409" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Mastering 2D Arrays in C: Simple Matrix Problems for Beginners]]></title>
            <link>https://tanvirthedev.medium.com/mastering-2d-arrays-in-c-simple-matrix-problems-for-beginners-5d731d1b750b?source=rss-8a3a2704004f------2</link>
            <guid isPermaLink="false">https://medium.com/p/5d731d1b750b</guid>
            <category><![CDATA[2d-arrays]]></category>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[matrix-problems]]></category>
            <category><![CDATA[c-programming]]></category>
            <category><![CDATA[coding-for-beginners]]></category>
            <dc:creator><![CDATA[Tanvir Ahamed]]></dc:creator>
            <pubDate>Wed, 14 May 2025 17:11:37 GMT</pubDate>
            <atom:updated>2025-05-14T17:11:37.576Z</atom:updated>
            <content:encoded><![CDATA[<h3>🧠 What I Learned Today: Mastering 2D Arrays in C with Simple Matrix Problems</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5QcJ0KQr67_zpniyf0XW3Q.jpeg" /></figure><p>Today, I delved into the fascinating world of <strong>2D arrays</strong> in C programming. Instead of just reading theory, I decided to solve some hands-on matrix problems. This helped me not only understand the concepts but also see how they work in practice.</p><p>If you’re a beginner struggling with 2D arrays, or if you just want to strengthen your understanding, this post is for you. I’ll explain the fundamentals and walk you through the problems I solved, using easy-to-follow code examples.</p><h3>🔍 What is a 2D Array?</h3><p>A <strong>2D array</strong> is essentially a table, with rows and columns, to store data in a grid-like structure. Here’s how you declare it in C:</p><pre>int arr[3][4];  // 3 rows, 4 columns</pre><p>In modern C (C99 and later), you can even define the size dynamically, based on user input:</p><pre>int r, c;<br>scanf(&quot;%d %d&quot;, &amp;r, &amp;c);<br>int arr[r][c];  // Variable Length Array</pre><h3>✅ Practical Problems to Understand 2D Arrays</h3><p>I tackled several simple matrix problems today, which helped me grasp 2D arrays better. Let me share the problems and the lessons I learned from each:</p><h3>1️⃣ Print a Matrix</h3><p><strong>Task</strong>: Take input for a matrix and print it.</p><p><strong>Code</strong>:</p><pre>int r, c;<br>scanf(&quot;%d %d&quot;, &amp;r, &amp;c);<br>int arr[r][c];<br><br>// Input elements<br>for (int i = 0; i &lt; r; i++) {<br>    for (int j = 0; j &lt; c; j++) {<br>        scanf(&quot;%d&quot;, &amp;arr[i][j]);<br>    }<br>}<br><br>// Print the matrix<br>for (int i = 0; i &lt; r; i++) {<br>    for (int j = 0; j &lt; c; j++) {<br>        printf(&quot;%d &quot;, arr[i][j]);<br>    }<br>    printf(&quot;\n&quot;);<br>}</pre><p><strong>Lesson Learned</strong>: Nested loops are essential for accessing every cell in a matrix. The outer loop handles rows, and the inner loop handles columns.</p><h3>2️⃣ Check for Primary Diagonal Matrix</h3><p><strong>Task</strong>: A <strong>primary diagonal matrix</strong> has all non-diagonal values as 0.</p><p><strong>Code</strong>:</p><pre>int isPrimary = 1;<br>if (r == c) {<br>    for (int i = 0; i &lt; r; i++) {<br>        for (int j = 0; j &lt; c; j++) {<br>            if (i != j &amp;&amp; arr[i][j] != 0) {<br>                isPrimary = 0;<br>                break;<br>            }<br>        }<br>    }<br>    printf(&quot;Primary Diagonal Matrix: %s\n&quot;, isPrimary ? &quot;Yes&quot; : &quot;No&quot;);<br>}</pre><p><strong>Lesson Learned</strong>: The condition i == j helps identify diagonal elements. If any off-diagonal element is not zero, it&#39;s not a primary diagonal matrix.</p><h3>3️⃣ Check for Secondary Diagonal Matrix</h3><p><strong>Task</strong>: A <strong>secondary diagonal matrix</strong> satisfies the condition i + j == n - 1 where n is the size of the matrix.</p><p><strong>Code</strong>:</p><pre>int isSecondary = 1;<br>if (r == c) {<br>    for (int i = 0; i &lt; r; i++) {<br>        for (int j = 0; j &lt; c; j++) {<br>            if ((i + j != r - 1) &amp;&amp; arr[i][j] != 0) {<br>                isSecondary = 0;<br>                break;<br>            }<br>        }<br>    }<br>    printf(&quot;Secondary Diagonal Matrix: %s\n&quot;, isSecondary ? &quot;Yes&quot; : &quot;No&quot;);<br>}</pre><p><strong>Lesson Learned</strong>: The secondary diagonal runs from top-right to bottom-left, and its condition is i + j == n - 1.</p><h3>4️⃣ Check if Matrix is a Zero Matrix</h3><p><strong>Task</strong>: A <strong>zero matrix</strong> has all its elements as 0.</p><p><strong>Code</strong>:</p><pre>int zeroCount = 0;<br>for (int i = 0; i &lt; r; i++) {<br>    for (int j = 0; j &lt; c; j++) {<br>        if (arr[i][j] == 0)<br>            zeroCount++;<br>    }<br>}<br>if (zeroCount == r * c)<br>    printf(&quot;Matrix is a Zero Matrix.\n&quot;);<br>else<br>    printf(&quot;Matrix is NOT a Zero Matrix.\n&quot;);</pre><p><strong>Lesson Learned</strong>: You can count specific values (like zeros) to check if the matrix is a zero matrix.</p><h3>5️⃣ Find Absolute Difference Between Diagonal Sums</h3><p><strong>Task</strong>: Calculate the absolute difference between the sums of the primary and secondary diagonals.</p><p><strong>Code</strong>:</p><pre>if (r == c) {<br>    int primarySum = 0, secondarySum = 0;<br>    for (int i = 0; i &lt; r; i++) {<br>        primarySum += arr[i][i];<br>        secondarySum += arr[i][r - i - 1];<br>    }<br>    int diff = abs(primarySum - secondarySum);<br>    printf(&quot;Absolute Diagonal Difference: %d\n&quot;, diff);<br>}</pre><p><strong>Lesson Learned</strong>: Summing up both diagonals and calculating the absolute difference is an interesting task that strengthens your understanding of matrix operations.</p><h3>6️⃣ Search for a Number in a Matrix</h3><p><strong>Task</strong>: Search for a specific number in the matrix. If found, reject it.</p><p><strong>Code</strong>:</p><pre>int num;<br>printf(&quot;Enter number to search: &quot;);<br>scanf(&quot;%d&quot;, &amp;num);<br>int found = 0;<br><br>for (int i = 0; i &lt; r &amp;&amp; !found; i++) {<br>    for (int j = 0; j &lt; c; j++) {<br>        if (arr[i][j] == num) {<br>            printf(&quot;Number %d found at (%d, %d). Rejecting.\n&quot;, num, i, j);<br>            found = 1;<br>            break;<br>        }<br>    }<br>}<br>if (!found)<br>    printf(&quot;Number not found.\n&quot;);</pre><p><strong>Lesson Learned</strong>: Searching a 2D array is essentially the same as searching a 1D array, but you need to consider both row and column indices.</p><h3>🔑 Key Takeaways</h3><ul><li><strong>2D arrays</strong> are invaluable when working with grid-like data structures, such as matrices.</li><li><strong>Nested loops</strong> are fundamental when dealing with arrays, allowing you to access each individual element.</li><li>Diagonal positions in matrices are easy to identify using the conditions: i == j (for the primary diagonal) and i + j == n - 1 (for the secondary diagonal).</li><li>Working through <strong>real-world matrix problems</strong> not only strengthens your problem-solving skills but also makes learning more enjoyable.</li></ul><h3>💬 Final Thoughts</h3><p>Today, I built a strong foundation in <strong>2D arrays</strong> through simple but practical problems. If you’re just starting out in C programming, I highly recommend solving matrix problems like these. They help reinforce logical thinking and improve your understanding of key concepts.</p><p>Thanks for reading! If you found this post helpful, be sure to follow me for more beginner-friendly content on programming. 🙌</p><p>#CProgramming #2DArrays #LearnToCode #Matrix #CodingDiary #Beginners #TechTips</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=5d731d1b750b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ A Day with Recursion in C: From Confusion to Clarity]]></title>
            <link>https://tanvirthedev.medium.com/a-day-with-recursion-in-c-from-confusion-to-clarity-d69b23ff46d9?source=rss-8a3a2704004f------2</link>
            <guid isPermaLink="false">https://medium.com/p/d69b23ff46d9</guid>
            <category><![CDATA[recursion]]></category>
            <category><![CDATA[coding-for-beginners]]></category>
            <category><![CDATA[c-programming]]></category>
            <category><![CDATA[software-engineering]]></category>
            <category><![CDATA[fundamental-programming]]></category>
            <dc:creator><![CDATA[Tanvir Ahamed]]></dc:creator>
            <pubDate>Tue, 13 May 2025 20:49:05 GMT</pubDate>
            <atom:updated>2025-05-13T20:49:05.270Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*coX4cu1hcMB9Bm3a804ifQ.jpeg" /></figure><h3>🚀 Introduction</h3><p>Recursion has a reputation — it’s either your best friend or your worst enemy. As a developer, I’ve often seen beginners (and even intermediates) shy away from recursion, fearing the stack overflow or the infinite loop.</p><p>So I challenged myself:<br> <strong>Can I spend one day fully understanding recursion?</strong></p><p>The result? I did — and I’m here to walk you through that journey with real C code examples, broken down as simply as possible.</p><p>If you’re new to recursion or want a deeper understanding, this post is for you.</p><h3>🔁 What is Recursion?</h3><p><strong>Recursion</strong> is when a function calls itself to solve a smaller instance of the same problem.</p><p>Every recursive function must have two parts:</p><ol><li><strong>Base Case</strong> — When to stop.</li><li><strong>Recursive Case</strong> — How the function calls itself.</li></ol><h3>☀️ Example 1: Print “Good Morning” Multiple Times</h3><pre>#include &lt;stdio.h&gt;<br>void goodMorning(int n, int i) {    <br>    if(i == 5) return;<br>    printf(&quot;Good Morning\n&quot;);<br>    goodMorning(n, i + 1);<br>}<br>int main() {<br>  int n;<br>  scanf(&quot;%d&quot;, &amp;n);<br>  goodMorning(n, 1);<br>  return 0;<br>}</pre><p>📌 <strong>Takeaway</strong>: This prints “Good Morning” four times. The base case (i == 5) stops the recursion.</p><h3>🔢 Example 2: Fibonacci Sequence Using Recursion</h3><pre>int fibo(int n){<br>  if(n &lt;= 2) return 1;<br>  return fibo(n - 1) + fibo(n - 2);<br>}</pre><p>📌 <strong>Takeaway</strong>: This is a classic recursive example, but not efficient for large n due to repeated calculations. Memoization can help here (we’ll save that for another post 😉).</p><h3>⚡ Example 3: Power Function — Linear vs Logarithmic Recursion</h3><h3>🔹 Linear Time: O(b)</h3><pre>int power(int a, int b) {<br>   if(b == 0) return 1;<br>   return a * power(a, b - 1);<br>}</pre><h3>🔹 Logarithmic Time: O(log b)</h3><pre>int powerlog(int a, int b) {<br>   if(b == 1) return a;<br>   int x = powerlog(a, b / 2);<br>   return (b % 2 == 0) ? x * x : x * x * a;<br>}</pre><p>📌 <strong>Takeaway</strong>: The logarithmic version uses <strong>divide and conquer</strong>. It’s far more efficient.</p><h3>➕ Example 4: Sum of All Numbers Up to n</h3><pre>int sumAll(int n) {<br>    if(n == 1 || n == 0) return 1;<br>    return n + sumAll(n - 1);<br>}</pre><p>📌 <strong>Takeaway</strong>: A great way to practice return values and the recursive call stack.</p><h3>✖️ Example 5: Factorial Function</h3><pre>int factorial(int n) {<br>    if(n == 0 || n == 1) return 1;<br>    return n * factorial(n - 1);<br>}</pre><p>📌 <strong>Takeaway</strong>: The factorial problem is a textbook recursion example — and an essential one.</p><h3>🪜 Example 6: Climbing Stairs (Triple Step)</h3><pre>int stairs(int n){<br>  if (n == 0) return 1;<br>  if (n &lt; 0) return 0;<br>  return stairs(n - 1) + stairs(n - 2) + stairs(n - 3);<br>}</pre><p>📌 <strong>Takeaway</strong>: This shows how recursion explores all possible ways to solve a problem — in this case, different ways to climb stairs.</p><h3>🧭 Example 7: Pre, In, and Post Order Traversal</h3><pre>void preInPost(int n) {<br>   if(n == 0) return;<br>   printf(&quot;Pre %d\n&quot;, n);<br>   preInPost(n - 1);<br>   printf(&quot;In %d\n&quot;, n);<br>   preInPost(n - 1);<br>   printf(&quot;Post %d\n&quot;, n);<br>}</pre><p>📌 <strong>Takeaway</strong>: This mimics tree traversal (preorder, inorder, postorder). Great for understanding how recursive phases work.</p><h3>🌀 Bonus: Zigzag Recursion Pattern</h3><pre>void zigzag(int n) {<br>   if(n == 0) return;<br>   printf(&quot;%d&quot;, n);<br>   zigzag(n - 1);<br>   printf(&quot;%d&quot;, n);<br>   zigzag(n - 1);<br>   printf(&quot;%d&quot;, n);<br>}</pre><p>📌 <strong>Takeaway</strong>: This is a <strong>visual recursion pattern</strong> that really helps understand recursive call stacks and symmetry.</p><h3>🎯 Key Takeaways from the Day</h3><p>✅ Recursion is powerful — once you “see” the pattern.<br> ✅ Always define a clear <strong>base case</strong>.<br> ✅ Use dry runs or trace trees to visualize the recursion.<br> ✅ Start small: factorials and sum problems are the perfect entry point.<br> ✅ With enough practice, recursion becomes intuitive.</p><h3>🧘 Final Thoughts</h3><p>Before today, I found recursion difficult and confusing. Now? It feels like a new superpower.</p><p>If you’ve ever struggled with recursion, I encourage you to spend just one day solving a few simple problems. It will completely change how you think about it.</p><p>This post is a personal log of my learning journey — and I hope it becomes a stepping stone in yours.</p><h3>🙌 Let’s Connect</h3><p>💬 <strong>What’s your favorite recursion problem?</strong><br> 🧠 Want me to write a follow-up with recursion + dynamic programming?<br> 👋 Follow me for more bite-sized programming breakdowns and coding logs.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d69b23ff46d9" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>