<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: HILQIA KENDA</title>
    <description>The latest articles on DEV Community by HILQIA KENDA (@hilqia_kenda).</description>
    <link>https://dev.to/hilqia_kenda</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%2F2473981%2Fe87e942a-b4ac-49c9-8536-cc2fccdf1269.jpg</url>
      <title>DEV Community: HILQIA KENDA</title>
      <link>https://dev.to/hilqia_kenda</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/hilqia_kenda"/>
    <language>en</language>
    <item>
      <title>Rebuilding RouteMatrix</title>
      <dc:creator>HILQIA KENDA</dc:creator>
      <pubDate>Mon, 23 Feb 2026 16:08:09 +0000</pubDate>
      <link>https://dev.to/hilqia_kenda/rebuilding-routematrix-374b</link>
      <guid>https://dev.to/hilqia_kenda/rebuilding-routematrix-374b</guid>
      <description>&lt;p&gt;A few months ago, I shipped the first version of &lt;strong&gt;RouteMatrix&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Technically, it worked.&lt;br&gt;&lt;br&gt;
Users could create trips. Data flowed. The system held up.&lt;/p&gt;

&lt;p&gt;But something felt off.&lt;/p&gt;

&lt;p&gt;I was shipping features… without deep clarity.&lt;/p&gt;

&lt;p&gt;So I paused and asked myself a harder question:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;What problem am I actually solving?&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;That question forced a reset.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Realization
&lt;/h2&gt;

&lt;p&gt;RouteMatrix started as a generic trip management tool.&lt;/p&gt;

&lt;p&gt;But logistics teams don’t need “trip tools.”&lt;/p&gt;

&lt;p&gt;They need:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Clear fleet visibility
&lt;/li&gt;
&lt;li&gt;Accountability across drivers and dispatch
&lt;/li&gt;
&lt;li&gt;Operational clarity without chasing spreadsheets
&lt;/li&gt;
&lt;li&gt;Reliable tracking that reflects real-world constraints
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I wasn’t building for those pains directly.&lt;/p&gt;

&lt;p&gt;So instead of iterating on surface features, I decided to rethink the foundation.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Rebuild
&lt;/h2&gt;

&lt;p&gt;RouteMatrix is now being rebuilt as a &lt;strong&gt;Tracking Truck SaaS&lt;/strong&gt; — designed specifically around operational workflows in logistics.&lt;/p&gt;

&lt;p&gt;This isn’t a UI redesign.&lt;/p&gt;

&lt;p&gt;It’s a structural shift:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;New architecture&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;New data model&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;New mental model&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I’m redesigning how trips are represented.&lt;br&gt;
How tracking events are stored.&lt;br&gt;
How fleet-level aggregation works.&lt;br&gt;
How accountability is enforced at the system level.&lt;/p&gt;

&lt;p&gt;Less “feature shipping.”&lt;br&gt;&lt;br&gt;
More system design thinking.&lt;/p&gt;




&lt;h2&gt;
  
  
  Building in Public
&lt;/h2&gt;

&lt;p&gt;I’m documenting the rebuild openly:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Architecture decisions
&lt;/li&gt;
&lt;li&gt;Mistakes
&lt;/li&gt;
&lt;li&gt;Trade-offs
&lt;/li&gt;
&lt;li&gt;What I’d never do again
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Future posts will go deeper into:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Backend architecture&lt;/li&gt;
&lt;li&gt;Data modeling for fleet tracking&lt;/li&gt;
&lt;li&gt;Scaling event ingestion&lt;/li&gt;
&lt;li&gt;Designing for operational clarity instead of feature volume&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you’re building in logistics, fleet management, or SaaS infrastructure — I’d love to exchange ideas (or even collaborate).&lt;/p&gt;

