<?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 Lasanya Premarathne on Medium]]></title>
        <description><![CDATA[Stories by Lasanya Premarathne on Medium]]></description>
        <link>https://medium.com/@kldpremarathne?source=rss-74dfda7d627b------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*tbcMByiSUAEKa7HS</url>
            <title>Stories by Lasanya Premarathne on Medium</title>
            <link>https://medium.com/@kldpremarathne?source=rss-74dfda7d627b------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 02 Dec 2026 10:45:17 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@kldpremarathne/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[The Reality of Working on My Final Year Project]]></title>
            <link>https://medium.com/@kldpremarathne/the-reality-of-working-on-my-final-year-project-146c19b3a5db?source=rss-74dfda7d627b------2</link>
            <guid isPermaLink="false">https://medium.com/p/146c19b3a5db</guid>
            <category><![CDATA[final-year-projects]]></category>
            <category><![CDATA[project-proposal]]></category>
            <dc:creator><![CDATA[Lasanya Premarathne]]></dc:creator>
            <pubDate>Sat, 14 Nov 2026 12:56:01 GMT</pubDate>
            <atom:updated>2026-11-14T12:56:01.680Z</atom:updated>
            <content:encoded><![CDATA[<p><em>Some days you feel like you’ve finally figured something out. And the next day, it feels like you’re back at square one.</em></p><p>Working on my final-year project while having a full-time job and a few other things have been quite an experience.</p><p>Our semester started around the last week of September, and the proposal submission deadline was on November 5.</p><p>On Mondays, we have lectures.</p><p>Tuesdays, I usually have supervisor meetings around 5 PM. After the meetings, I’d spend some more time working on my research until around 7:30 PM.</p><p>Wednesdays were another day when I’d try to get some university work done.</p><p>Thursdays and Fridays, I’m too busy wondering when the week will end.</p><p>On Saturdays, I usually spent most of my time working on research and catching up on other university-related work.</p><p>Sundays are for running and sleeping mostly, and if time permits after all that, then I do some work.</p><p>It wasn’t always easy to find the time, but I tried to get something done whenever I could.</p><h3>The research process isn’t always straightforward</h3><p>And honestly, working on the final-year project hasn’t always been easy.</p><p>Some days, I end up working happily, thinking I’ve finally figured something out. Like, okay, this makes sense now. I’m actually getting somewhere.</p><p>And then the next day, I feel like I’ve fallen straight back to square one.</p><p>Suddenly, everything I thought I had figured out seems wrong, and whatever progress I made so far feels almost useless.</p><p>It’s a weird feeling, especially when you’re already trying to fit everything into a limited amount of time.</p><p>You spend hours trying to understand something, and just when you think you’ve got it, you realise there’s something else you haven’t considered.</p><p>Some days, you make progress. Other days, you spend just as much time trying to understand why something you thought was correct doesn’t actually work.</p><p>And I guess that’s part of working on something that you don’t entirely know how to solve yet.</p><h3>The last few days before submission</h3><p>The last few days leading up to the proposal submission were probably the most intense.</p><p>I was running on around two hours of sleep a day at some point. It was honestly insane.</p><p>It was mentally draining, especially when I still had to manage work and everything else happening during the day.</p><p>I knew I wasn’t getting enough sleep, and I also knew that working out with that little sleep wasn’t healthy.</p><p>But I did need that mental break.</p><p>I don’t think I could have lasted through that routine for much longer if I had completely stopped going to the gym.</p><p>Of course, I wasn’t trying to do intense workouts(my workouts are never intense) or get personal records during those days. I mainly focused on stretching and doing lighter workouts.</p><p>It wasn’t about getting stronger or improving my performance at the gym. It was more about having something different to focus on for a while, instead of constantly thinking about work and the project.</p><p>That said, I wouldn’t consider that a healthy way to manage deadlines. It was just how things happened during those final few days, and I know it’s not something I can keep doing.</p><h3>Finally, submitted!</h3><p>The proposal was due on November 5, and I managed to submit it.</p><p>It wasn’t easy, but I’m glad I got it done thanks to my supervisor for providing such detailed feedback even at the last minute and to the trainer at the gym for agreeing to whatever the time I say I’ll be there.</p><p>I think one of the biggest challenges was trying to make progress on the project. There wasn’t always a large block of time available to sit down and work on it. I had to make use of the time I did have, even if that meant working on it for an hour or two after everything else.</p><p>And the progress wasn’t always consistent. Some days went really well, while others felt like I hadn’t achieved anything at all.</p><p>But eventually, I got to the submission.</p><h3>What’s next?</h3><p>I’m currently waiting for the presentation and viva dates. They haven’t been published yet, but they should be announced soon.</p><p>I’m also doing another module this semester called Formal Methods, and that has a submission coming up on November 17. So I’m currently preparing for that as well.</p><p>The proposal submission is done, but there’s still a long way to go with the final-year project itself.</p><p>I guess this is just the beginning of the next stage.</p><p>Let’s see how things go.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=146c19b3a5db" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[How I Managed(?)]]></title>
            <link>https://medium.com/@kldpremarathne/how-i-managed-full-time-work-university-the-gym-and-running-68e4901b71b8?source=rss-74dfda7d627b------2</link>
            <guid isPermaLink="false">https://medium.com/p/68e4901b71b8</guid>
            <category><![CDATA[daily-routine]]></category>
            <category><![CDATA[half-marathon]]></category>
            <category><![CDATA[final-year]]></category>
            <dc:creator><![CDATA[Lasanya Premarathne]]></dc:creator>
            <pubDate>Mon, 09 Nov 2026 20:40:19 GMT</pubDate>
            <atom:updated>2026-11-09T20:41:37.255Z</atom:updated>
            <content:encoded><![CDATA[<h3>How I Managed(?) To Submit the Final Year Project Proposal With Full-Time Work, The Gym, and Running</h3><p><em>Trying to fit everything into one week while also getting sick multiple times.</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*PCZAMiN7j-qcRemd_wBszA.jpeg" /><figcaption>sunset from my weekday running location</figcaption></figure><p>It was not easy. A lot of it came down to having some structure throughout my weekdays and trying to have a structure on Saturdays as well. Although, sometimes, that meant choosing to sleep instead of attending lectures.</p><p>So, this is what my week has generally looked like.</p><h3>Mondays</h3><p>On Mondays, I had to go to work, online lectures, and then the gym.</p><p>Our semester started around the last week of September. After trying to manage everything for the first one or two weeks, I realised that the arrangement wasn’t really healthy.</p><p>I used to go to work around 8:30 AM and work until about 5 PM. Then I’d close my office tabs, open my university tabs, and log into my online lecture.</p><p>Most people at the office leave by around 6 PM. I mean, not necessarily because they’ve finished all their work, but they usually stop working from the office and continue anything that’s left once they get home.</p><p>So I was literally the only person at the office, staying there until around 8 PM just to attend my lectures. And honestly, sitting alone at the office after everyone had left wasn’t helping me very much mentally. (Not sure if it’s staying in the office or staying alone hit the hardest.)</p><p>Eventually, I requested to work from home on Mondays, and thankfully, that was approved.</p><p>So, for the past few weeks, I’ve been working from home on Mondays. But that doesn’t necessarily mean it’s an easy day.</p><p>I usually start work around 8:30 AM and keep working until around 8:30 PM, including the lecture. There’s no proper mental break in between. Immediately after that, I leave home to go to the gym.</p><p>Yes, it’s exhausting. But I know that if I didn’t go to the gym after those long Mondays, the day would feel even more mentally demanding.</p><p>The workload is still the same, but somehow, the way I feel about the day is different when I get to go to the gym. So I try to make sure I go, even after those long days unless I actually can’t.</p><h3>Tuesdays</h3><p>On Tuesdays, I usually have my supervisor meetings around 5 PM.</p><p>I go to work around 8:30 AM, attend the meeting, and then spend some more time on university-related work and research until around 7:30 PM.</p><p>After that, I head to the gym.</p><h3>Wednesdays</h3><p>Wednesdays are usually a little more physically demanding.</p><p>I try to go running in the morning, usually from around 6 AM to 7 AM, before going to work.</p><p>I normally stay at the office until around 7:30 PM. Not because I have anything specific to do until then, but because I work with a trainer at the gym, and he usually comes around 7 PM.</p><p>If I go to the gym earlier, I don’t really have enough time to get work done before gym nor after gym. So I’d rather stay at the office a little longer, get some work done, and then head to the gym.</p><p>But sometimes after getting home, I try to spend at least another hour working on university-related stuff.</p><p>But I do realise that these days can be very demanding, both mentally and physically. So unless there’s a specific deadline approaching, I try not to push myself unnecessarily. I know I’m already demanding quite a lot from myself.</p><p>And this isn’t just a Wednesday thing. It’s pretty much how most of my weekdays go, with work, university, gym and running all competing for the same limited amount of time.</p><h3>Thursdays and Fridays</h3><p>Thursdays are comparatively simple. There’s nothing extra, really. No runs, no supervisor meetings, nothing. It’s just work and gym.</p><p>And on Fridays, there’s no gym.</p><p>My trainer usually comes to the gym from Monday to Thursday, so I consider Fridays my rest days as well. Sometimes I plan to go running instead, but these days, it’s been raining almost every evening.</p><p>So I don’t really get to run on Fridays.</p><h3>Saturdays</h3><p>On Saturdays, I usually have lectures from 8.30am, but most of the time, I consider sleeping in to be worth it.</p><p>I don’t attend the lectures every week, partly because I don’t always understand what the lecturers are saying. And even if I attend, I still have to put in the effort to learn and understand the content myself.</p><p>So sometimes, I’d rather get some extra sleep and spend the time going through the material later.</p><p>I usually sleep until around noon or 1 PM on Saturdays and then spend the day mainly working on my research and university work.</p><p>That’s pretty much it for Saturdays.</p><h3>Sundays</h3><p>Before the whole rainy weather situation started, I used to run on Sunday evenings. But since it’s been raining so much in the evenings, I switched to running in the mornings.</p><p>I usually leave for my running location around 5:45 AM and try to get in 10 kilometres or more every Sunday.</p><p>I’m preparing for my first half marathon on December 13, so the Sunday long runs are a pretty important part of my running week.</p><p>After coming home, I usually chill for a bit. Actually, chill a lot.</p><p>I have a huge breakfast, or lunch, or whatever you want to call it, take a good bath, and eventually get back to working on my university stuff.</p><p>And that’s generally how my Sundays go.</p><h3>Making time for everything else</h3><p>Saying all of this doesn’t mean I skipped everything else in my life.</p><p>I still went out with friends, did at least some of the chores around the house, and spent time annoying my parents and siblings.</p><p>I didn’t want my entire life to revolve around work and university, even when it felt like there was very little time for anything else.</p><p>Of course, there were days when I couldn’t follow the routine properly. Getting sick multiple times didn’t exactly help either. But I tried to get back to it whenever(as soon as) I could.</p><h3>So, that’s been my routine</h3><p>This is more or less how my weeks have been going over the past few months.</p><p>It wasn’t about following a perfect schedule or making sure every single day was productive. It was more about having some structure, knowing what I needed to get done, and TRYING to make a little progress every day.</p><p>And somehow, in between all of this, I managed to submit my final-year project proposal, which was due on November 5.</p><p>Now I’m waiting for the presentation and viva dates, preparing for another module submission on November 17, and continuing my half-marathon training.</p><p>So yeah, let’s see how things go. I’ll probably give you another update by the time I finish my next submission or the half marathon.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=68e4901b71b8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[LinkedIn Needs a “I Feel You” Reaction]]></title>
            <link>https://medium.com/@kldpremarathne/linkedin-needs-a-i-feel-you-reaction-6927272b1059?source=rss-74dfda7d627b------2</link>
            <guid isPermaLink="false">https://medium.com/p/6927272b1059</guid>
            <category><![CDATA[linkedin]]></category>
            <category><![CDATA[ux]]></category>
            <category><![CDATA[my-story]]></category>
            <dc:creator><![CDATA[Lasanya Premarathne]]></dc:creator>
            <pubDate>Mon, 08 Jun 2026 03:46:58 GMT</pubDate>
            <atom:updated>2026-06-08T03:46:58.944Z</atom:updated>
            <content:encoded><![CDATA[<p>I came across a LinkedIn post recently.</p><p>Someone lived around 10 km away from their office and was thinking of moving closer.</p><p>Then they started looking at apartments.</p><p>The rent was way above their budget.</p><p>So they decided:</p><blockquote><em>“I already pay so much to the government in taxes. I might as well spend some time on the road and move on.”</em></blockquote><p>I smiled.</p><p>Not because it was funny.</p><p>Because I understood it.</p><p>I’ve been there too.</p><p>But when I tried to react to the post, I paused.</p><p>Not because I don’t understand what the reactions mean.</p><p>Because none of them reflected what I actually felt.</p><p>Yes, I smiled.</p><p>But the 😂 reaction didn’t feel right.</p><p>I wasn’t laughing at the situation.</p><p>I smiled because I connected with it.</p><p>We have reactions for:</p><p>👍 Like</p><p>🎉 Celebrate</p><p>💡 Insightful</p><p>❤️ Love</p><p>😂 Laugh</p><p>But in moments like this, I wish there was a simple handshake reaction.</p><p>A reaction that says:</p><blockquote><em>“I feel you.”</em></blockquote><p>Not because I agree.</p><p>Not because I learned something.</p><p>Just because I’ve been there too.</p><p>The posts I remember aren’t always the most insightful ones.</p><p>They’re usually the ones that make me think:</p><blockquote><em>“Yep. That’s exactly how it is.”</em></blockquote><p>And I think that’s why some posts do so well.</p><p>People don’t always connect with expertise.</p><p>Sometimes they connect with recognition.</p><p>They see a piece of their own life in someone else’s story.</p><p>And for a moment, they feel understood.</p><p>Maybe that’s the reaction LinkedIn is missing.</p><p>🫱🏼‍🫲🏽 A handshake.</p><p>Or maybe I’m wrong.</p><p>What reaction feels most like “I feel you” to you?</p><p>PS: the link to the post I was referring to- <a href="https://www.linkedin.com/posts/-divya-porwal_see-you-tomorrow-bengaluru-traffic-share-7469265326174588930-fSpQ/?utm_source=share&amp;utm_medium=member_android&amp;rcm=ACoAADtQSUYBjwrIf3yYBFUGJK2CAscjXzF_0Ig">https://www.linkedin.com/posts/-divya-porwal_see-you-tomorrow-bengaluru-traffic-share-7469265326174588930-fSpQ/?utm_source=share&amp;utm_medium=member_android&amp;rcm=ACoAADtQSUYBjwrIf3yYBFUGJK2CAscjXzF_0Ig</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=6927272b1059" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[AI vs. me]]></title>
            <link>https://medium.com/@kldpremarathne/ai-vs-me-25523f7b5bb4?source=rss-74dfda7d627b------2</link>
            <guid isPermaLink="false">https://medium.com/p/25523f7b5bb4</guid>
            <category><![CDATA[ai-coding-assistant]]></category>
            <category><![CDATA[modern-problems]]></category>
            <category><![CDATA[ai-vs-me]]></category>
            <category><![CDATA[ai]]></category>
            <dc:creator><![CDATA[Lasanya Premarathne]]></dc:creator>
            <pubDate>Fri, 08 May 2026 18:00:12 GMT</pubDate>
            <atom:updated>2026-05-08T18:00:12.117Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*K5KCmb5IdBl_N6U2Nvk4lw.png" /></figure><p>I used to sit with problems for a long time.</p><p>Like… <em>really</em> sit with them.<br>Stare at the screen. Try something. Break it. Ctrl+Z(Undo) it. Google five different things that kind of relate but don’t fully solve it. Go get water. Come back. Try again.</p><p>And then at some random point, it would click.</p><p>That feeling? That was the best part. Not even the solution itself, just that tiny moment where everything suddenly made sense. And sometimes it was just one line.</p><p>But now, it’s different. <em>Very</em> different</p><p>I’m opening Claude Code, typing what I want, and it’s just… doing it.</p><p>Function? Done.<br>UI? Yes<br>Edge cases? Covered.<br>Refactoring? Sure.</p><p>I’m mostly testing and tweaking.</p><p>And yes it’s fast. <em>Way</em> faster than how I used to work.</p><p>But there’s this thought that keeps creeping in:</p><p><strong>I think I’m getting worse at coding.</strong></p><p>It’s a weird guilt.</p><p>Nothing is technically wrong.<br>The code is working.<br>I’m shipping faster.<br>I’m solving bigger problems in less time.</p><p>But it’s feeling like I’m skipping something.</p><p>Before, I was <em>understanding</em> things because I had to fight through them. Now I’m getting to the end without really knowing what’s happening in the middle.</p><p>And that’s the part that’s bothering me.</p><p>It’s not that I can’t code.</p><p>It’s that I’m not sure if I still <em>can…</em> without AI.</p><p>I don’t think this is just a “me” problem.</p><p>AI is changing the whole loop:</p><p>Before:</p><ul><li>Think</li><li>Try</li><li>Fail</li><li>Understand</li><li>Solve</li></ul><p>Now:</p><ul><li>Ask</li><li>Get answer</li><li>Check if it works</li></ul><p>That <em>struggle</em> phase? It’s becoming optional.</p><p>And when something becomes optional… it’s usually the first thing I’m dropping.</p><p>The problem is how easy it’s becoming to switch my brain off.</p><p>There’s a difference between:</p><ul><li>using AI to move faster</li><li>and using AI to avoid thinking</li></ul><p>And if I’m being honest, I’m falling into the second one.</p><p>Not because I want to… but because it’s just… easier. And faster.</p><p>I’m not trying to go back to doing everything manually. That doesn’t make sense anymore.</p><p>But I also don’t want to lose the part of me that actually <em>thinks through problems</em>.</p><p>So I’m trying a few small things.</p><p>Not strict rules. Just… trying out.</p><h3>Thinking Before Asking</h3><p>Even if I know I’m going to use AI, I’m pausing.</p><p>“What would I do here if AI didn’t exist?”</p><p>Most of the time I’m not getting a full solution… but I’m getting <em>something</em>. And that “something” is helping me understand what comes next.</p><h3>Comparing, Not Just Accepting</h3><p>Instead of just taking the output, I’m looking at it like:</p><p>“Would I have written this myself without AI?”</p><p>If the answer is no, that’s where the learning is happening.</p><h3>Breaking the Code on Purpose</h3><p>If AI gives me something, I’m trying to mess with it.</p><p>Changing things. Pushing edge cases. Seeing where it fails.</p><p>It’s forcing me to actually understand what’s going on instead of trusting it blindly.</p><h3>Being more specific with prompts</h3><p>Without saying</p><p>“Build the component”</p><p>I‘m trying to say:</p><p>“Build this component, use an array for this.. a hook for this.. this is what the data structure looks like..” <br>Basically trying to think through the architecture before AI writes it.</p><p>That alone makes me feel more involved.</p><h3>Sometimes… I don’t use AI at All</h3><p>Not often. But sometimes.</p><p>It’s slower. Sometimes frustrating.</p><p>But it’s reminding me that I can still think.</p><h3>If I still can’t feel like I’m using my brain.. HackerRank</h3><p>Yes then i go to HackerRank and try to do some questions there.</p><p>React<br>Data structures<br>Or something completely new that forces me to struggle.. with one simple rule: No generated answers.</p><p>Maybe the job isn’t really about writing every line anymore. <br>Even though interviews still expect that.<br>And university vivas still make you code without even using an IDE somehow.</p><p>Maybe it’s more about:</p><ul><li>knowing what I want</li><li>knowing if what I’m getting is actually correct</li><li>knowing how to fix it when it isn’t</li></ul><p>That’s still skill. Just… a different kind.</p><p>I do think it’s really easy to drift into a place where I stop engaging completely.</p><p>And once that happens, yeah… I probably will get stupid.</p><p>Not because of AI.</p><p>Just because I’m not using the part of my brain that made me interested in this in the first place.</p><p>I guess the balance is somewhere in the middle.</p><p>I’m using the tools. I’m moving fast.</p><p>But I’m trying not to give up the thinking entirely.</p><p>That part still matters.</p><p>Now, if you think I’m wrong just say how to fix it.. I’d genuinely love to fix it and use AI without any guilt:)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=25523f7b5bb4" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Frontend vs Backend: Lessons from Working Outside My Comfort Zone]]></title>
            <link>https://medium.com/@kldpremarathne/frontend-vs-backend-lessons-from-working-outside-my-comfort-zone-19cd64336399?source=rss-74dfda7d627b------2</link>
            <guid isPermaLink="false">https://medium.com/p/19cd64336399</guid>
            <dc:creator><![CDATA[Lasanya Premarathne]]></dc:creator>
            <pubDate>Thu, 05 Feb 2026 06:49:01 GMT</pubDate>
            <atom:updated>2026-02-05T06:49:01.292Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*oT34GlBvsPYXvkKca932eg.png" /></figure><p>Even though my title has the words s<em>oftware engineer</em>, most of my day-to-day work has been focused on frontend. I’ve been working with React for a while, and that’s where I feel the most comfortable. Recently, however, I was asked to develop a feature for a live project; one I had never worked on before and didn’t even know existed. The task required changes on both the frontend and the backend.</p><p>I decided to start with the backend.</p><p>It took time to understand the existing codebase, the data flow, and the decisions made by developers before me. Once I had a clearer picture, I implemented the required backend changes and then moved on to the frontend. The feature was deployed successfully.</p><p>Shortly after deployment, a bug was reported.</p><p>My immediate assumption was that it would be a backend issue — the area I was least confident in. That uncertainty made me anxious. But after investigating, I discovered that the issue was actually in the frontend code. When another bug appeared soon after, it also originated from the frontend.</p><p>That moment forced me to pause.</p><p>Frontend development is what I’m most familiar with. It’s what I spend most of my time doing. So why were the problems consistently appearing there?</p><p>The more I reflected, the more I realized there was something more behind it.</p><p>Once the backend logic was implemented and verified, it felt relatively stable. The flow was structured, the inputs and outputs were clearly defined, and the behavior remained consistent unless someone intentionally changed it. The frontend, in contrast, felt far more sensitive. Small assumptions about state, data shapes, or user interaction could lead to unexpected behavior.</p><p>Frontend bugs also tend to hide better.</p><p>They don’t always throw clear errors or break the build. Often, the application “mostly works,” but fails under specific conditions, certain user actions, timing issues, or edge cases. When asynchronous data, UI state, and user behavior intersect, even small oversights can become visible bugs.</p><p>Another realization was about confidence.</p><p>Because I’m more experienced with frontend work, I naturally move faster and trust my instincts more. But that speed can quietly turn into assumptions. I assume I know how a component behaves. I assume the data will look a certain way. I assume users will follow expected paths.</p><p>When working on the backend, I was far more cautious. I read more code, traced more flows, and tested more scenarios, all because I knew I was working outside my comfort zone.</p><p>Ironically, that caution made my backend changes more stable.</p><p>There’s also the visibility factor.</p><p>Frontend issues are immediately exposed to users. Even minor bugs are noticeable because they directly affect what people see and interact with. Backend issues may exist just as often, but they don’t always surface as quickly or as visibly. But, when backend issues do appear, they can be far more serious, impacting data integrity, system stability, or even core business functionalities.</p><p>This experience changed how I think about frontend engineering.</p><p>It isn’t easier than backend work. It’s complex in a different way.</p><h3>Key Takeaways</h3><ul><li>Familiarity with a technology can lead to overlooked assumptions.</li><li>Frontend systems are often more fragile than they appear due to state, async data, and user interactions.</li><li>Backend logic tends to feel more stable because of clearly defined inputs, outputs, and constraints.</li><li>Frontend bugs are more visible since they directly impact user experience.</li><li>Working outside your comfort zone encourages more disciplined engineering habits.</li><li>Assumptions are a common source of bugs, especially in areas where we feel most confident.</li><li>Frontend and backend deserve equal rigor in design, testing, and review.</li><li>Growth often comes from reflecting on mistakes, not avoiding them.</li></ul><p>In the end, this wasn’t really about frontend vs backend, but how i approach them.</p><p>I’m still learning what kind of engineer I want to become. Experiences like this show me that growth doesn’t come from always being right; it comes from being willing to examine mistakes and understand why they happened. Every bug, every uncomfortable task, and every unfamiliar codebase is an opportunity to build better habits.</p><p>Sometimes you will feel unsure of where you stand, that’s normal. Over time, confidence will come; not from avoiding mistakes, but from learning how to handle them.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=19cd64336399" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[What actually is setTimeout(fn, 0)]]></title>
            <link>https://medium.com/@kldpremarathne/what-actually-is-settimeout-fn-0-c01a6e58292b?source=rss-74dfda7d627b------2</link>
            <guid isPermaLink="false">https://medium.com/p/c01a6e58292b</guid>
            <category><![CDATA[javascript]]></category>
            <dc:creator><![CDATA[Lasanya Premarathne]]></dc:creator>
            <pubDate>Tue, 22 Jul 2025 20:36:28 GMT</pubDate>
            <atom:updated>2025-07-22T20:36:28.409Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1021/1*bB4Lon4sp5b-dqG3e9wjCA.png" /></figure><h3>What It Really Means in JavaScript</h3><p>If you write JavaScript, you might have seen this little trick: a time out function with a delay of 0 milliseconds.</p><pre>console.log(&quot;This runs first&quot;);<br><br>setTimeout(() =&gt; {<br>  console.log(&quot;This runs later&quot;);<br>}, 0);<br><br>console.log(&quot;This runs next&quot;);</pre><p>At first, you’d think setting the delay to 0 means the code will run <em>immediately</em>.</p><p>But when you run it, the output is:</p><pre>This runs first<br>This runs next<br>This runs later</pre><p>So what’s really going on? Let’s break it down in simple terms.</p><p>JavaScript is single-threaded: JavaScript only does one thing at a time.</p><p>When it sees setTimeout, it doesn’t stop and wait.</p><p>Instead, it says:</p><blockquote><em>“Okay, I’ll run this function later, after everything else that’s running right now is done.”</em></blockquote><p>Even if you say 0 milliseconds, it <em>still</em> goes into the later list.</p><h3>Relating to the event loop</h3><ol><li>It has a <strong>call stack</strong> — a list for things it’s doing right now.</li><li>It also has a <strong>task queue</strong> — a waiting list for things to do next.</li><li>The <strong>event loop</strong> keeps checking if the call stack is empty.</li></ol><ul><li>If yes, it moves the first thing from the task queue to the call stack and runs it.</li></ul><p>When you use setTimeout(fn, 0), your function goes into the task queue.</p><p>It will <em>only</em> run after the call stack is empty, even if the delay is 0.</p><h3>Why setTimeout(fn, 0)?</h3><ol><li>If you have lots of code running, this gives the browser a chance to update the screen.</li><li>If your code is heavy, breaking it up keeps the page responsive.</li><li>Sometimes you want to wait until the current function finishes before running something else.</li></ol><h3>A modern and a faster way: Promises</h3><p>In modern JavaScript, there’s an even quicker trick:</p><pre>console.log(&quot;Start&quot;);<br><br>Promise.resolve().then(() =&gt; {<br>  console.log(&quot;Microtask&quot;);<br>});<br><br>setTimeout(() =&gt; {<br>  console.log(&quot;Macrotask&quot;);<br>}, 0);<br><br>console.log(&quot;End&quot;);</pre><p>Output:</p><pre>Start<br>End<br>Microtask<br>Macrotask</pre><p>Promises go into the “microtask” queue, which runs sooner than setTimeout.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c01a6e58292b" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[20 Must-Know JavaScript Functions for Every React Developer]]></title>
            <link>https://medium.com/@kldpremarathne/20-must-know-javascript-functions-for-every-react-developer-cac7fe06e674?source=rss-74dfda7d627b------2</link>
            <guid isPermaLink="false">https://medium.com/p/cac7fe06e674</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[function-javascript]]></category>
            <category><![CDATA[react-developer]]></category>
            <dc:creator><![CDATA[Lasanya Premarathne]]></dc:creator>
            <pubDate>Thu, 10 Jul 2025 19:13:36 GMT</pubDate>
            <atom:updated>2025-07-10T19:13:36.956Z</atom:updated>
            <content:encoded><![CDATA[<p>Whether you’re just learning React or a seasoned pro, your JavaScript fundamentals is what’s doing all the behind the scenes. So, if you’re aiming to build cleaner, faster, and more scalable apps, knowing the key JS functions is non-negotiable.</p><p>I have explored 20 JS functions and here’s a summary.</p><h3>1. map() – Transform each item into something new</h3><p><strong>Parameters:</strong></p><ul><li>callback(currentValue, index, array)</li></ul><p><strong>Returns:</strong></p><ul><li>A <strong>new array</strong> of transformed values</li><li>Does <strong>not mutate</strong> the original array</li></ul><pre>const items = [&#39;Apple&#39;, &#39;Banana&#39;, &#39;Mango&#39;];<br>return (<br>  &lt;ul&gt;<br>    {items.map((item, index) =&gt; (<br>      &lt;li key={index}&gt;{item}&lt;/li&gt;<br>    ))}<br>  &lt;/ul&gt;<br>)</pre><p>✅ Used in: Rendering dynamic components from lists.</p><h3>2. filter() – Keep only matching items</h3><p><strong>Parameters:</strong></p><ul><li>callback(currentValue, index, array) – should return true or false</li></ul><p><strong>Returns:</strong></p><ul><li>A <strong>new array</strong> with only truthy items</li><li>Does <strong>not mutate</strong> the original array</li></ul><pre>const activeUsers = users.filter(user =&gt; user.isActive);</pre><p>✅ Used in: Filtering displayed components or state updates.</p><h3>3. reduce() – Accumulate a single result</h3><p><strong>Parameters:</strong></p><ul><li>callback(accumulator, currentValue, index, array)</li><li>initialValue <em>(optional)</em></li></ul><p><strong>Returns:</strong></p><ul><li>A <strong>single value</strong> (number, object, array, etc.)</li><li>Does <strong>not mutate</strong> original array</li></ul><pre>const total = cart.reduce((acc, item) =&gt; acc + item.price, 0);</pre><p>✅ Used in: Calculating totals, merging objects, and more.</p><h3>4. find() – Return the first matching element</h3><p><strong>Parameters:</strong></p><ul><li>callback(currentValue, index, array)</li></ul><p><strong>Returns:</strong></p><ul><li>The <strong>first matching element</strong></li><li>Returns undefined if not found</li><li>Does <strong>not mutate</strong> the array</li></ul><pre>const user = users.find(user =&gt; user.id === targetId);</pre><p>✅ Used in: Fetching a specific item before rendering or updating.</p><h3>5. includes() – Check if a value exists in an array or string</h3><p><strong>Parameters:</strong></p><ul><li>valueToFind</li><li>fromIndex <em>(optional)</em></li></ul><p><strong>Returns:</strong></p><ul><li>true or false</li><li>Does <strong>not mutate</strong> the array/string</li></ul><pre>if (selectedItems.includes(item.id)) {<br>  // highlight item<br>}</pre><p>✅ Used in: Conditional styling or logic in JSX.</p><h3>6. some() – Check if any item matches</h3><p><strong>Parameters:</strong></p><ul><li>callback(currentValue, index, array)</li></ul><p><strong>Returns:</strong></p><ul><li>true if at least one item matches</li><li>Does <strong>not mutate</strong> the array</li></ul><pre>const hasErrors = fields.some(field =&gt; field.error);</pre><p>✅ Used in: Form validation or conditional rendering.</p><h3>7. every() – Check if all items match</h3><p><strong>Parameters:</strong></p><ul><li>callback(currentValue, index, array)</li></ul><p><strong>Returns:</strong></p><ul><li>true if all items match</li><li>Does <strong>not mutate</strong> the array</li></ul><pre>const isValid = fields.every(field =&gt; !field.error);</pre><p>✅ Used in: Form validation or conditional rendering.</p><h3>8. setTimeout() – Run a function after a delay</h3><p><strong>Parameters:</strong></p><ul><li>callback, delayInMs, ...args</li></ul><p><strong>Returns:</strong></p><ul><li>A timeout ID (used for clearTimeout)</li><li>Does <strong>not mutate</strong> anything</li></ul><pre>useEffect(() =&gt; {<br>  const timeout = setTimeout(() =&gt; {<br>    setShow(true);<br>  }, 2000);<br>  return () =&gt; clearTimeout(timeout);<br>}, []);</pre><p>✅ Used in: Animations, loading states, throttling UX.</p><h3>9. setInterval() / clearInterval() – Repeat a function at intervals</h3><p><strong>Parameters:</strong></p><ul><li>setInterval(callback, intervalInMs, ...args) – runs callback every intervalInMs milliseconds</li><li>clearInterval(intervalId) – stops the interval using its ID</li></ul><p><strong>Returns:</strong></p><ul><li>setInterval() returns an <strong>interval ID</strong> (a number)</li><li>Use this ID with clearInterval() to stop the repeated execution</li><li>Neither function mutates existing data</li></ul><pre>let intervalId; // declare outside to keep reference<br>const startClock = () =&gt; {<br>  intervalId = setInterval(() =&gt; {<br>    const now = new Date();<br>    console.log(now.toLocaleTimeString());<br>  }, 1000);<br>}<br><br>// Start the clock<br>startClock();<br><br>// Later, when you want to stop:<br>clearInterval(intervalId);</pre><p>✅ Used in: If you start an interval inside useEffect, always call clearInterval() in the cleanup function to prevent memory leaks or multiple intervals.</p><h3>10. Object.entries() / Object.keys() / Object.values()</h3><p><strong>Parameters:</strong></p><ul><li>An object</li></ul><p><strong>Returns:</strong></p><ul><li>entries() → array of [key, value] pairs</li><li>keys() → array of keys</li><li>values() → array of values</li><li>Does <strong>not mutate</strong> the original object</li></ul><pre>Object.entries(errors).map(([field, message]) =&gt; (<br>  &lt;p key={field}&gt;{message}&lt;/p&gt;<br>));</pre><p>✅ Used in: Rendering dynamic object values, form errors, etc.</p><h3>11. JSON.stringify() / JSON.parse()</h3><p><strong>Parameters:</strong></p><ul><li>Any JS value or JSON string</li></ul><p><strong>Returns:</strong></p><ul><li>stringify() → JSON string</li><li>parse() → JavaScript value</li><li>Does <strong>not mutate</strong> input</li></ul><pre>localStorage.setItem(&quot;data&quot;, JSON.stringify(myData));<br>const parsed = JSON.parse(localStorage.getItem(&quot;data&quot;));</pre><p>✅ Used in: Persisting state, debugging, sending/receiving API data.</p><h3>12. Array.from() – Create arrays from iterables or lengths</h3><p><strong>Parameters:</strong></p><ul><li>arrayLike or { length: N }</li><li>Optional map function</li></ul><p><strong>Returns:</strong></p><ul><li>A <strong>new array</strong></li><li>Does <strong>not mutate</strong> input</li></ul><pre>const stars = Array.from({ length: 5 }, (_, i) =&gt; i + 1);</pre><p>✅ Used in: Rendering elements like rating stars or pagination.</p><h3>13. typeof / instanceof</h3><p><strong>Parameters:</strong></p><ul><li>typeof takes a variable</li><li>instanceof takes an object and constructor</li></ul><p><strong>Returns:</strong></p><ul><li>typeof → string (e.g., &quot;string&quot;, &quot;object&quot;)</li><li>instanceof → boolean</li></ul><pre>if (typeof value === &#39;string&#39;) { ... }<br>if (myDate instanceof Date) { ... }</pre><p>✅ Used in: Safe conditional rendering or logic.</p><h3>14. Promise.all() – Run multiple promises in parallel</h3><p><strong>Parameters:</strong></p><ul><li>iterable – usually an <strong>array of promises</strong></li></ul><p><strong>Returns:</strong></p><ul><li>A <strong>single promise</strong> that:</li><li><em>Resolves</em> to an <strong>array of resolved values</strong> (order matches input)</li><li><em>Rejects immediately</em> if <strong>any promise rejects</strong> (with the first rejection reason)</li></ul><pre>const [data1, data2] = await Promise.all([fetchA(), fetchB()]);</pre><p>✅ Used in: Parallel API calls in useEffect or getServerSideProps.</p><h3>15. splice() – Add/remove items from array (mutates)</h3><p><strong>Parameters:</strong></p><ul><li>startIndex, deleteCount, ...items</li></ul><p><strong>Returns:</strong></p><ul><li>Array of <strong>removed items</strong></li><li>✅ <strong>Mutates</strong> the original array</li></ul><pre>const arr = [1, 2, 3, 4];<br>arr.splice(1, 2); // Removes 2 items from index 1 → [2, 3]<br>console.log(arr); // [1, 4]</pre><p>✅ <strong>React tip:</strong> Avoid using splice() directly on state arrays — always create a copy first, or use filter()/slice() if you want immutability.</p><h3>16. forEach() – Loop through items (no return)</h3><p><strong>Parameters:</strong></p><ul><li>callback(currentValue, index, array)</li></ul><p><strong>Returns:</strong></p><ul><li>undefined</li><li>Does <strong>not mutate</strong> array but may cause side effects</li></ul><pre>[1, 2, 3].forEach(num =&gt; console.log(num));</pre><p>✅ <strong>React tip:</strong> Use it for side effects, <strong>not</strong> for transformations (use map() for those).</p><h3>17. concat() – Join arrays/values into a new array</h3><p><strong>Parameters:</strong></p><ul><li>One or more arrays/values</li></ul><p><strong>Returns:</strong></p><ul><li>A <strong>new array</strong></li><li>Does <strong>not mutate</strong> originals</li></ul><pre>const arr1 = [1, 2];<br>const arr2 = [3, 4];<br>const result = arr1.concat(arr2); // [1, 2, 3, 4]</pre><p>✅ <strong>React tip:</strong> Great for updating arrays in immutable ways (e.g., appending to state).</p><h3>18. findIndex() – Get index of first match</h3><p><strong>Parameters:</strong></p><ul><li>callback(currentValue, index, array)</li></ul><p><strong>Returns:</strong></p><ul><li>Index of matching element</li><li>-1 if not found</li><li>Does <strong>not mutate</strong></li></ul><pre>const users = [{ id: 1 }, { id: 2 }];<br>const index = users.findIndex(u =&gt; u.id === 2); // 1</pre><p>✅ <strong>React tip:</strong> Useful for locating items in a list before updating or deleting.</p><h3>19. split() – Break string into an array</h3><p><strong>Parameters:</strong></p><ul><li>separator</li><li>Optional limit</li></ul><p><strong>Returns:</strong></p><ul><li>A <strong>new array</strong></li><li>Does <strong>not mutate</strong> original string</li></ul><pre>const str = &quot;apple,banana,kiwi&quot;;<br>const fruits = str.split(&quot;,&quot;); // [&quot;apple&quot;, &quot;banana&quot;, &quot;kiwi&quot;]</pre><p>✅ <strong>React tip:</strong> Helpful when parsing CSV-like data or processing form input.</p><h3>20. substring() – Get part of a string by index range</h3><p><strong>Parameters:</strong></p><ul><li>startIndex <em>(number)</em> – starting index (inclusive)</li><li>endIndex <em>(optional number)</em> – ending index (exclusive)</li></ul><p><strong>Returns:</strong></p><ul><li>A <strong>new string</strong> containing characters from startIndex up to (but not including) endIndex</li><li>Does <strong>not mutate</strong> the original string</li></ul><pre>const str = &quot;JavaScript&quot;;<br>console.log(str.substring(4, 10)); // &quot;Script&quot;</pre><h3>Bonus: But what is contains()?</h3><p>If you’ve ever seen contains() and wondered where it fits in JavaScript, here&#39;s the what exactly happens:</p><h3>Node.contains() — Real method</h3><p>Used in DOM logic (e.g., detecting outside clicks):</p><pre>element.contains(childElement); // true or false</pre><h3>Array.contains() — Doesn’t exist</h3><p>Use includes() instead:</p><pre>[1, 2, 3].includes(2); // true</pre><p>If you are still confused <a href="https://tpiros.dev/blog/contains-vs-includes/">here</a> is an article explaining it further:)</p><p>Comment down below if I’ve missed any must-know JavaScript functions — or share your favorites!</p><p>Happy coding! ✨</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cac7fe06e674" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Debounce Vs. Throttle]]></title>
            <link>https://medium.com/@kldpremarathne/debounce-vs-throttle-f45b84e7a0fc?source=rss-74dfda7d627b------2</link>
            <guid isPermaLink="false">https://medium.com/p/f45b84e7a0fc</guid>
            <dc:creator><![CDATA[Lasanya Premarathne]]></dc:creator>
            <pubDate>Wed, 18 Jun 2025 21:51:35 GMT</pubDate>
            <atom:updated>2025-06-18T21:51:35.979Z</atom:updated>
            <content:encoded><![CDATA[<p>Last week, I was working on a pretty simple validation: just checking if the new password and confirm password fields match. Classic stuff.</p><p>While discussing it with my senior, he said,</p><blockquote><em>“Just add a debounce to that check.”</em></blockquote><p>That threw me off a bit.</p><p>I’ve heard of <strong>debounce</strong> before. And <strong>throttle</strong>, too. I’ve even googled both a couple of times. But I didn’t really understand the difference… and I definitely didn’t remember which was which. So I just asked:</p><blockquote><em>“Why debounce and not throttle?”</em></blockquote><p>That one question turned into a mini-mentorship moment, and the difference actually clicked.</p><p>So, here’s what I learned. And the way I think of it now.</p><h3>Dev-Life Edition</h3><p>Imagine you’re typing into an input field that does a live check, like matching passwords, or a search bar that gives you results as you type.</p><p>If you run your check <strong>every single time</strong> the user hits a key, it could overload the browser, or fire off unnecessary network calls. That’s where <strong>debounce</strong> comes in.</p><h3>Debounce feels like:</h3><blockquote><em>Waiting until the user stops typing before doing anything.</em></blockquote><p>As a junior dev, I relate it to how I sometimes <em>wait until I finish writing a chunk of code</em> before asking the seniors for suggestions, because I know I can figure it out on my own. If I bug them every second, it’s a waste. Debounce is like that… <em>wait, then act.</em></p><h3>Throttle, on the other hand:</h3><blockquote><em>Makes sure you’re not calling something more than once every X milliseconds.</em></blockquote><p>This is more like me giving progress updates in a team meeting, I might have ten things I want to say, but I only speak <em>once every few minutes</em> to avoid spamming everyone. Throttle is your dev-brain saying, “Chill. Update, but only so often.”</p><h3>A Bit More Technical: What Actually Happens?</h3><p>Let’s get a little more into what debounce and throttle <em>do</em> behind the scenes.</p><h3>Debounce</h3><p>Debounce waits until there’s a <strong>pause in activity</strong> before running a function. Every time the function is triggered, it resets a timer.</p><p>So if you keep triggering it (e.g., typing), it never runs, <strong>until you stop</strong>.</p><pre>function debounce(fn, delay) {<br>  let timeout;<br>  return function (...args) {<br>    clearTimeout(timeout);<br>    timeout = setTimeout(() =&gt; fn.apply(this, args), delay);<br>  };</pre><p><strong>Use debounce when:</strong></p><ul><li>You only want to run something <em>after the user finishes doing something.</em></li><li>Examples:</li><li>Typing in a search box</li><li>Validating a password field</li><li>Resizing the window (and only needing to do something <em>after</em> it’s resized)</li></ul><h3>Throttle</h3><p>Throttle makes sure the function runs at <strong>regular intervals</strong>, no matter how many times it’s triggered.</p><p>It basically says, “You can call me, but only once every X milliseconds.”</p><pre>function throttle(fn, limit) {<br>  let lastCall = 0;<br>  return function (...args) {<br>    const now = new Date().getTime();<br>    if (now - lastCall &gt;= limit) {<br>      lastCall = now;<br>      fn.apply(this, args);<br>    }<br>  };<br>}</pre><p><strong>Use throttle when:</strong></p><ul><li>The function should run <strong>continuously, but not too often.</strong></li><li>Examples:</li><li>Scroll events</li><li>Mouse movement tracking</li><li>Resize events (when you want <em>continuous updates</em>, not just one)</li></ul><h3>Want to Try It Out?</h3><p>I’ve created a tiny demo project on GitHub where you can see both debounce and throttle in action.</p><p>👉 View the GitHub projects here:<br><a href="https://github.com/lasanya-premarathne/debounce-vs-throttle--react">React version</a><br><a href="https://github.com/lasanya-premarathne/debounce-vs-throttle--javascript">Vanilla Js version</a></p><p>Feel free to fork it, clone it, or play around with it!</p><p>PS: Lodash has inbuilt useThrottle and useDebounce hooks:)</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=f45b84e7a0fc" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>