<?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 Romaisa Amjad on Medium]]></title>
        <description><![CDATA[Stories by Romaisa Amjad on Medium]]></description>
        <link>https://medium.com/@iromaisa.22?source=rss-bf9c512e68be------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*xoNayFxUofEVdk9QEPOrvA.jpeg</url>
            <title>Stories by Romaisa Amjad on Medium</title>
            <link>https://medium.com/@iromaisa.22?source=rss-bf9c512e68be------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Fri, 20 Nov 2026 21:31:11 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@iromaisa.22/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[Identifying Real Needs and Shipping Better Software]]></title>
            <link>https://medium.com/@iromaisa.22/identifying-real-needs-and-shipping-better-software-1ca08afef22c?source=rss-bf9c512e68be------2</link>
            <guid isPermaLink="false">https://medium.com/p/1ca08afef22c</guid>
            <category><![CDATA[product-developem]]></category>
            <category><![CDATA[user-needs]]></category>
            <category><![CDATA[understanding-user-needs]]></category>
            <category><![CDATA[product-development]]></category>
            <dc:creator><![CDATA[Romaisa Amjad]]></dc:creator>
            <pubDate>Sat, 02 May 2026 06:44:51 GMT</pubDate>
            <atom:updated>2026-05-02T06:44:51.482Z</atom:updated>
            <content:encoded><![CDATA[<p>Building a successful product isn’t just about mastering a tech stack; it’s about ensuring that every line of code solves a real problem. The goal is to learn how we identify user needs, translate them into requirements, and use those insights to ship meaningful work.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hjvIlmigbaPeIdydUFXmXg.jpeg" /><figcaption>Understanding user needs</figcaption></figure><h3>How to Look for Needs (The “Why”)</h3><p>Users often ask for specific features (the “X”) when they actually have a different root problem (the “Y”). This is known as the <strong>XY Problem</strong>. To find the true need, we must look past the requested solution.</p><ul><li><strong>The Mom Test:</strong> When talking to users, never pitch your idea. Instead, ask about their <strong>life and past behaviors</strong>. If they haven’t already tried to solve the problem themselves, it probably isn’t a real problem.</li><li><strong>The Five Whys:</strong> To get to the root cause of a defect or a workflow break, successively ask “Why?”. For example, a “puddle on the floor” (symptom) might lead back to “no maintenance schedule” (root cause).</li><li><strong>Jobs-to-be-Done (JTBD):</strong> View every user’s need as a <strong>“job”</strong> the user is trying to accomplish. Your product is what the user “hires” to successfully complete that job.</li></ul><h3>User Needs vs. Technical Requirements</h3><p>It is crucial to distinguish between what the user wants to achieve and how the system must behave.</p><ul><li><strong>User Needs:</strong> Focus on the problem/goal from the user’s perspective (e.g., “Radiologist needs to accurately identify lung nodules”).</li><li><strong>Requirements:</strong> Focus on technical specifications (e.g., “Software must detect lung nodules with a sensitivity of 95%”).</li><li><strong>The Rule of Thumb:</strong> Requirements should start with <strong>“Software must”</strong>, while user needs start with <strong>“User needs to”</strong>.</li></ul><h3>Integrating Needs into Development</h3><p>Once we understand the need, we don’t just start coding. We <strong>“Shape”</strong> the work first.</p><ul><li><strong>Set an Appetite:</strong> Instead of asking “How long will this take?” (estimate), we ask <strong>“How much time do we want to spend on this?”</strong> (appetite). This forces us to design a solution that fits a fixed time box.</li><li><strong>Map the Scopes:</strong> Don’t organize tasks by person (Design vs. Programming). Instead, break the project into <strong>“Scopes”</strong> thus integrating vertical slices of front-end and back-end work that can be finished independently.</li><li><strong>Use Hill Charts:</strong> Track status by uncertainty rather than task counting. Work moves from <strong>“Uphill”</strong> (figuring things out) to <strong>“Downhill”</strong> (execution). A dot that doesn’t move on the hill is a signal that someone is stuck and needs help.</li></ul><h3>The Advantages: Why Should We Work This Way</h3><p>Focusing on needs over features provides several core advantages to our development process:</p><ul><li><strong>Eliminates Runaway Projects:</strong> Using a <strong>“Circuit Breaker”</strong> (not extending a project if it hits its time limit) ensures we don’t waste months on a solution that was only worth six weeks.</li><li><strong>Prevents “Garbage” Data/Features:</strong> Building models or features before solving real problems leads to low adoption and wasted resources.</li><li><strong>Drives Autonomy:</strong> When teams are assigned a <strong>whole project</strong> (the “what”) rather than a list of tickets (the “how”), they use their judgement to make better trade-offs and discover the real tasks needed to ship.</li><li><strong>Ensures Quality over Quantity:</strong> “Scope hammering” allows us to cut peripheral “nice-to-haves” so we can polish the <strong>core functionality</strong> that actually moves the needle for the customer.</li></ul><p>We don’t want to build a “notebook demo” that stakeholders clap for; we want to build an end-to-end vertical slice that users actually adopt.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1ca08afef22c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Database Models: ACID VS BASE]]></title>
            <link>https://medium.com/@iromaisa.22/database-models-acid-vs-base-1165d4a09234?source=rss-bf9c512e68be------2</link>
            <guid isPermaLink="false">https://medium.com/p/1165d4a09234</guid>
            <category><![CDATA[learning]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[databsae]]></category>
            <category><![CDATA[exploration]]></category>
            <dc:creator><![CDATA[Romaisa Amjad]]></dc:creator>
            <pubDate>Sat, 27 Dec 2025 16:54:15 GMT</pubDate>
            <atom:updated>2025-12-27T16:54:15.775Z</atom:updated>
            <content:encoded><![CDATA[<p>ACID and BASE are fundamental transaction models that define how a database organizes, manipulates, and ensures the integrity of its data. Understanding the difference is crucial for choosing the right database (e.g., SQL vs. NoSQL) for your application.</p><h4><strong>Database Transactions:</strong></h4><p><strong><em>“A transaction is any set of operations the database treats as a single, indivisible unit of work. This unit must complete fully to be considered successful.”</em></strong></p><h4><strong>Example:</strong></h4><p>When you transfer money, the transaction includes two steps:</p><ol><li>Debiting your account.</li><li>Crediting the recipient’s account.</li><li>Both must occur for the transaction to be valid.</li></ol><h4><strong>The Trade-Off: CAP Theorem</strong></h4><p>Modern databases are often distributed (data is spread across multiple servers or nodes). According to Brewer’s theorem (or CAP theorem), a distributed system can only guarantee two out of the following three properties:</p><p><strong><em>Consistency: </em></strong>Every user receives the most recently updated data.</p><p><strong><em>Availability: </em></strong>Every database request receives a successful response (the system is always up and accessible).</p><p><strong><em>Partition Tolerance: </em></strong>The system continues to operate even if communication between some nodes fails (network issues).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/671/1*2WIMd5xn2SGg-52vTncThQ.png" /></figure><p>ACID databases prioritize Consistency. BASE databases prioritize Availability. Both systems typically strive for Partition Tolerance in a distributed environment<strong><em>.</em></strong></p><h3><strong>ACID DATABASE MODEL</strong></h3><p><strong><em>“The ACID model is the traditional standard for relational databases (like MySQL, PostgreSQL, Oracle).”</em></strong></p><p>It prioritizes Consistency and Reliability above all else. If an error occurs in any step of a transaction, the entire transaction fails and reverts to the original state.</p><h3><strong>ACID Principles:</strong></h3><h4>Atomicity</h4><p><strong><em>“All or Nothing.”</em></strong> The entire transaction must succeed, or if any part fails, the entire transaction is cancelled and reverted.</p><p><strong>Bank Transfer:</strong> If the money is withdrawn from Account A but fails to deposit into Account B, the money is put <em>back</em> into Account A.</p><h4>Consistency</h4><p>Data must always adhere to all defined rules (integrity constraints). The database moves from one <em>valid</em> state to another <em>valid</em> state.</p><p><strong>Accounting Rules:</strong> The total balance of all accounts must be the same before and after a transaction. Money cannot be created or destroyed.</p><h4>Isolation</h4><p>Multiple concurrent transactions appear to execute one after the other (serially). One transaction’s updates are hidden from others until it is <em>completed</em>.</p><p><strong>Inventory Update:</strong> If two users try to update the stock count of the same item simultaneously, the second user must wait until the first user’s update is fully committed.</p><h4>Durability</h4><p>Once a transaction is officially committed, the changes are permanent, even if the system crashes (power loss, server failure, etc.).</p><p><strong>Messaging App: </strong>After a user gets the <em>“message sent”</em> confirmation, the message will never be lost, regardless of subsequent system failures.</p><h3><strong>BASE DATABASE MODEL</strong></h3><p><strong><em>“The BASE model is often used by modern distributed and NoSQL databases (like Cassandra, MongoDB, Redis).”</em></strong></p><p>It prioritizes Availability and Scalability over immediate consistency.</p><h3><strong>BASE Principles:</strong></h3><h4>Basically Available</h4><p>The system is guaranteed to be accessible (available) for reads and writes almost all the time. Availability is prioritized.</p><p><strong>E-commerce:</strong> During a massive sale, the system stays up and allows users to browse and checkout, even if inventory counts are temporarily lagging.</p><h4>Soft State</h4><p>The data is allowed to be inconsistent temporarily (transient state). It is not guaranteed to be consistent across all nodes at all times.</p><p><strong>Social Media: </strong>If you edit your profile bio, the change might not show up for all users right away, and the system updates the visible bio on its own (softly) over time.</p><h4>Eventually Consistent</h4><p>The system guarantees that the data will become consistent across all distributed nodes at some point after all updates complete, but without a guaranteed time limit.</p><p><strong>Distributed Document Editing:</strong> Multiple users editing the same document will see temporary differences, but the system guarantees that all changes will be merged and synchronized over time.</p><h3><strong><em>KEY DIFFERENCES AND USE-CASES</em></strong></h3><p>The choice between the ACID and BASE models is fundamentally a trade-off between strict consistency and high availability.</p><p><strong>ACID</strong> databases prioritize Consistency and Data Integrity (safety) above all else, enforcing immediate consistency by requiring record locking during transactions. This strictness ensures that data is always accurate and reliable, making ACID the ideal choice for applications where money or sensitive information is involved, such as financial systems, bank transfers, and inventory management.</p><p>However, this focus on immediate consistency often makes ACID databases harder to scale horizontally and can lead to performance issues or delays when handling a very large volume of concurrent requests.</p><p>In contrast, <strong>BASE </strong>databases prioritize Availability and Partition Tolerance (liveness), making them excellent for modern, distributed applications. They embrace eventual consistency, meaning data might be temporarily inconsistent across the system, but is guaranteed to sync up over time.</p><p>Crucially, BASE operates without record locking, which drastically improves performance and makes it much easier to scale horizontally to handle massive data volumes and heavy user traffic. This model is best suited for scenarios where temporary data inconsistency is acceptable in exchange for continuous service, such as social media feeds, e-commerce product catalogs, and real-time analytics.</p><p><strong><em>“ACID is the standard for structured, relational databases (like SQL), while BASE is the architectural foundation for many modern NoSQL databases (like MongoDB or Cassandra)”</em></strong></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=1165d4a09234" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Adapter Design Patterns]]></title>
            <link>https://medium.com/@iromaisa.22/adapter-design-patterns-382333fbc7d8?source=rss-bf9c512e68be------2</link>
            <guid isPermaLink="false">https://medium.com/p/382333fbc7d8</guid>
            <category><![CDATA[adapter-design-pattern]]></category>
            <category><![CDATA[exploring]]></category>
            <category><![CDATA[learning]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[adapter-pattern]]></category>
            <dc:creator><![CDATA[Romaisa Amjad]]></dc:creator>
            <pubDate>Fri, 12 Dec 2025 18:16:12 GMT</pubDate>
            <atom:updated>2025-12-27T16:24:50.352Z</atom:updated>
            <content:encoded><![CDATA[<p><strong><em>“The Adapter Pattern is used when two systems cannot work together because their interfaces do not match.”</em></strong></p><p>It converts the incoming data or method format into the format our system already uses, so everything works smoothly.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/454/1*BgOB55KGBLJ5NcGLX1BoZA.png" /><figcaption>Adapter design pattern</figcaption></figure><h3><strong>Usage of Adapter Pattern:</strong></h3><ul><li>A new API/library returns data in a different format than your old code expects.</li><li>You are replacing a database, payment gateway, or service.</li><li>You want to keep your existing code unchanged.</li><li>Two parts of your project communicate differently.</li></ul><p>The adapter avoids rewriting your whole system.</p><h3><strong>Real Life Example:</strong></h3><p>A <em>charger adapter</em><strong> </strong>converts the plug so they fit.</p><p><em>In software:</em> The Adapter Pattern converts one data format into another so they fit.</p><p>Adapter design pattern</p><h3><strong>Example Scenario:</strong></h3><pre>// system expects one full name string<br><br>&quot;Jhon Doe&quot;</pre><pre>//new API sends:<br>{ firstName: &quot;Jhon&quot;, lastName: &quot;Doe&quot; }</pre><h3><strong>Solution : Adapter Function</strong></h3><pre><br>// Incompatible data from API<br><br>const apiData = {<br>  firstName: &quot;Jhon&quot;,<br>  lastName: &quot;Doe&quot;<br>};<br><br>// Adapter to match old interface<br><br>function nameAdapter(data) {<br>  return data.firstName + &quot; &quot; + data.lastName;<br>}<br><br>const fullName = nameAdapter(apiData);<br>console.log(fullName); // &quot;John Doe&quot;</pre><p>This adapter function converts the new api format to old format.</p><h3><strong>Real Applications in Web Development:</strong></h3><h4><strong>ORMS(Sequelize , mongoose):</strong></h4><p><strong><em>“ORMs (Object-Relational Mappers) help your code interact with a database without writing raw queries.”</em></strong></p><p>We want to write queries in JavaScript instead of directly writing database queries. These queries are then translated to the database using ORMs.</p><p><strong><em>E.g.</em></strong></p><p>Instead of writing</p><pre>SELECT * FROM users WHERE id = 1;</pre><p>We can write</p><pre>User.findByPk(1); // Sequelize<br>User.findById(1); // mongoose</pre><p>In this way, we can say that ORMs acts as an adapter i.e. translating queries written in JavaScript to the queries understandable by the database.</p><h4><strong>Payment Gateways:</strong></h4><p>Different payment providers (Stripe, PayPal, JazzCash, Easypaisa) have different APIs e.g.</p><h4>1. Stripe</h4><ul><li><strong>Payment Method:</strong> stripe.charge(amount)</li><li><strong>Amount Format:</strong> Amount must be passed <strong>in cents</strong>.</li></ul><h4>2. PayPal</h4><ul><li><strong>Payment Method:</strong> paypal.pay({ total })</li><li><strong>Amount Format:</strong> Amount is provided <strong>in dollars</strong>.</li></ul><h4>3. JazzCash</h4><ul><li><strong>Payment Method:</strong> jazzCash.makePayment(amount)</li><li><strong>Amount Format:</strong> Amount must be passed <strong>in Pakistani Rupees (PKR)</strong>.</li></ul><p>And our app wants the common interface for all, it can be achieved by adapter pattern. Without adapter, we would need a separate code for each payment method.</p><h4><strong>API Response Normalization</strong></h4><p>Different APIs return data in different formats. For example:</p><pre>const apiData = {<br>_id: &quot;123&quot;,<br>itemName: &quot;Shoes&quot;,<br>cost: 2000<br>};</pre><p>And our frontend table expects data in id, title, price format. Here, the API fields _id, itemName, and cost don’t match the frontend expected field names id, title, price. For this we can create and use an adapter function i.e.</p><pre>function tableData(apiData) {<br>  return {<br>   id: apiData._id,<br>   title: apiData.itemName,<br>   price: apiData.cost,<br>  };<br>  }</pre><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=382333fbc7d8" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Singleton Pattern]]></title>
            <link>https://medium.com/@iromaisa.22/singleton-pattern-9fbf9c18262d?source=rss-bf9c512e68be------2</link>
            <guid isPermaLink="false">https://medium.com/p/9fbf9c18262d</guid>
            <category><![CDATA[learning]]></category>
            <category><![CDATA[exploring]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[classes-and-objects]]></category>
            <dc:creator><![CDATA[Romaisa Amjad]]></dc:creator>
            <pubDate>Sun, 07 Dec 2025 16:41:56 GMT</pubDate>
            <atom:updated>2025-12-12T17:34:03.112Z</atom:updated>
            <content:encoded><![CDATA[<p><strong><em>“Singleton pattern is a design pattern which restricts a class to instantiate its multiple objects.”</em></strong></p><p>It is a way of defining a class in which the class is defined in such a way that only one instance of the class is created in the complete execution of a program.</p><h3><strong>Code Example:</strong></h3><h4><strong><em>Without singleton pattern:</em></strong></h4><p><strong><em>Steps to follow:</em></strong></p><ol><li>Create class <em>“NoSingleton”</em>.</li><li>Inside the class, create a constructor.</li><li>Generate a random number inside the constructor.</li></ol><pre>class NoSingleton {<br>  constructor() {<br>    this.data = Math.random();<br>  }<br>}<br><br>const instance1 = new NoSingleton();<br>const instance2 = new NoSingleton();<br><br>console.log(&quot;Value for instance 1:&quot;, instance1);<br>console.log(&quot;Value for instance 2:&quot;, instance2);<br>console.log(&quot;Are both instances same: &quot;, instance1.data === instance2.data);</pre><p><strong><em>Observations:</em></strong></p><p>When we create two instances of the class, the constructor is called twice, separately for both the objects so it will print different random values and the comparison string returns <strong>false. </strong>This is because this class is not a singleton class so we can make as many objects and all of them will print different random numbers.</p><p><strong><em>Output snapshot:</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yzh5X-EJB2qepD0dB-9X-Q.png" /><figcaption>Figure 1: Output snapshot of non singleton class</figcaption></figure><p>In the output we can see both the objects have different random numbers and the instance comparison returns false.</p><h4><strong><em>With singleton pattern:</em></strong></h4><p><strong><em>Steps to follow:</em></strong></p><ol><li>Create class Singleton.</li><li>Inside the class, create a constructor. Inside the constructor, write an if statement that <strong><em>“if instance is created once then return the previous one” </em></strong>otherwise create the instance.</li><li>Generate a random number inside the constructor.</li></ol><pre>class Singleton {<br>  constructor() {<br>    if (Singleton.instance) {<br>      return Singleton.instance;<br>    }<br><br>    this.data = Math.random();<br>    Singleton.instance = this;<br>  }<br>}<br><br>const instance1 = new Singleton();<br>const instance2 = new Singleton();<br><br>console.log(&quot;Value for instance 1:&quot;, instance1);<br>console.log(&quot;Value for instance 2:&quot;, instance2);<br>console.log(&quot;Are both instances same: &quot;, instance1.data === instance2.data);</pre><p><strong><em>Observations:</em></strong></p><p>When we create two instances of this class, the same constructor is called twice, both the objects will print the same random values and the comparison string returns <strong>true. </strong>This is because this class is a singleton class so when an object is created, it checks through the if statement i.e. if an object is created before. If yes, then it returns the already created object (do not create new object). If not, then it creates an object and returns it and after this whenever the object is created for the Singleton class, the same response will be given.</p><p><strong><em>Output snapshot:</em></strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jJFtvxIpHH7vTSstHq9eSg.png" /><figcaption>Figure 2: Output snapshot of singleton class</figcaption></figure><p>In the output we can see both the objects have the same random number and the instance comparison returns true.</p><p><strong><em>Uses of Singleton Pattern:</em></strong></p><ol><li><strong><em>Database Connection:</em></strong> we connect the server to the database via sequelize where we create a single instance and use it all over the code.</li><li><strong><em>Query client instance:</em></strong> query client instance from Tanstack Query, where we instantiate once and use in all hooks.</li><li><strong><em>Authentication:</em></strong> On first time login a token is generated with some n expiry duration which we use all over the application.</li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9fbf9c18262d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Database Transactions & Row locking transactions]]></title>
            <link>https://medium.com/@iromaisa.22/database-transactions-row-locking-transactions-2868856e4174?source=rss-bf9c512e68be------2</link>
            <guid isPermaLink="false">https://medium.com/p/2868856e4174</guid>
            <category><![CDATA[web-technology]]></category>
            <category><![CDATA[learning]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[exploring]]></category>
            <dc:creator><![CDATA[Romaisa Amjad]]></dc:creator>
            <pubDate>Sun, 07 Dec 2025 16:29:47 GMT</pubDate>
            <atom:updated>2025-12-12T17:35:27.685Z</atom:updated>
            <content:encoded><![CDATA[<p><strong><em>“ A transaction is a sequence of operations performed as a single logical unit of work”</em></strong></p><p>Transactions maintains the consistency of the database by ensuring:</p><ol><li>Either all operations succeed (commit).</li><li>If any operation fails then none do (rollback)</li></ol><h3><strong><em>Case scenario:</em></strong></h3><p>For instance we are creating an ecommerce store in which we wanted when customer is created, it’s cart is also created:</p><p><strong><em>Without transaction:</em></strong></p><p>In case we have not defined the transactions, if while creating a customer some error occurred and then creating a cart is not executed then the customer entry will be added and there will be no cart for that customer</p><pre>exports.signup = asyncWrapper(async function (req, res) {<br>   try {<br>     const { name, email, password, gender, balance } = req.body;<br> <br>     const salt = await bcrypt.genSalt(12);<br>     const hashedPassword = await bcrypt.hash(password, salt);<br> <br>     const [customer] = await Customers.findOrCreate({<br>       where: { email },<br>       defaults: {<br>         name,<br>         password: hashedPassword,<br>         gender,<br>         balance,<br>       },<br>     });<br> <br>     await Cart.findOrCreate({<br>       where: { fk_customer_id: customer.id },<br>     });<br> <br>     res.status(201).send(customer);<br>   } catch (err) {<br>     throw err; <br>   }<br> });</pre><p>In the above code, in the try block we created a customer.Suppose the operation is successful till line 15 and then the query of creating the card fails. Now in this case the customer will be created but the card for the customer is not created. We want that if a customer is created the corresponding cart must be created otherwise no customer is going to be created. To achieve this we use transactions</p><p><strong><em>With transaction:</em></strong></p><pre>exports.signup = asyncWrapper(async function (req, res) {<br>   const transaction = await sequelize.transaction();<br>   try {<br>     const { name, email, password, gender, balance } = req.body;<br> <br>     const salt = await bcrypt.genSalt(12);<br>     const hashedPassword = await bcrypt.hash(password, salt);<br> <br>     const [customer] = await Customers.findOrCreate({<br>       where: { email },<br>       defaults: {<br>         name,<br>         password: hashedPassword,<br>         gender,<br>         balance,<br>       },<br>       transaction : transaction<br>     });<br> <br>     await Cart.findOrCreate({<br>       where: { fk_customer_id: customer.id },<br>       transaction,<br>     });<br> <br>     await transaction.commit();  // releases lock<br> <br>     res.status(201).send(customer);<br>   } catch (err) {<br>     await transaction.rollback(); // if error then <br>     throw err; <br>   }<br> });</pre><p>In the above code, now we have added transactions. While creating a customer and a cart, the operations are wrapped inside a transaction in the try block, and if all operations succeed, the transaction commits the data to the database. In a catch block, in case of an error the transaction will roll back i.e. no record is going to be created if any query fails.</p><p><strong><em>Row locking advantage:</em></strong></p><p>Transactions ensure controlled access to the database by locking the rows involved in the operation. When one query is actively reading or modifying a particular piece of data, the database prevents other queries from accessing or changing that same data until the first operation is complete. This row-level locking avoids conflicts, race conditions, and inconsistent results especially in multi-user systems where many requests occur at the same time.</p><h4>DATABASE TRANSACTIONS WITH REFERENCE TO THE CONCEPT OF ACID:</h4><p>The concept of transactions of the database refers to the concept of ACID i.e.</p><ol><li><strong><em>A(atomicity):</em></strong> The entire transaction happens at once or nothing happens at all.</li><li><strong><em>C(consistency): </em></strong>The database must be consistent before and after the transaction.</li><li><strong><em>I(isolation): </em></strong>Multiple transactions occur independently without interference.</li><li><strong><em>D(durability):</em></strong>It ensures if the transaction is committed, the changes are saved.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jZE9C_Ez_UpopYXixO77Nw.png" /><figcaption>Database concept with reference to ACID</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2868856e4174" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Factory Functions]]></title>
            <link>https://medium.com/@iromaisa.22/factory-functions-cac588549c8d?source=rss-bf9c512e68be------2</link>
            <guid isPermaLink="false">https://medium.com/p/cac588549c8d</guid>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[learning]]></category>
            <category><![CDATA[exploration]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[web-technology]]></category>
            <dc:creator><![CDATA[Romaisa Amjad]]></dc:creator>
            <pubDate>Wed, 03 Dec 2025 14:26:25 GMT</pubDate>
            <atom:updated>2025-12-12T17:37:06.275Z</atom:updated>
            <content:encoded><![CDATA[<p><strong><em>“ Factory functions are a form of design pattern that enables the creation of objects with specific properties and behaviors ”</em></strong></p><h3><strong>Significance:</strong></h3><p>If we have complex logic, and we have to create multiple objects again and again that have the same logic, we can write the logic once in a function and use that function as a factory to create our objects. It’s the same as a real-world factory producing products.</p><h3><strong>Case Scenario:</strong></h3><p>When we write:</p><pre>const object1= {<br>    // some code for object 1<br>}</pre><p>This works perfectly when you only need one object. But if you need multiple objects with small differences, defining the object multiple times with minor changes is not a good approach e.g. creating n objects</p><pre>const object1= {<br>    // some code for object 1<br>}<br>const object2 = {<br>    // some code for object 2<br>}<br>const object3 = {<br>    // some code for object 3<br>}<br>const object4 = {<br>    // some code for object 4<br>}<br>const objectn = {<br>    // some code for object n<br>}</pre><p><strong><em>Because by adopting this approach:</em></strong></p><ul><li>We are repeating the same logic again and again.</li><li>It becomes harder to maintain.</li><li>If we need 50 or 100 objects, our code becomes messy.</li><li>Any change requires editing every object manually.</li></ul><p>By using a factory function, it will return a new object every time depending on the input we give.</p><h4><strong>Creating an object without factory function:</strong></h4><pre>const me = {<br>    name: &quot;Rex&quot;,<br>    talk(){<br><br>        return `${this.name} is talking`;<br>    }<br>}<br>const friend = {<br>    name: &quot;John&quot;,<br>    talk(){<br>        return `${this.name} is talking`;<br>    }<br>}<br>console.log(me.talk()); // Rex is talking<br>console.log(friend.talk()); // John is talking<br>me.name = &quot;Rex Jr.&quot;;<br>console.log(me.talk()); // Rex Jr. is talking</pre><p>In the above code we created two objects with name i.e. John and Rex and function talk.</p><p><strong><em>In the current scenario two points are noted:</em></strong></p><ol><li>Both objects are the same but are declared for different names.</li><li>The name variable can be accessed and we can change the declared value.</li></ol><h4><strong><em>Creating object with factory function:</em></strong></h4><pre>function factoryFunction(name){<br><br>    return{ <br>        name: name,<br>        talk(){<br>            return `${name} is talking`;<br>        }<br>    };<br><br>}<br><br>const rex = factoryFunction(&quot;Rex&quot;);<br>const john = factoryFunction(&quot;John&quot;);<br>console.log(rex.talk()); // Rex is talking<br>console.log(john.talk());// John is talking</pre><p>Now, in the above scenario where we created a generic factory function which can take name as an argument and as a result gives the whole object, so we don’t need a separate object for n number of same objects.</p><h3><strong><em>ADVANTAGES OF FACTORY FUNCTIONS:</em></strong></h3><ol><li>We can isolate common logic and write it only once (no duplicate code).</li><li>In case of a bug we have to search for it only at one block of code.</li></ol><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=cac588549c8d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Idempotency]]></title>
            <link>https://medium.com/@iromaisa.22/idempotency-768ec2e23fd6?source=rss-bf9c512e68be------2</link>
            <guid isPermaLink="false">https://medium.com/p/768ec2e23fd6</guid>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[exploration]]></category>
            <category><![CDATA[web-technology]]></category>
            <category><![CDATA[idempotency]]></category>
            <dc:creator><![CDATA[Romaisa Amjad]]></dc:creator>
            <pubDate>Wed, 03 Dec 2025 14:11:10 GMT</pubDate>
            <atom:updated>2025-12-12T17:37:32.174Z</atom:updated>
            <content:encoded><![CDATA[<p><strong><em>“Idempotency is the property of an operation that ensures executing it multiple times produces the same final outcome as executing it only once.”</em></strong></p><p>In the context of APIs, an operation is idempotent if its side effects (the changes it makes to the server’s state) are applied only once, regardless of how many times the request is successfully processed or retried<strong>.</strong></p><h4><strong><em>Issues with Non-Idempotent APIs:</em></strong></h4><p>When an API endpoint is not idempotent, a primary issue is the potential for creating duplicate records in the backend.</p><h3><strong><em>Case Scenario: Non-Idempotent Payment Reques</em>t</strong></h3><ul><li><strong><em>Client Request:</em></strong> A client sends a POST request.</li><li><strong><em>Partial Success:</em></strong><em> </em>The server successfully validates the request and stores the payment data in the database.</li><li><strong><em>Server Failure</em></strong><em>:</em> When it was time to notify the customer, an error (e.g., 500 Internal Server Error) occurred.</li><li><strong><em>Client Retries:</em></strong> The user, having not received a success notification, retries the payment request.</li><li><strong><em>Result:</em></strong> The server processes the payment again, leading to the user being charged twice.</li></ul><p>This occurs because the original POST request, which stores new entry, is not idempotent by default. Retrying the request causes an unintended and harmful side effect <strong>(double payment)</strong>.</p><p>After multiple requests for the same operation, despite<strong><em> n failures</em></strong>, the final system state must be the same as if the operation had succeeded only once.</p><h3><strong><em>Solution to the Problem:</em></strong></h3><p>To make a non-idempotent request (like a POST request for payment) safe to retry, we use a unique identifier called an <em>Idempotency-Key.</em></p><h4><strong><em>Working:</em></strong></h4><p>The client generates a unique ID, called the <strong><em>Idempotency-Key</em>. </strong>This Idempotency-Key is sent to the server within a header. When a new request arrives, the server first checks cache to determine if the received Idempotency-Key has been processed before. If the key is not found, the server executes the operation, such as processing a payment. Following the successful execution, the server stores the Idempotency-Key in the cache, associating it with the final response or status of the operation, before sending the actual response to the client.</p><p>Conversely, if a subsequent request arrives with an Idempotency-Key that is found in the cache, the server recognizes it as a retry. In this case, it immediately skips the execution of the operation, effectively preventing duplicate execution of tasks. Instead of processing, it retrieves the original stored response associated with that key from the cache and sends it back to the client, thereby guaranteeing that the operation is executed only once and all retries receive a consistent result. The stored keys are not kept permanently but are configured with an expiry time (TTL), typically around <strong><em>24 hours</em></strong>, to automatically clear the cache.</p><h3><strong>HTTP Methods and Its nature</strong></h3><ol><li><strong>GET:</strong></li></ol><p>Idempotency nature: Yes</p><p>Reason: Retrieving data has no side effects.</p><p><strong>2. PUT:</strong></p><p>Idempotency nature: Yes</p><p>Reason: Replacing data at a given URL results in the same every time.</p><p><strong>3. DELETE:</strong></p><p>Idempotency nature: Yes</p><p>Reason: Deleting a data, whether executed once or multiple times, results in the one data being deleted</p><p><strong>4. POST:</strong></p><p>Idempotency nature: No</p><p>Reason: It creates a new data entry, so executing it multiple times usually creates multiple resources.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0H5E_xd0X4H82paa5v15BQ.jpeg" /><figcaption>HTTP meothods Idemopotency and it’s nature</figcaption></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=768ec2e23fd6" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Designing a Static Website with Canva: A Beginner’s Guide]]></title>
            <link>https://medium.com/@iromaisa.22/designing-a-website-with-canva-a-beginners-guide-18bfb958959f?source=rss-bf9c512e68be------2</link>
            <guid isPermaLink="false">https://medium.com/p/18bfb958959f</guid>
            <category><![CDATA[learning]]></category>
            <category><![CDATA[canva-pro]]></category>
            <category><![CDATA[website]]></category>
            <category><![CDATA[beginners-guide]]></category>
            <category><![CDATA[website-development]]></category>
            <dc:creator><![CDATA[Romaisa Amjad]]></dc:creator>
            <pubDate>Mon, 08 Sep 2025 10:48:41 GMT</pubDate>
            <atom:updated>2026-02-05T06:56:33.436Z</atom:updated>
            <content:encoded><![CDATA[<p>When we think of website development, <strong>HTML/CSS and JavaScript frameworks</strong> are usually the first tools that come to mind. However, <strong>Canva</strong>, originally known as a visual design platform, has evolved into a practical <strong>no-code website builder</strong> that’s perfect for resumes, portfolios, landing pages, and quick demos you can share with clients or teams.</p><p>With its <strong>drag-and-drop editor</strong>, Canva makes it easy to design responsive websites without writing a single line of code.</p><p>In this article, I’ll share my own exploration of Canva web development and how new developers (and non-developers) can take advantage of it.</p><h4><strong><em>1. Getting started; account and environment:</em></strong></h4><ul><li>Sign up or log in to <a href="https://www.canva.com/">Canva.</a></li><li>From the Dashboard, search for <strong>“Website”</strong> and select it.</li><li>Canva will open the <strong>Website Builder environment</strong> where you can either start with a blank design or choose from hundreds of templates.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*gdzqOU9WfP7lHb51EnB4Gg.png" /><figcaption>Canva Dashboard</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*3Af9YiNELaJ_P6KzCOUPYg.png" /><figcaption>Website builder environment in Canva</figcaption></figure><h4><strong><em>2. Start building (templates, structure, and elements):</em></strong></h4><ul><li>Choosing a template is great for quick layouts and design inspiration.</li><li>If you want full creative freedom, then you can start creating a website from scratch.</li><li>Use Canva elements like Frames, grids, icons, and shapes work like the building blocks of a coded website (think of them like &lt;div&gt; containers).</li><li>Photo frame in Canva are Perfect for profile pictures, banners, or product shots.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aPI9F71ORrOlS9UQaySRXA.png" /><figcaption>Use elements in Canva for building a website</figcaption></figure><h4><strong><em>3. Adding links:</em></strong></h4><p>Links make your site interactive:</p><ul><li>Copy the URL you want to add.</li><li>Right click the element (text, button, or image) you want to add link.</li><li>Select the Link option and paste the URL, click Done.</li><li>Now when visitors click the element, they’re redirected to the link.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aXmDMcT-R9hDuDyVk6HmGw.png" /><figcaption>Step 1: Copy Link address you want to add</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DAdrd4mXXxsaCtbqhlpsuQ.png" /><figcaption>Step 2: Create an element and right click on it to select the link option</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5I_EGIbcXkntKp1z-LSYWw.png" /><figcaption>Step 3: paste the link and click done.</figcaption></figure><h4><strong><em>4. Navigation bar (how it is generated and limitations)</em></strong></h4><p>Navigation is automatically generated from <strong>page titles</strong> in Canva.</p><ul><li>Give each page a clear title (e.g., Home, About, Contact).</li><li>Canva creates a navigation menu for desktop and mobile.</li><li>For custom navigation, you can also create your own nav buttons and link them manually.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2ZHLqp3C4OwU2VdHIJolJQ.png" /><figcaption>Add a clear page title</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HdXUWlXpm94VhMO85JKcww.png" /><figcaption>Automatic navigation bar added</figcaption></figure><h4><strong><em>5. Embedding Google Forms and other embeds</em></strong></h4><p>We can add forms in Canva website for feedback and contact</p><ul><li>Go to <strong>Google Forms</strong> and create your form.</li><li>Copy its shareable link.</li><li>In Canva, go to <strong>Apps and Embed</strong> and paste the URL.</li><li>Canva will create a responsive frame with your form.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*W_y8C5nCltNyjywLwsfzUw.png" /><figcaption>Sign up and create a form</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MAt1AM0b8gUlx94rm7iBcA.png" /><figcaption>Copy the Link</figcaption></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*2n_oA1MNqUhg6jAEdQUmbQ.png" /><figcaption>Embed the form using Embed Option in Canva</figcaption></figure><h4><strong><em>6. Responsiveness: preview and edit for mobile</em></strong></h4><p>Canva also offers an opportunity to make your website responsive in both mobile and large screens</p><ul><li>Click <strong>Preview </strong>option<strong> </strong>in Canva.</li><li>Switch between Desktop and Mobile views.</li><li>Adjust spacing, font size, and element layout until your site looks balanced on all screen sizes.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*kEjJPjeeJZQ8_ZCkEznW5w.png" /><figcaption>Preview option in canva; both for mobile and larger screens</figcaption></figure><h4><strong><em>7. Animations and motion</em></strong></h4><p>Canva supports element and page animations (the same Animate tool used in presentations). Select an element and choose <strong>Animate</strong> to apply entrance or motion effects. Advanced interactivity e.g. animations on click or hover with custom script is limited compared with custom web development.</p><h4><strong><em>8. Publishing: domains, SEO, and privacy</em></strong></h4><ul><li>To publish a Canva website, Canva provides two options; choose a Canva free domain <strong>(example: yourname.my.canva.site</strong>) or connect / purchase a custom domain. According to Canva’s terms: free accounts can publish up to <strong>five (5)</strong> Canva Sites to the free my.canva.site URL.</li><li>In Publish settings you can set the <strong><em>Website title</em>, <em>favicon</em>, and <em>description</em>, </strong>and toggle Search engine visibility on or off before publishing. Use a concise description (meta description) and clear page titles to help discoverability.</li><li>Canva provides the option to password-protect sites or hide them from search engines for private sharing</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-Enmy49dmNbErE9oU6T9Fg.png" /><figcaption>Canva Publish website</figcaption></figure><h4><strong><em>9. Analytics and insights</em></strong></h4><p>Canva provides <strong>Website Insights</strong> i.e. views, traffic, engagement inside Canva; however,<strong> <em>Website Insights are available to Canva Pro, Teams, and Education users</em></strong> who have edit access to the site. If you need advanced analytics, those integrations may not be available by default.</p><h4>10. Exporting and converting to real code</h4><p>Canva does not provide a reliable <strong>export full website as production-ready HTML/CSS/JS </strong>workflow intended for continuing development. Some people save a published Canva website from the browser <strong>(Save → Webpage)</strong> or use third-party conversion tools, but these approaches are brittle and produce code that typically needs heavy cleanup. If you plan to convert a Canva design into a real web app, treat the Canva output as a visual design and reimplement it using a framework of your choice.</p><h3>Limitations And when <strong>not</strong> to use Canva</h3><p>If your project includes only static data then Canva can be helpful but if your project requires custom back-end logic, server-side data handling, or advanced SEO/analytics control, In such cases, to a code-based stack (e.g., MERN) and refactor the project for scalability and flexibility.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=18bfb958959f" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>