&lt;p&gt;The next updates will be more technical 👀&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%2Fh62s7wr9qalfod0zwqs2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fh62s7wr9qalfod0zwqs2.png" alt="trips list" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>backend</category>
      <category>designsystem</category>
      <category>softwareengineering</category>
      <category>softwaredevelopment</category>
    </item>
    <item>
      <title>Why Refactoring Can’t Save Bad Architecture</title>
      <dc:creator>HILQIA KENDA</dc:creator>
      <pubDate>Sat, 14 Feb 2026 13:15:32 +0000</pubDate>
      <link>https://dev.to/hilqia_kenda/why-refactoring-cant-save-bad-architecture-17ee</link>
      <guid>https://dev.to/hilqia_kenda/why-refactoring-cant-save-bad-architecture-17ee</guid>
      <description>&lt;p&gt;When a codebase starts to feel messy, the first instinct is almost automatic:&lt;/p&gt;

&lt;p&gt;“Let’s refactor it.”&lt;/p&gt;

&lt;p&gt;I did that.&lt;br&gt;
Again.&lt;br&gt;
And again.&lt;br&gt;
And again.&lt;/p&gt;

&lt;p&gt;Each time, the code looked cleaner — for a while.&lt;/p&gt;

&lt;p&gt;But no matter how much I refactored, the system kept collapsing back into complexity. New features would arrive, and the mess would quietly return as if nothing had changed.&lt;/p&gt;

&lt;p&gt;That’s when I learned something the hard way:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Refactoring improves code.&lt;/strong&gt; It does not fix architecture.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;The Phase Where Everything Felt Wrong&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;This was the stage where:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Features were tightly coupled&lt;/li&gt;
&lt;li&gt;Models were doing too much&lt;/li&gt;
&lt;li&gt;Business logic had leaked into places it didn’t belong&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The system worked, but it felt heavy, fragile, and hard to extend.&lt;/p&gt;

&lt;p&gt;So I did what most developers do when they sense disorder.&lt;/p&gt;

&lt;p&gt;I tried to clean it up.&lt;/p&gt;

&lt;p&gt;I renamed variables.&lt;br&gt;
Extracted methods.&lt;br&gt;
Reorganized folders.&lt;br&gt;
Split large functions into smaller ones.&lt;/p&gt;

&lt;p&gt;And yes — it looked better.&lt;/p&gt;

&lt;p&gt;But only on the surface.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;The Illusion of Progress&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;The code became more readable. Easier to navigate. Cleaner to look at.&lt;/p&gt;

&lt;p&gt;But beneath that:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The boundaries were still unclear

&lt;ul&gt;
&lt;li&gt;Responsibilities were still blurred&lt;/li&gt;
&lt;li&gt;The system still didn’t know what it wanted to be&lt;/li&gt;
&lt;li&gt;And the real test came when I started adding new features.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;/ul&gt;

&lt;p&gt;The mess returned.&lt;/p&gt;

&lt;p&gt;Not because I wrote bad code.&lt;br&gt;
But because the architecture was never designed for growth.&lt;/p&gt;

&lt;p&gt;I was repainting walls in a house with a cracked foundation.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;What Refactoring Actually Does&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Refactoring is valuable. It absolutely has its place.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Refactoring:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Improves readability&lt;/li&gt;
&lt;li&gt;Reduces duplication&lt;/li&gt;
&lt;li&gt;Simplifies functions
Makes code easier to understand
But architecture is something else entirely.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Architecture:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Defines boundaries&lt;/li&gt;
&lt;li&gt;Controls dependencies&lt;/li&gt;
&lt;li&gt;Separates responsibilities
Protects the system from entropy as it grows&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Refactoring cleans.&lt;br&gt;
Architecture contains.&lt;/p&gt;

&lt;p&gt;If the structure is wrong, no amount of cleaning will stop it from collapsing under new weight.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;The Real Problem I Hadn’t Faced&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;I hadn’t clearly defined:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;The core domain of the system&lt;/li&gt;
&lt;li&gt;The long-term goal of the application&lt;/li&gt;
&lt;li&gt;The separation between planning, tracking, and operations&lt;/li&gt;
&lt;li&gt;What belonged where — and what absolutely didn’t&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So every new feature bent the structure a little more.&lt;/p&gt;

