<?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: Priyanka-Chettri</title>
    <description>The latest articles on DEV Community by Priyanka-Chettri (@priyankaa).</description>
    <link>https://dev.to/priyankaa</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.us-east-2.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F1412856%2F956fa6ee-5d64-428a-9639-c845f1288f7f.png</url>
      <title>DEV Community: Priyanka-Chettri</title>
      <link>https://dev.to/priyankaa</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/priyankaa"/>
    <language>en</language>
    <item>
      <title>Before I Built with AI, I Wanted to Understand What Was Underneath</title>
      <dc:creator>Priyanka-Chettri</dc:creator>
      <pubDate>Sun, 09 Aug 2026 13:58:48 +0000</pubDate>
      <link>https://dev.to/priyankaa/before-i-built-with-ai-i-wanted-to-understand-what-was-underneath-3a64</link>
      <guid>https://dev.to/priyankaa/before-i-built-with-ai-i-wanted-to-understand-what-was-underneath-3a64</guid>
      <description>&lt;p&gt;As I started learning Applied AI, I realized I didn't want to jump straight into LLM APIs, RAG, agents, and prompting without understanding what was underneath.&lt;/p&gt;

&lt;p&gt;So I went back to the basics.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;From Machine Learning to Deep Learning&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Traditional machine learning often relied on humans to decide which features were important.&lt;/p&gt;

&lt;p&gt;For example, for digit recognition, we might manually identify:&lt;/p&gt;

&lt;p&gt;edges&lt;br&gt;
curves&lt;br&gt;
strokes&lt;br&gt;
shapes&lt;/p&gt;

&lt;p&gt;Neural networks changed this approach.&lt;/p&gt;

&lt;p&gt;Instead of manually defining all the features, a neural network can learn useful representations from the data.&lt;/p&gt;

&lt;p&gt;A simple network looks like:&lt;/p&gt;

&lt;p&gt;Input → Hidden Layers → Output&lt;/p&gt;

&lt;p&gt;Each neuron uses weights and biases, and during training the model adjusts these parameters to reduce its error.&lt;/p&gt;

&lt;p&gt;The &lt;em&gt;cost function&lt;/em&gt; tells us how wrong the prediction is.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Backpropagation&lt;/em&gt; helps determine how each parameter contributed to that error, and gradient descent updates the parameters in a direction that reduces the cost.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Why Deep Learning?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;When we stack many layers, we get deep neural networks.&lt;/p&gt;

&lt;p&gt;The interesting part is that different layers can learn increasingly complex representations:&lt;/p&gt;

&lt;p&gt;Pixels → Edges → Shapes → Parts → Object&lt;/p&gt;

&lt;p&gt;This ability to automatically learn representations from raw data became one of the major strengths of deep learning.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;From Deep Learning to Generative AI&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A neural network doesn't have to be supervised. It can be trained using supervised, unsupervised, self-supervised, or reinforcement learning.&lt;/p&gt;

&lt;p&gt;Modern AI heavily relies on self-supervised learning.&lt;/p&gt;

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

&lt;p&gt;"The capital of France is ___"&lt;/p&gt;

&lt;p&gt;Target → Paris&lt;/p&gt;

&lt;p&gt;The text itself provides the training target. This makes it possible to learn from enormous amounts of data without manually labeling everything.&lt;/p&gt;

&lt;p&gt;Then came &lt;em&gt;Transformers&lt;/em&gt;, which introduced the idea of attention—allowing models to learn relationships between different parts of a sequence efficiently.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Large Transformers&lt;/em&gt; trained on massive datasets became foundation models.&lt;/p&gt;

&lt;p&gt;When these models are trained to work with language at enormous scale, we get &lt;em&gt;Large Language Models&lt;/em&gt; (LLMs).&lt;/p&gt;

&lt;p&gt;And when models can use what they've learned to generate new text, code, images, audio, or video, we call it Generative AI.&lt;/p&gt;

