<?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>Forem: Devmancer</title>
    <description>The latest articles on Forem by Devmancer (@devmancer10).</description>
    <link>https://forem.com/devmancer10</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%2F1317805%2F5376cfe9-0656-48a5-8548-ef5b7b3a58d6.png</url>
      <title>Forem: Devmancer</title>
      <link>https://forem.com/devmancer10</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/devmancer10"/>
    <language>en</language>
    <item>
      <title>The big-o-notation</title>
      <dc:creator>Devmancer</dc:creator>
      <pubDate>Sat, 21 Feb 2026 00:39:32 +0000</pubDate>
      <link>https://forem.com/devmancer10/the-big-o-notation-33dg</link>
      <guid>https://forem.com/devmancer10/the-big-o-notation-33dg</guid>
      <description>&lt;p&gt;When we talk about algorithms, we often describe them using asymptotic notation, and one of the most common types is Big-O notation.&lt;/p&gt;

&lt;p&gt;Big-O represents the worst-case time complexity of an algorithm.&lt;/p&gt;

&lt;p&gt;But what does that really mean?&lt;/p&gt;

&lt;p&gt;Think of it like this:&lt;/p&gt;

&lt;p&gt;Big-O asks your code:&lt;br&gt;
“As more customers come in, how crazy does the work become?”&lt;/p&gt;

&lt;p&gt;In other words, Big-O measures how your code behaves as the input size gets bigger.&lt;/p&gt;

&lt;p&gt;What is “n”?&lt;/p&gt;

&lt;p&gt;n represents the size of the input.&lt;/p&gt;

&lt;p&gt;For example:&lt;/p&gt;

&lt;p&gt;If you have an array with 5 numbers → n = 5&lt;/p&gt;

&lt;p&gt;If you have 1000 numbers → n = 1000&lt;/p&gt;

&lt;p&gt;Big-O is simply asking:&lt;/p&gt;

&lt;p&gt;If n increases, how much do the number of steps increase?&lt;/p&gt;

&lt;p&gt;O(1) —&amp;gt; Constant Time&lt;br&gt;
const array = [1, 2, 3, 4];&lt;br&gt;
console.log(array[0]);&lt;/p&gt;

&lt;p&gt;This is O(1) —&amp;gt; constant time.&lt;/p&gt;

&lt;p&gt;Why?&lt;/p&gt;

&lt;p&gt;Because it doesn’t matter if the array has:&lt;/p&gt;

&lt;p&gt;4 elements&lt;/p&gt;

&lt;p&gt;1,000 elements&lt;/p&gt;

&lt;p&gt;1,000,000 elements&lt;/p&gt;

&lt;p&gt;Accessing array[0] always takes one step.&lt;/p&gt;

&lt;p&gt;The work does not grow as n grows.&lt;/p&gt;