&lt;p&gt;Until eventually, it snapped.&lt;/p&gt;

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

&lt;p&gt;Refactoring is not a substitute for architectural thinking.&lt;/p&gt;

&lt;p&gt;Before cleaning code, ask:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;What are the boundaries in this system?&lt;/li&gt;
&lt;li&gt;What responsibilities belong to each part?&lt;/li&gt;
&lt;li&gt;How will this design behave when the system doubles in size?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Because if the architecture isn’t prepared for growth, the mess will always come back.&lt;/p&gt;

&lt;p&gt;No matter how clean the code looks today.&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%2Fyyzjvao9mqexs435po31.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%2Fyyzjvao9mqexs435po31.jpg" alt=" " width="800" height="533"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>softwareengineering</category>
      <category>cleancode</category>
      <category>refactoring</category>
      <category>webdev</category>
    </item>
    <item>
      <title>[Boost]</title>
      <dc:creator>HILQIA KENDA</dc:creator>
      <pubDate>Thu, 12 Feb 2026 20:21:15 +0000</pubDate>
      <link>https://dev.to/hilqia_kenda/-4al5</link>
      <guid>https://dev.to/hilqia_kenda/-4al5</guid>
      <description>&lt;div class="ltag__link"&gt;
  &lt;a href="/hilqia_kenda" class="ltag__link__link"&gt;
    &lt;div class="ltag__link__pic"&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%2Fuser%2Fprofile_image%2F2473981%2Fe87e942a-b4ac-49c9-8536-cc2fccdf1269.jpg" alt="hilqia_kenda"&gt;
    &lt;/div&gt;
  &lt;/a&gt;
  &lt;a href="https://dev.to/hilqia_kenda/setting-up-the-server-for-a-real-time-chat-app-with-typescript-express-3653" class="ltag__link__link"&gt;
    &lt;div class="ltag__link__content"&gt;
      &lt;h2&gt;⚡ Setting Up the Server for a Real-Time Chat App with TypeScript &amp;amp; Express&lt;/h2&gt;
      &lt;h3&gt;HILQIA KENDA ・ Aug 23 '25&lt;/h3&gt;
      &lt;div class="ltag__link__taglist"&gt;
        &lt;span class="ltag__link__tag"&gt;#typescript&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#node&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#javascript&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#beginners&lt;/span&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/a&gt;
&lt;/div&gt;


</description>
      <category>typescript</category>
      <category>node</category>
      <category>javascript</category>
      <category>beginners</category>
    </item>
    <item>
      <title>🚀 Building a Fuel Route Optimization API with Django, Redis &amp; OpenRouteService</title>
      <dc:creator>HILQIA KENDA</dc:creator>
      <pubDate>Thu, 12 Feb 2026 19:45:00 +0000</pubDate>
      <link>https://dev.to/hilqia_kenda/building-a-fuel-route-optimization-api-with-django-redis-openrouteservice-409h</link>
      <guid>https://dev.to/hilqia_kenda/building-a-fuel-route-optimization-api-with-django-redis-openrouteservice-409h</guid>
      <description>&lt;p&gt;Last night, I challenged myself to solve a very practical problem:&lt;/p&gt;

&lt;p&gt;How do you find the cheapest fuel stops along a driving route between two cities?&lt;/p&gt;

&lt;p&gt;At first, it sounded simple.&lt;/p&gt;

&lt;p&gt;Until I opened the fuel station dataset and realized…&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;It had no coordinates. 😅&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;That’s when this turned from a simple API into a deep dive into:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Routing&lt;/li&gt;
&lt;li&gt;Geocoding&lt;/li&gt;
&lt;li&gt;Spatial matching&lt;/li&gt;
&lt;li&gt;Caching&lt;/li&gt;
&lt;li&gt;Performance engineering&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  🧠 The Core Idea
&lt;/h2&gt;