&lt;p&gt;The Mental Model&lt;/p&gt;

&lt;p&gt;This isn't a perfectly linear hierarchy, but this is the mental map that helped me:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Machine Learning&lt;br&gt;
      ↓&lt;br&gt;
Neural Networks&lt;br&gt;
      ↓&lt;br&gt;
Deep Learning&lt;br&gt;
      ↓&lt;br&gt;
Transformers&lt;br&gt;
      ↓&lt;br&gt;
Self-Supervised Learning&lt;br&gt;
      ↓&lt;br&gt;
Foundation Models&lt;br&gt;
      ↓&lt;br&gt;
LLMs&lt;br&gt;
      ↓&lt;br&gt;
Generative AI&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The goal isn't to become an ML researcher before becoming an Applied AI Engineer.&lt;/p&gt;

&lt;p&gt;For me, the goal is simpler:&lt;/p&gt;

&lt;p&gt;Understand what problem each concept solved, so that when I build on top of AI models, I know what I'm actually building on.&lt;/p&gt;

&lt;p&gt;That's the foundation I'm starting my Applied AI journey with.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>The React Pattern That Changed How I Build Reusable Components</title>
      <dc:creator>Priyanka-Chettri</dc:creator>
      <pubDate>Thu, 09 Oct 2025 10:33:07 +0000</pubDate>
      <link>https://dev.to/priyankaa/the-react-pattern-that-changed-how-i-build-reusable-components-k2o</link>
      <guid>https://dev.to/priyankaa/the-react-pattern-that-changed-how-i-build-reusable-components-k2o</guid>
      <description>&lt;p&gt;While building components for a design system, I initially followed an existing pattern that was already in place- they all had a consistent pattern. I didn’t know what it was called, but I loved how scalable and flexible it felt.&lt;/p&gt;

&lt;p&gt;Later, I realized… this approach had a name — &lt;strong&gt;the Compound Component Pattern&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Let me explain with a simple example 👇&lt;/p&gt;

&lt;p&gt;Imagine we have a Flyout Button that, when clicked, opens a menu with a list.&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%2Fw9l94eb7z92gvmti85oo.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%2Fw9l94eb7z92gvmti85oo.png" alt="Flyout with menu" width="800" height="533"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now, in a typical setup, if we want the Flyout to appear over a specific component, we’d probably pass a prop like toggle from the parent and control it there.&lt;br&gt;
That works — but what if we want to use this Flyout anywhere in the app, with any icon, and in multiple combinations?&lt;/p&gt;

&lt;p&gt;That’s where the Compound Pattern comes into play.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;🧩 How to Identify When to Use It&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;If there’s a shared state between two or more components, that shared state lives in the parent component&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;You want flexibility and reusability without passing props down multiple levels&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;You’d rather use React Context to manage state than prop drilling&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Then you’re probably looking at a perfect use case for the &lt;strong&gt;Compound Design Pattern.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;A component with compound pattern in action looks like this&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;Flyout&amp;gt;
  &amp;lt;Flyout.Toggle&amp;gt;
    &amp;lt;Icon name="more" /&amp;gt;
  &amp;lt;/Flyout.Toggle&amp;gt;
  &amp;lt;Flyout.Menu&amp;gt;
    &amp;lt;Flyout.Item&amp;gt;Profile&amp;lt;/Flyout.Item&amp;gt;
    &amp;lt;Flyout.Item&amp;gt;Settings&amp;lt;/Flyout.Item&amp;gt;
    &amp;lt;Flyout.Item&amp;gt;Logout&amp;lt;/Flyout.Item&amp;gt;
  &amp;lt;/Flyout.Menu&amp;gt;
&amp;lt;/Flyout&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here, each sub-component (&lt;em&gt;Toggle, Menu, Item&lt;/em&gt;) communicates through a shared context, not props.&lt;br&gt;
This makes the component incredibly reusable, readable, and extensible — a win for design systems.&lt;/p&gt;

