<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Fahad Khan</title>
    <description>The latest articles on DEV Community by Fahad Khan (@fahad_khan1226).</description>
    <link>https://dev.to/fahad_khan1226</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F2386347%2F099834da-b362-41b9-8baf-c839b6305d21.png</url>
      <title>DEV Community: Fahad Khan</title>
      <link>https://dev.to/fahad_khan1226</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/fahad_khan1226"/>
    <language>en</language>
    <item>
      <title>Debugging the invisible</title>
      <dc:creator>Fahad Khan</dc:creator>
      <pubDate>Wed, 30 Jul 2025 14:08:03 +0000</pubDate>
      <link>https://dev.to/fahad_khan1226/debugging-the-invisible-47dn</link>
      <guid>https://dev.to/fahad_khan1226/debugging-the-invisible-47dn</guid>
      <description>&lt;p&gt;So I was working on a side project during my leisure time and an interesting thing happened.&lt;/p&gt;

&lt;p&gt;I developed a grid layout with 2 columns at each row. worked as expected → big achievement :D&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F272q6uqx6m74uc0lzhhr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F272q6uqx6m74uc0lzhhr.png" alt=" " width="784" height="364"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here, I used an array of objects and iterated over it. Simple and straight forward work so far.&lt;/p&gt;

&lt;p&gt;Now, I knew that the description of each object can vary and the respective column should adapt to keep the UI visually appealing. Hence I added a random word — &lt;strong&gt;A SINGLE, LONG word&lt;/strong&gt; — without giving much notice to it and chaos followed.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
    description: "I have been involved asasasasasasasasasasasddasdasd"
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The result? Well…&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3n9ncgvq1i8ko0lflau7.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3n9ncgvq1i8ko0lflau7.webp" alt=" " width="715" height="364"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  The Frustration
&lt;/h2&gt;

&lt;p&gt;And the coffee cups started to pile up, sweat kicking in, what did I do wrong?&lt;/p&gt;

&lt;p&gt;Maybe…&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;some parent element is breaking the ui?&lt;/li&gt;
&lt;li&gt;do I need to revisit the basics?&lt;/li&gt;
&lt;li&gt;maybe if I restart?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;well folks, 15 minutes in, nothing seemed to work. so I started making the grid layout again from scratch!&lt;/p&gt;

&lt;p&gt;and it turns out its working FINE NOW!!&lt;/p&gt;

&lt;p&gt;WHAT?? AHHHHHHHHHHHH...&lt;/p&gt;

&lt;h2&gt;
  
  
  The Solution
&lt;/h2&gt;

&lt;p&gt;Mhm, no space between the word, hmm, A single word then, maybe if I… Woah!!&lt;/p&gt;

&lt;p&gt;Around 6 Months of experience as a MERN dev and I never knew :)&lt;/p&gt;

&lt;p&gt;so basically a single, long-enough word that exceeds the column length, will OVERFLOW.&lt;/p&gt;

&lt;p&gt;but wait, if it happens, do we not have a way around it? WE DO! Just use &lt;strong&gt;hyphens-auto&lt;/strong&gt; it ensures that if the word is long enough, it will be hyphenated to the next line.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvr0ujjxjmfiwls0ljubv.webp" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvr0ujjxjmfiwls0ljubv.webp" alt=" " width="719" height="366"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  The Lesson
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;Turns out, the real bug was my assumption. And the fix? Curiosity!&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;BEWARE FOLKS! Even a single word can break the UI, literally. Don’t just code, understand it.&lt;/p&gt;

&lt;p&gt;PS: Just sharing my experiences. much love :D&lt;/p&gt;

</description>
      <category>tailwindcss</category>
      <category>mern</category>
      <category>webdev</category>
      <category>programming</category>
    </item>
    <item>
      <title>Architectural Decision: Should Every Role Have Its Own Schema?</title>
      <dc:creator>Fahad Khan</dc:creator>
      <pubDate>Fri, 25 Jul 2025 19:41:21 +0000</pubDate>
      <link>https://dev.to/fahad_khan1226/architectural-decision-should-every-role-have-its-own-schema-186d</link>
      <guid>https://dev.to/fahad_khan1226/architectural-decision-should-every-role-have-its-own-schema-186d</guid>
      <description>&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ft1b1gmdr7fhouhdh3e2u.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ft1b1gmdr7fhouhdh3e2u.png" alt=" " width="800" height="365"&gt;&lt;/a&gt;&lt;strong&gt;Context:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;I'm working on a School ERP web application built using the MERN stack.&lt;br&gt;