&lt;p&gt;Given:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Start Address → End Address as a string or list of coordinates&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;The system should:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Geocode both addresses using OpenRouteService&lt;/li&gt;
&lt;li&gt;Fetch the driving route polyline&lt;/li&gt;
&lt;li&gt;Build a route corridor using bounding boxes along the path&lt;/li&gt;
&lt;li&gt;Match fuel stations from a CSV dataset that fall inside this corridor&lt;/li&gt;
&lt;li&gt;Return the cheapest stations along the trip&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;No coordinates in the dataset? No problem. We make the map logic do the work.&lt;/p&gt;

&lt;h2&gt;
  
  
  ⚡ The Performance Problem
&lt;/h2&gt;

&lt;p&gt;Geocoding and routing APIs are expensive and slow.&lt;/p&gt;

&lt;p&gt;So I introduced &lt;strong&gt;Redis caching:&lt;/strong&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Addresses are geocoded once and cached forever&lt;/li&gt;
&lt;li&gt;Routes are cached&lt;/li&gt;
&lt;li&gt;Fuel stations are loaded into memory using Pandas&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;And here’s the fun part:&lt;/p&gt;

&lt;p&gt;❌ No database&lt;br&gt;
❌ No GIS server&lt;br&gt;
✅ Pure spatial computation in memory&lt;/p&gt;

&lt;p&gt;After the first request, response times drop to under 150ms.&lt;/p&gt;

&lt;h2&gt;
  
  
  🛠️ Stack Used
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Django + DRF&lt;/li&gt;
&lt;li&gt;Redis&lt;/li&gt;
&lt;li&gt;Pandas&lt;/li&gt;
&lt;li&gt;GeoPandas&lt;/li&gt;
&lt;li&gt;OpenRouteService API&lt;/li&gt;
&lt;li&gt;Spatial math (without PostGIS)&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  💡 Key Engineering Lessons
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Normalize messy data instead of bending your logic around it&lt;/li&gt;
&lt;li&gt;Cache aggressively when dealing with external APIs&lt;/li&gt;
&lt;li&gt;You don’t always need a database for spatial problems&lt;/li&gt;
&lt;li&gt;Bounding boxes + in-memory data can be incredibly fast&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This project genuinely felt like building a mini map engine from scratch.&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%2F4opsyewcpjethnhlbx4l.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F4opsyewcpjethnhlbx4l.png" alt=" " width="800" height="450"&gt;&lt;/a&gt;&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%2Fujh0tts6cutpjglk3onv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fujh0tts6cutpjglk3onv.png" alt=" " width="800" height="440"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
      <category>backenddevelopment</category>
      <category>developers</category>
      <category>django</category>
      <category>softwaredevelopment</category>
    </item>
    <item>
      <title>⚡ Setting Up the Server for a Real-Time Chat App with TypeScript &amp; Express</title>
      <dc:creator>HILQIA KENDA</dc:creator>
      <pubDate>Sat, 23 Aug 2025 05:30:00 +0000</pubDate>
      <link>https://dev.to/hilqia_kenda/setting-up-the-server-for-a-real-time-chat-app-with-typescript-express-3653</link>
      <guid>https://dev.to/hilqia_kenda/setting-up-the-server-for-a-real-time-chat-app-with-typescript-express-3653</guid>
      <description>&lt;p&gt;Real-time applications are everywhere today — from chat apps to trading dashboards. I recently started working on a real-time chat application, and the first step was setting up the server to handle secure, scalable communication.&lt;/p&gt;