&lt;p&gt;O(n) —&amp;gt; Linear Time&lt;br&gt;
for (let i = 0; i &amp;lt; arr.length; i++) {&lt;br&gt;
  console.log(arr[i]);&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;This is O(n) —&amp;gt; linear time.&lt;/p&gt;

&lt;p&gt;Why?&lt;/p&gt;

&lt;p&gt;Because the loop runs once for every element.&lt;/p&gt;

&lt;p&gt;If there are 5 elements → the loop runs 5 times&lt;/p&gt;

&lt;p&gt;If there are 100 elements → the loop runs 100 times&lt;/p&gt;

&lt;p&gt;The number of operations grows at the same rate as the input size.&lt;/p&gt;

&lt;p&gt;If n doubles, the work doubles.&lt;/p&gt;

&lt;p&gt;O(n²) —&amp;gt; Quadratic Time&lt;br&gt;
for (let i = 0; i &amp;lt; n; i++) {&lt;br&gt;
  for (let j = 0; j &amp;lt; n; j++) {&lt;br&gt;
    console.log(i, j);&lt;br&gt;
  }&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;This is O(n²) —&amp;gt; quadratic time.&lt;/p&gt;

&lt;p&gt;Why?&lt;/p&gt;

&lt;p&gt;The outer loop runs n times.&lt;/p&gt;

&lt;p&gt;For each outer loop, the inner loop also runs n times.&lt;/p&gt;

&lt;p&gt;So total operations = n × n = n².&lt;/p&gt;

&lt;p&gt;If:&lt;/p&gt;

&lt;p&gt;n = 5 → 5 × 5 = 25 operations&lt;/p&gt;

&lt;p&gt;n = 100 → 100 × 100 = 10,000 operations&lt;/p&gt;

&lt;p&gt;Now the work grows much faster than the input.&lt;/p&gt;

&lt;p&gt;If n doubles, the work increases four times.&lt;/p&gt;

&lt;p&gt;Important Rule About Big-O&lt;/p&gt;

&lt;p&gt;Big-O cares about growth, not exact numbers.&lt;/p&gt;

&lt;p&gt;If an algorithm takes:&lt;/p&gt;

&lt;p&gt;2n² + 10n + 100&lt;/p&gt;

&lt;p&gt;We still write it as:&lt;/p&gt;

&lt;p&gt;O(n²)&lt;/p&gt;

&lt;p&gt;Why?&lt;/p&gt;

&lt;p&gt;Because when n becomes very large, the n² term dominates everything else.&lt;/p&gt;

&lt;p&gt;Big-O keeps only the fastest-growing term.&lt;/p&gt;

&lt;p&gt;Quick Summary&lt;/p&gt;

&lt;p&gt;O(1) → stays the same no matter what&lt;/p&gt;

&lt;p&gt;O(n) → grows at the same rate as the input&lt;/p&gt;

&lt;p&gt;O(n²) → grows much faster than the input&lt;/p&gt;

&lt;p&gt;Big-O measures growth as input increases&lt;/p&gt;

&lt;p&gt;We ignore constants and smaller terms&lt;/p&gt;

</description>
      <category>newbie</category>
      <category>algorithms</category>
      <category>dev</category>
    </item>
    <item>
      <title>my understanding of crud applications,controllers, and middlewares.</title>
      <dc:creator>Devmancer</dc:creator>
      <pubDate>Fri, 21 Nov 2025 18:26:46 +0000</pubDate>
      <link>https://forem.com/devmancer10/my-understanding-of-crud-applicationscontrollers-and-middlewares-16c8</link>
      <guid>https://forem.com/devmancer10/my-understanding-of-crud-applicationscontrollers-and-middlewares-16c8</guid>
      <description>&lt;p&gt;Okay, before we start - quick disclaimer: I am in no way a professional. I'm just typing this stuff here because I'm too lazy to write notes in my book.&lt;/p&gt;

&lt;p&gt;Now, let's begin!&lt;/p&gt;

&lt;p&gt;To me, CRUD applications feel like the backbone of many systems. They help us Create, Read, Update, and Delete data - you know, the stuff everyone knows. But during my adventure in the world of CRUD, I seemed to have found another layer, a deeper mystery so to speak.&lt;/p&gt;

&lt;p&gt;Long story short, I basically had to understand the difference between middleware and controllers. To be honest, I don't really know where to draw the line completely, but my knowledge has evolved since last time - I'll tell you that!&lt;/p&gt;

&lt;p&gt;I used to think that anything with app.use() was middleware (not my proudest moment, to be honest - don't judge! Also, if you're planning to, please notice the #newbie hashtag - thanks!).&lt;/p&gt;

&lt;p&gt;My Middleware vs Controller Revelation&lt;br&gt;
Now I've figured out it's much more intriguing than that. The main distinction I found separating middleware and controllers is that controllers handle the final response, while middleware uses next() to pass control to the next function.&lt;/p&gt;

&lt;p&gt;Code exmaple:&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%2Fhero81eld0fh1roprvky.JPG" 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%2Fhero81eld0fh1roprvky.JPG" alt="code example" width="800" height="511"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;just think of middlewares as waiters:&lt;br&gt;
they, &lt;/p&gt;

&lt;p&gt;Grinds the beans &lt;/p&gt;

&lt;p&gt;Steams the milk &lt;/p&gt;

&lt;p&gt;Checks if you paid &lt;/p&gt;

&lt;p&gt;Then passes it along  "Next!"&lt;/p&gt;

&lt;p&gt;then controllers they are the ones who:&lt;/p&gt;

&lt;p&gt;Puts everything together &lt;/p&gt;

&lt;p&gt;Adds the final touches &lt;/p&gt;

&lt;p&gt;Hands you the finished drink  "Here's your coffee!"&lt;/p&gt;

&lt;p&gt;(beautiful illustration analogy btw )&lt;/p&gt;

&lt;p&gt;The Order Matters Saga&lt;br&gt;
Oh, and lest I forget - did you know that the order of middleware actually matters? Funny story: I actually found that out while setting up routes for my operations, and I put updateUser before validateUser. Thank god for ChatGPT, am I right guys?&lt;/p&gt;

&lt;p&gt;Anyway, let's not glaze Sam right now. I'm quite happy I've gained this knowledge!&lt;/p&gt;

&lt;p&gt;Follow me to see my next blog on Swagger documentation!&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>backend</category>
      <category>newbie</category>
    </item>
    <item>
      <title>Why parametized functions make your code cleaner</title>
      <dc:creator>Devmancer</dc:creator>
      <pubDate>Thu, 04 Sep 2025 20:33:01 +0000</pubDate>
      <link>https://forem.com/devmancer10/why-parametized-functions-make-your-code-cleaner-507l</link>
      <guid>https://forem.com/devmancer10/why-parametized-functions-make-your-code-cleaner-507l</guid>
      <description>&lt;p&gt;When you’re new to JavaScript, it’s tempting to write logic directly inside event listeners. It works until your code grows. Soon you’re repeating yourself, fixing bugs in multiple places, and struggling to keep everything in sync. Thats why parametized functions is important. &lt;/p&gt;

&lt;p&gt;Take this example of a calculator app. Each button (+, -, ×, /) needs to:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Save the first number.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Store the operator.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Clear the display.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Without parameters, you end up repeating logic: &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%2Fxc55pm34qy08ijw28487.JPG" 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%2Fxc55pm34qy08ijw28487.JPG" alt=" " width="395" height="231"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Instead of repeating the same steps, wrap them into one reusable function with a parameter:&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%2Ficue2egahpqc9d1s831q.JPG" 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%2Ficue2egahpqc9d1s831q.JPG" alt=" " width="597" height="230"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;this improves usability because:&lt;/p&gt;

&lt;p&gt;DRY Principle (Don’t Repeat Yourself): One function handles all operators.&lt;/p&gt;

&lt;p&gt;Easier Maintenance: Change logic once, and every operator updates.&lt;/p&gt;

&lt;p&gt;Scalable: Adding more operators (like % or √) is just one line.&lt;/p&gt;

&lt;p&gt;Readable: The intent is clear  “set operator to X"&lt;/p&gt;

&lt;p&gt;I do think parametized functions make your code clean and reusable&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>beginners</category>
    </item>
  </channel>
</rss>