We have a "users" schema that acts as a base model for various roles like:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Teachers&lt;/li&gt;
&lt;li&gt;Students&lt;/li&gt;
&lt;li&gt;Parents&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Each of these role-specific users has its own schema containing relevant information, built on top of the base "users" schema, ensuring separation of concerns.&lt;/p&gt;

&lt;p&gt;For example, the school owner is also a User, but they don’t require any additional information. In this case, the School schema simply contains a reference to the User who owns it.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;My Dilemma:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Now, I’ve been asked to implement a new role: "Sub-Admins".&lt;/p&gt;

&lt;p&gt;Here’s the catch:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Sub-admins don’t need any additional fields.&lt;/li&gt;
&lt;li&gt;They can be documented using the existing "users" schema.&lt;/li&gt;
&lt;li&gt;The only thing that distinguishes them is a field that references the school(s) they are associated with.&lt;/li&gt;
&lt;li&gt;Each school can have multiple sub-admins.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;My Questions :&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;So now I’m trying to decide:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Should I create a separate schema for sub-admins, just like I’ve done for teachers, students, and parents? Keeps the structure consistent -- Adds unnecessary complexity&lt;/li&gt;
&lt;li&gt;Should I simply add a new reference field (e.g., subAdminSchool) directly to the "users" schema? Simple and direct -- Might introduce confusion, since other roles don’t store extra fields inside users&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;I've confirmed that the sub-admin role is unlikely to need additional fields in the near future.&lt;/p&gt;

&lt;p&gt;Any advice, insights, or experiences would be highly appreciated. The coffee cups are piling up folks!! &lt;strong&gt;Thank you!!&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>mongodb</category>
      <category>systemdesign</category>
      <category>programming</category>
    </item>
    <item>
      <title>DSA progress log- Day 1</title>
      <dc:creator>Fahad Khan</dc:creator>
      <pubDate>Mon, 30 Jun 2025 08:42:29 +0000</pubDate>
      <link>https://dev.to/fahad_khan1226/dsa-progress-log-day-1-43ag</link>
      <guid>https://dev.to/fahad_khan1226/dsa-progress-log-day-1-43ag</guid>
      <description>&lt;p&gt;&lt;strong&gt;Problem:&lt;/strong&gt; Remove Duplicates from Sorted Array&lt;br&gt;
&lt;strong&gt;Platform:&lt;/strong&gt; LeetCode&lt;/p&gt;

&lt;p&gt;*&lt;em&gt;Problem statement: *&lt;/em&gt;&lt;br&gt;
Given an integer array nums sorted in non-decreasing order, remove the duplicates in-place such that each unique element appears only once. The relative order of the elements should be kept the same. Then return the number of unique elements in nums.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Approach:&lt;/strong&gt; Two Pointers&lt;br&gt;
We initialize two pointers a and b with 0 and 1 values repectively, than we iterate over the array one time, increment pointer b on each iteration, and increment pointer a once only if nums[a] &amp;lt; nums[b], since the array is in non-decreasing order.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Complexities&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Time - O(n)&lt;br&gt;
Space - O(1)&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Complete Guide Here:&lt;/strong&gt;&lt;br&gt;
&lt;a href="https://leetcode.com/problems/remove-duplicates-from-sorted-array/solutions/6901913/javascript-solution-by-fahad_khan1226-9sgn" rel="noopener noreferrer"&gt;https://leetcode.com/problems/remove-duplicates-from-sorted-array/solutions/6901913/javascript-solution-by-fahad_khan1226-9sgn&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;code&gt;var removeDuplicates = function(nums) {&lt;br&gt;
    let a = 0, b = 1;&lt;br&gt;
    while(b &amp;lt; nums.length) {&lt;br&gt;
        if(nums[a] &amp;lt; nums[b]) {&lt;br&gt;
            nums[++a] = nums[b];&lt;br&gt;
        }&lt;br&gt;
        b++;&lt;br&gt;
    }&lt;br&gt;
    return a + 1;&lt;br&gt;
};&lt;/code&gt;&lt;/p&gt;

</description>
      <category>programming</category>
      <category>dsa</category>
      <category>leetcode</category>
      <category>javascript</category>
    </item>
  </channel>
</rss>