&lt;p&gt;Here’s a walkthrough of the setup:&lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;🏗️ Project Structure&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;I’m building the app in TypeScript with Express. &lt;br&gt;
The backend structure looks like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight markdown"&gt;&lt;code&gt;backend/  
 └── src/  
     ├── features/  
     ├── shared/  
     ├── config.ts  
     ├── routes.ts  
     ├── setupDatabase.ts  
     └── setupServer.ts  
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  &lt;strong&gt;⚙️ The Server Setup(setupServer.ts)&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Here’s the core of the server class:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight typescript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;Application&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nx"&gt;json&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nx"&gt;urlencoded&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nx"&gt;Response&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nx"&gt;Request&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="nx"&gt;NextFunction&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;express&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;http&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;http&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;cors&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;cors&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;hpp&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;hpp&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;cookieSession&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;cookie-session&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;HTTP_STATUS&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;http-status-codes&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;express-async-errors&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;helmet&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;helmet&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="nx"&gt;compression&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;compression&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="k"&gt;export&lt;/span&gt; &lt;span class="kd"&gt;class&lt;/span&gt; &lt;span class="nc"&gt;ChattyServer&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;private&lt;/span&gt; &lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;Application&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

  &lt;span class="nf"&gt;constructor&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;Application&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;app&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="k"&gt;public&lt;/span&gt; &lt;span class="nf"&gt;start&lt;/span&gt;&lt;span class="p"&gt;():&lt;/span&gt; &lt;span class="k"&gt;void&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;securityMiddleware&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;standardMiddleware&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;routeMiddleware&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;globalErrorHandler&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;startServer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="k"&gt;private&lt;/span&gt; &lt;span class="nf"&gt;securityMiddleware&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;Application&lt;/span&gt;&lt;span class="p"&gt;):&lt;/span&gt; &lt;span class="k"&gt;void&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;use&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;cookieSession&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
      &lt;span class="na"&gt;name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;session&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;keys&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;key1&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;key2&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;],&lt;/span&gt;
      &lt;span class="na"&gt;maxAge&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;24&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;60&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;60&lt;/span&gt; &lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="mi"&gt;1000&lt;/span&gt;
    &lt;span class="p"&gt;}));&lt;/span&gt;
    &lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;use&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;hpp&lt;/span&gt;&lt;span class="p"&gt;());&lt;/span&gt;
    &lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;use&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;helmet&lt;/span&gt;&lt;span class="p"&gt;());&lt;/span&gt;
    &lt;span class="nx"&gt;app&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;use&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;cors&lt;/span&gt;&lt;span class="p"&gt;());&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  &lt;strong&gt;🔐 Security Middleware&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Real-time apps need robust security because of constant data exchange. I’ve added:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;cookie-session&lt;/strong&gt; → lightweight session handling&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;hpp&lt;/strong&gt; → protects against HTTP parameter pollution&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;helmet&lt;/strong&gt; → adds secure HTTP headers&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;cors&lt;/strong&gt; → enables cross-origin requests safely&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;📡 Next Steps&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;With the foundation in place, the next steps are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Integrating a database (setupDatabase.ts)&lt;/li&gt;
&lt;li&gt;Adding &lt;strong&gt;WebSocket&lt;/strong&gt; support for real-time messaging&lt;/li&gt;
&lt;li&gt;Implementing user authentication &amp;amp; chat channels&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  &lt;strong&gt;🚀 Takeaway&lt;/strong&gt;
&lt;/h3&gt;

&lt;p&gt;Setting up a server for a real-time chat app is more than just “getting Express running.” It’s about:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Structuring middleware for scalability&lt;/li&gt;
&lt;li&gt;Prioritizing security early&lt;/li&gt;
&lt;li&gt;Preparing for real-time event-driven communication&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I’ll share progress on WebSocket integration in the next part. Stay tuned!&lt;/p&gt;