&lt;p&gt;This pattern truly changed how I think about building components in React.&lt;br&gt;
Once you start using the Compound Pattern, you realize it’s not just about cleaner code — it’s about creating a language for your UI.&lt;/p&gt;

</description>
      <category>react</category>
      <category>javascript</category>
      <category>designpatterns</category>
      <category>ui</category>
    </item>
    <item>
      <title>𝐖𝐡𝐚𝐭 𝐛𝐮𝐢𝐥𝐝𝐢𝐧𝐠 𝐚 𝐬𝐢𝐦𝐩𝐥𝐞 𝐓𝐨-𝐃𝐨 𝐥𝐢𝐬𝐭 𝐢𝐧 𝐑𝐞𝐚𝐜𝐭 𝐜𝐚𝐧 𝐭𝐞𝐚𝐜𝐡 𝐲𝐨𝐮 𝐚𝐬 𝐚 𝐁𝐞𝐠𝐢𝐧𝐧𝐞𝐫🎯</title>
      <dc:creator>Priyanka-Chettri</dc:creator>
      <pubDate>Sun, 29 Sep 2024 10:03:50 +0000</pubDate>
      <link>https://dev.to/priyankaa/--cj6</link>
      <guid>https://dev.to/priyankaa/--cj6</guid>
      <description>&lt;p&gt;Creating a to-do in React appears simple. However, as you introduce add on features, it opens a whole new door to explore and understand concepts. Here's how this project can enhance your understanding.&lt;/p&gt;

&lt;p&gt;✅ 𝐂𝐨𝐦𝐩𝐨𝐧𝐞𝐧𝐭 𝐒𝐭𝐫𝐮𝐜𝐭𝐮𝐫𝐞: Break tasks into manageable chunks with reusable components.&lt;br&gt;
 ✅ 𝐏𝐫𝐨𝐩𝐬 &amp;amp; 𝐃𝐚𝐭𝐚 𝐅𝐥𝐨𝐰: Pass data seamlessly between parent and child components.&lt;br&gt;
 ✅ 𝐂𝐨𝐧𝐝𝐢𝐭𝐢𝐨𝐧𝐚𝐥 𝐑𝐞𝐧𝐝𝐞𝐫𝐢𝐧𝐠: Show or render components based on a condition ( example of to do: If the edit mode is on then place an input field).&lt;br&gt;
 ✅ 𝐄𝐯𝐞𝐧𝐭 𝐇𝐚𝐧𝐝𝐥𝐢𝐧𝐠 : Understand how to handle clicks, typing, and more. On delete button click how can you delete the to-do?&lt;br&gt;
 ✅ 𝐑𝐞𝐚𝐜𝐭 𝐡𝐨𝐨𝐤𝐬: Understand when to use useState and useEffect.&lt;/p&gt;

&lt;p&gt;Once you've built a basic to-do application, it's time to level up by adding features that make your app more robust and user-friendly.&lt;/p&gt;

&lt;p&gt;✅ 𝐈𝐦𝐩𝐥𝐞𝐦𝐞𝐧𝐭 𝐋𝐨𝐜𝐚𝐥 𝐒𝐭𝐨𝐫𝐚𝐠𝐞: With every change in the to-dos store the input into a local storage. Use useEffect to update the local storage.&lt;br&gt;
 ✅ 𝐈𝐦𝐩𝐫𝐨𝐯𝐞 𝐒𝐭𝐚𝐭𝐞 𝐌𝐚𝐧𝐚𝐠𝐞𝐦𝐞𝐧𝐭 𝐰𝐢𝐭𝐡 𝐂𝐨𝐧𝐭𝐞𝐱𝐭 𝐀𝐏𝐈: To avoid prop drilling if any and manage state more effectively, implement the React Context API. Understanding Context API solidifies your base.&lt;br&gt;
 ✅ 𝐎𝐩𝐭𝐢𝐦𝐢𝐬𝐞 𝐰𝐢𝐭𝐡 𝐑𝐞𝐚𝐜𝐭 𝐒𝐭𝐚𝐭𝐞 𝐌𝐚𝐧𝐚𝐠𝐞𝐦𝐞𝐧𝐭 𝐋𝐢𝐛𝐫𝐚𝐫𝐢𝐞𝐬: As your application grows, you might notice unnecessary re-renders, especially when working with multiple components and features. Libraries like Recoil, Redux, or Zustand can help manage state efficiently and prevent re-renders.&lt;/p&gt;