</description>
      <category>typescript</category>
      <category>node</category>
      <category>javascript</category>
      <category>beginners</category>
    </item>
    <item>
      <title>🛠️ Setting Up Fusio as an API Gateway for CRM &amp; LLM Microservices</title>
      <dc:creator>HILQIA KENDA</dc:creator>
      <pubDate>Thu, 24 Jul 2025 22:10:24 +0000</pubDate>
      <link>https://dev.to/hilqia_kenda/setting-up-fusio-as-an-api-gateway-for-crm-llm-microservices-51l3</link>
      <guid>https://dev.to/hilqia_kenda/setting-up-fusio-as-an-api-gateway-for-crm-llm-microservices-51l3</guid>
      <description>&lt;p&gt;Over the past few days, I’ve been working on integrating an open-source API management layer using Fusio (v5.2.3) to centralize and secure communication between our CRM and LLM-based applications.&lt;/p&gt;

&lt;h2&gt;
  
  
  🔍 Why Fusio?
&lt;/h2&gt;

&lt;p&gt;Fusio provides a lightweight, flexible API gateway and management system with:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Visual interface for API operations&lt;/li&gt;
&lt;li&gt;Built-in support for OAuth2, rate limiting, and request logging&lt;/li&gt;
&lt;li&gt;Schema-driven API design&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Real-time analytics &amp;amp; monitoring dashboards&lt;br&gt;
It’s a great fit for internal service coordination, especially when you're running microservices for systems like:&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Customer Relationship Management (CRM)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Large Language Model (LLM) integration APIs&lt;/p&gt;
&lt;h2&gt;
  
  
  ⚙️ What I Set Up
&lt;/h2&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;🚀 API Gateway Layer between multiple services (CRM-Core, CRM-MatchMaker, LLM engine)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;🧩 Defined operations, actions, and routes inside Fusio to handle each microservice endpoint&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;🔐 Centralized access control and token handling&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;📈 Enabled real-time metrics for test coverage, error rate, usage per operation, and latency&lt;/p&gt;&lt;/li&gt;
&lt;/ul&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%2Fe8ph0x495d7bz128b9dt.jpeg" 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%2Fe8ph0x495d7bz128b9dt.jpeg" alt="during demo api gateway" width="800" height="465"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  🧪 Testing &amp;amp; Challenges
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;✅ Successfully simulated and monitored traffic between internal endpoints&lt;/li&gt;
&lt;li&gt;🐛 Faced and fixed a persistent MySQL connection issue while spinning up the Fusio container (lesson: always verify DB port exposure + credentials in .env)&lt;/li&gt;
&lt;li&gt;🔄 Used docker-compose to manage isolated services, with volume resets during setup retries
&lt;/li&gt;
&lt;/ul&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;
&lt;span class="c"&gt;# Used this command combo to reset and re-run the setup&lt;/span&gt;
docker-compose down &lt;span class="nt"&gt;-v&lt;/span&gt;
&lt;span class="nb"&gt;sudo rm&lt;/span&gt; &lt;span class="nt"&gt;-rf&lt;/span&gt; ./db
docker-compose up &lt;span class="nt"&gt;-d&lt;/span&gt;

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  ✅ What’s Next
&lt;/h2&gt;

&lt;p&gt;Finalizing integration with the production application layer&lt;br&gt;
Setting up WebSocket event streaming for real-time updates&lt;br&gt;
Deploying Fusio on a cloud server for internal + external access&lt;/p&gt;

&lt;h3&gt;
  
  
  💡 Final Thoughts
&lt;/h3&gt;

&lt;p&gt;Fusio is a powerful open-source tool that gives devs full control over API lifecycle management — without depending on heavy SaaS solutions. For internal microservice architectures, especially with real-time and AI-driven logic like CRM + LLM, it’s proving to be a great fit.&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%2Fsdipf6ygtkyp4yvt7yg6.jpeg" 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%2Fsdipf6ygtkyp4yvt7yg6.jpeg" alt="running internal test within Fusio" width="800" height="456"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  🧵 Stay tuned
&lt;/h3&gt;

&lt;p&gt;next post will cover production deployment and runtime performance benchmarks.&lt;/p&gt;

&lt;h2&gt;
  
  
  Tags:
&lt;/h2&gt;

&lt;h4&gt;
  
  
  &lt;a class="mentioned-user" href="https://dev.to/backend"&gt;@backend&lt;/a&gt; @api @microservices @opensource &lt;a class="mentioned-user" href="https://dev.to/devops"&gt;@devops&lt;/a&gt; &lt;a class="mentioned-user" href="https://dev.to/crm"&gt;@crm&lt;/a&gt; &lt;a class="mentioned-user" href="https://dev.to/llm"&gt;@llm&lt;/a&gt; @fusio &lt;a class="mentioned-user" href="https://dev.to/pytutorial"&gt;@pytutorial&lt;/a&gt;  @docker
&lt;/h4&gt;

</description>
      <category>python</category>
      <category>crm</category>
      <category>llm</category>
      <category>opensource</category>
    </item>
    <item>
      <title>Why the Single Responsibility in Software Development?</title>
      <dc:creator>HILQIA KENDA</dc:creator>
      <pubDate>Fri, 24 Jan 2025 14:17:12 +0000</pubDate>
      <link>https://dev.to/hilqia_kenda/why-the-single-responsibility-in-software-development-2l61</link>
      <guid>https://dev.to/hilqia_kenda/why-the-single-responsibility-in-software-development-2l61</guid>
      <description>&lt;p&gt;Why use a single responsibility in software development?&lt;/p&gt;

&lt;p&gt;A single responsibility into the application, resulte to a clean and well-organized architecture by breaking down an application into different layers, we can easily manage and maintain our code.&lt;br&gt;
Single responsibility reduce the duplication as well and improve scalability of the application. &lt;/p&gt;

&lt;p&gt;This is some few benefits and the beauty of single responsibility into an application.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>beginners</category>
      <category>programming</category>
      <category>python</category>
    </item>
    <item>
      <title>The This Keyword</title>
      <dc:creator>HILQIA KENDA</dc:creator>
      <pubDate>Tue, 14 Jan 2025 21:48:59 +0000</pubDate>
      <link>https://dev.to/hilqia_kenda/the-this-keyword-4ob4</link>
      <guid>https://dev.to/hilqia_kenda/the-this-keyword-4ob4</guid>
      <description>&lt;p&gt;**Im a going to give a closer look to one of the features that confuses many developers in JavaScript; the This Keyword. Mostly that is because of the poor explanation or teaching materials about the this keyword. I personally I was really confused about this keyword and it was not easy to understand how it works, until I found these 2 rules to understand it easily; these are execution with: 1) A Method or function within an object and 2) with Regular function.&lt;/p&gt;

&lt;p&gt;Frist of all What is the this keyword? This refences the object that is executing the current function. &lt;br&gt;
If a function is a method in object, this references object itself. E.g.&lt;br&gt;
// method -&amp;gt; obj&lt;/p&gt;

&lt;p&gt;If the function is a regular function (which is not in object) this references the global object. E.g.&lt;br&gt;
// function -&amp;gt; global (in browser: windows, in Node: global)&lt;/p&gt;

&lt;p&gt;1st Rule within an Object&lt;br&gt;
Let take an example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const vehicle = {
  brand: "Toyota",
  productionDate: "2020-04-05",
  start() {
    console.log(this);
  },
};

vehicle.start();
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Because start is a method in the vehicle object, we will get the vehicle object in the console.&lt;br&gt;
 Here is the output:&lt;br&gt;
// {brand: 'Toyota', productionDate: '2020-04-05', start: ƒ start()}&lt;/p&gt;

&lt;p&gt;If we add a stop method as follow:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const vehicle = {
  brand: "Toyota",
  productionDate: "2020-04-05",
  start() {
    console.log(this);
  },
};