&lt;p&gt;By adding these features, you're not only enhancing functionality but also learning critical concepts like local storage, context-based state management, and optimising rendering behaviour, which are essential for building scalable React applications.&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%2Fmnzhzfj3tkqfxl2010ea.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%2Fmnzhzfj3tkqfxl2010ea.png" alt="A snapshot of the to do list app" width="800" height="410"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Accent Colors for Checkboxes and Radios</title>
      <dc:creator>Priyanka-Chettri</dc:creator>
      <pubDate>Wed, 05 Jun 2024 12:17:05 +0000</pubDate>
      <link>https://dev.to/priyankaa/accent-colors-for-checkboxes-and-radios-5jb</link>
      <guid>https://dev.to/priyankaa/accent-colors-for-checkboxes-and-radios-5jb</guid>
      <description>&lt;p&gt;Utilize &lt;strong&gt;accent-&lt;/strong&gt;* utilities to modify the accent color of elements, ideal for customizing the appearance of &lt;strong&gt;&lt;em&gt;checkboxes&lt;/em&gt;&lt;/strong&gt; and &lt;strong&gt;&lt;em&gt;radio buttons&lt;/em&gt;&lt;/strong&gt; by replacing the browser's default color.&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%2F6o9ahim44xl2w93z0t13.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%2F6o9ahim44xl2w93z0t13.png" alt="Cover" width="800" height="819"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here, I have given accent color accent-pink-500, you can customize the color according to your need.This comes handy if you want to customize the look of your check boxes and radio buttons according to your theme.&lt;/p&gt;

&lt;p&gt;The code for it is given below:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;div class="mx-auto my-auto border h-[100px] w-[300px] rounded-md flex justify-center items-center gap-4 shadow-lg"&amp;gt;
&amp;lt;label class="font-semibold font-serif"&amp;gt;Accent Color&amp;lt;/label&amp;gt;
&amp;lt;input type="checkbox" class="accent-pink-500 " id="checkbox" &amp;gt;
&amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Thanks for reading!&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Unveiling the Magic of hover, focus and active variants in Tailwind CSS.</title>
      <dc:creator>Priyanka-Chettri</dc:creator>
      <pubDate>Tue, 28 May 2024 07:43:15 +0000</pubDate>
      <link>https://dev.to/priyankaa/unveiling-the-magic-of-hover-focus-and-active-variants-in-tailwind-css-54pg</link>
      <guid>https://dev.to/priyankaa/unveiling-the-magic-of-hover-focus-and-active-variants-in-tailwind-css-54pg</guid>
      <description>&lt;p&gt;💡𝐏𝐫𝐨 𝐓𝐢𝐩: Make your UI elements pop with Tailwind CSS! Use 𝐡𝐨𝐯𝐞𝐫, 𝐟𝐨𝐜𝐮𝐬, and 𝐚𝐜𝐭𝐢𝐯𝐞 variants to enhance user experience and engagement. Your designs will thank you!&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%2F120ip3lm0tdb6f5ay1cb.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%2F120ip3lm0tdb6f5ay1cb.png" alt="Cover Page" width="800" height="819"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Dive into this demo to see them in action!&lt;br&gt;
 Ready to give it a try? Check out the code below and start &lt;br&gt;
 experimenting! 👇&lt;/p&gt;