vehicle.stop = function (){
    console.log(this)
}

vehicle.stop();
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;the output in the console is still the same, because stop is a method or a function in the object.&lt;/p&gt;

&lt;p&gt;2nd Rule is with a regular function.&lt;br&gt;
Let take an example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function startVehicle() {
  console.log(this);
}
startVehicle();
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;if this function is long to the console, we are going to get a window object in browser and global in Node.&lt;br&gt;
However, if we use a constructor function with the new operator the output will be different, let see a similar example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function StartVehicle(brand) {
  this.brand = brand;
  console.log(this);
}

const start = new StartVehicle("BMW");
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;With this the output is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// StartVehicle {brand: 'BMW'}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This time we are getting a new object here. By the way note that this object is a completely different object, it is not the StartVehicle object.&lt;br&gt;
When you use the “new” operator it returns an empty object “{}”and then set this keyword to point the new object, that is ho we get the new object returned.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// new -&amp;gt; {} and then this point to the new object
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here is the take away, when dealing with a object this reference to the object itself.&lt;br&gt;
However, when dealing with the regular function this by the default reference to the global object. But if you call a function using the new operator the case in our early constructor’s function example, this will reference a new empty object create by the new operator.&lt;/p&gt;

&lt;p&gt;I am going to give a closer look to one of the features that confuses many developers in JavaScript; the This Keyword. Mostly that is because of the poor explanation or teaching materials about the this keyword. I personally I was really confused about this keyword and it was not easy to understand how it works, until I found these 2 rules to understand it easily; these are execution with: 1) A Method or function within an object and 2) with Regular function.&lt;/p&gt;

&lt;p&gt;Frist of all What is the this keyword? This refences the object that is executing the current function. &lt;br&gt;
If a function is a method in object, this references object itself. E.g.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// method -&amp;gt; obj
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If the function is a regular function (which is not in object) this references the global object. E.g.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// function -&amp;gt; global (in browser: windows, in Node: global)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;1st Rule within an Object&lt;br&gt;
Let take an example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const vehicle = {
  brand: "Toyota",
  productionDate: "2020-04-05",
  start() {
    console.log(this);
  },
};

vehicle.start();
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Because start is a method in the vehicle object, we will get the vehicle object in the console.&lt;br&gt;
 Here is the output:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// {brand: 'Toyota', productionDate: '2020-04-05', start: ƒ start()}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If we add a stop method as follow:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const vehicle = {
  brand: "Toyota",
  productionDate: "2020-04-05",
  start() {
    console.log(this);
  },
};

vehicle.stop = function (){
    console.log(this)
}

vehicle.stop();
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;the output in the console is still the same, because stop is a method or a function in the object.&lt;/p&gt;

&lt;p&gt;2nd Rule is with a regular function.&lt;br&gt;
Let take an example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function startVehicle() {
  console.log(this);
}
startVehicle();
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;if this function is long to the console, we are going to get a window object in browser and global in Node.&lt;br&gt;
However, if we use a constructor function with the new operator the output will be different, let see a similar example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function StartVehicle(brand) {
  this.brand = brand;
  console.log(this);
}

const start = new StartVehicle("BMW");
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;With this the output is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// StartVehicle {brand: 'BMW'}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This time we are getting a new object here. By the way note that this object is a completely different object, it is not the StartVehicle object.&lt;br&gt;
When you use the “new” operator it returns an empty object “{}”and then set this keyword to point the new object, that is ho we get the new object returned.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;// new -&amp;gt; {} and then this point to the new object
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here is the take away, when dealing with a object this reference to the object itself.&lt;br&gt;
However, when dealing with the regular function this by the default reference to the global object. But if you call a function using the new operator the case in our early constructor’s function example, this will reference a new empty object create by the new operator.&lt;/p&gt;

&lt;p&gt;**&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>react</category>
      <category>programming</category>
    </item>
  </channel>
</rss>