&lt;p&gt;  &lt;iframe src="https://www.youtube.com/embed/-NeBA9blo4o"&gt;
  &lt;/iframe&gt;
&lt;/p&gt;

&lt;p&gt;➡️ Snippet of "hover" variant applied to a button.&lt;br&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%2F4id33vf2k2eqxhk9sr2z.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%2F4id33vf2k2eqxhk9sr2z.png" alt="Hover Code" width="800" height="691"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;➡️ Snippet of a "focus" variant applied to a button&lt;br&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%2F81xldmxajk6xjuizqloc.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%2F81xldmxajk6xjuizqloc.png" alt="Focus Code" width="800" height="691"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;➡️ Snippet of an "active" variant applied to a button&lt;br&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%2Fhrkqx3e0ahxx89j9zs9a.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%2Fhrkqx3e0ahxx89j9zs9a.png" alt="Active Code" width="800" height="618"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Overcoming Tight Coupling In OOPs With Effective Solutions</title>
      <dc:creator>Priyanka-Chettri</dc:creator>
      <pubDate>Mon, 08 Apr 2024 20:14:28 +0000</pubDate>
      <link>https://dev.to/priyankaa/overcoming-tight-coupling-in-oops-with-effective-solutions-3d3g</link>
      <guid>https://dev.to/priyankaa/overcoming-tight-coupling-in-oops-with-effective-solutions-3d3g</guid>
      <description>&lt;p&gt;Familiar with "&lt;strong&gt;tight coupling&lt;/strong&gt;" in OOPs? It's a common issue where classes become overly interdependent, making code changes cumbersome and error-prone. Imagine updating one class and having to revise multiple others due to tight dependencies. &lt;/p&gt;

&lt;p&gt;This is how a tightly coupled code looks like:&lt;/p&gt;

&lt;p&gt;Here, the direct instantiation of &lt;strong&gt;Engine&lt;/strong&gt; class within the constructor of &lt;strong&gt;Car&lt;/strong&gt; class creates a strong dependency between the two classes.&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%2F3wpv8cjwwc020qgwv9z4.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%2F3wpv8cjwwc020qgwv9z4.png" alt="Tight coupled code" width="800" height="713"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The problem encountered in the above code can be solved using &lt;strong&gt;Dependency injection&lt;/strong&gt; in Spring and by promoting the use of &lt;strong&gt;Interfaces&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;METHOD 1: Dependency injection using constructor injection&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Problem&lt;/strong&gt; ❌: Tight coupling occurs when one class directly instantiates another class, using the “&lt;strong&gt;new&lt;/strong&gt;” keyword&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Solution&lt;/strong&gt; 💡: Use Dependency injection to pass dependency from external sources, highly used in Spring . In the below figure the engine object is being passed as the parameter to the constructor from an external source.&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%2Fsaltogymi79118k8w8xl.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%2Fsaltogymi79118k8w8xl.png" alt="Solving tight coupling using dependency injection" width="800" height="798"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;METHOD 2: Using interfaces&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Problem&lt;/strong&gt; ❌: Classes depending on  concrete implements rather than interfaces, causes tightly coupled relationship between them. To say,  if the type of engine to be used by a car is changed the whole code has to be re written again.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Solution&lt;/strong&gt; 💡: Use interfaces instead of using concrete classes, this gives more flexibility to a code.&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%2Fqeb56njnfmotzkxh1wrz.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%2Fqeb56njnfmotzkxh1wrz.png" alt="Solving tight coupling using Interface" width="800" height="913"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Follow &lt;a href="https://dev.to/priyankachettri"&gt;Me&lt;/a&gt; for such contents!&lt;br&gt;
Happy Learning :)&lt;/p&gt;

</description>
      <category>springboot</category>
      <category>spring</category>
      <category>java</category>
      <category>oops</category>
    </item>
  </channel>
</rss>
