<?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: Shirin Monzavi</title>
    <description>The latest articles on DEV Community by Shirin Monzavi (@shirin_monzavi_f3d63ff99d).</description>
    <link>https://dev.to/shirin_monzavi_f3d63ff99d</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%2F3022842%2F2191dabc-2f8e-4c21-8019-1352e3727646.jpg</url>
      <title>DEV Community: Shirin Monzavi</title>
      <link>https://dev.to/shirin_monzavi_f3d63ff99d</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/shirin_monzavi_f3d63ff99d"/>
    <language>en</language>
    <item>
      <title>𝐂𝐨𝐮𝐧𝐭 𝐕𝐬 𝐂𝐨𝐮𝐧𝐭() 𝐢𝐧 𝐂# 𝐋𝐢𝐬𝐭&lt;𝐓&gt;?</title>
      <dc:creator>Shirin Monzavi</dc:creator>
      <pubDate>Thu, 20 Nov 2025 08:28:07 +0000</pubDate>
      <link>https://dev.to/shirin_monzavi_f3d63ff99d/--4c8k</link>
      <guid>https://dev.to/shirin_monzavi_f3d63ff99d/--4c8k</guid>
      <description>&lt;p&gt;𝐖𝐡𝐚𝐭 𝐢𝐬 𝐂𝐨𝐮𝐧𝐭 𝐢𝐧 𝐋𝐢𝐬𝐭&amp;lt;𝐓&amp;gt;?&lt;br&gt;
Count is a property of many collections in .Net and its value represents the number of elements in the collection. Its time complexity is O(1).&lt;/p&gt;

&lt;p&gt;𝐖𝐡𝐚𝐭 𝐢𝐬 𝐂𝐨𝐮𝐧𝐭() 𝐢𝐧 𝐋𝐢𝐬𝐭&amp;lt;𝐓&amp;gt;?&lt;br&gt;
Count() is LINQ extension method for counting elements of a List. &lt;br&gt;
At first, LINQ checks the type, if it is type of collection, it uses the count property. Otherwise, it iterates through all elements to count them. Its time complexity is O(n).&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%2Fr10z0yiwmia3nmi7d86z.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%2Fr10z0yiwmia3nmi7d86z.jpg" alt=" " width="800" height="1000"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;💯𝐃𝐨 𝐰𝐞 𝐫𝐞𝐚𝐥𝐥𝐲 𝐜𝐚𝐫𝐞 𝐭𝐡𝐞 𝐝𝐢𝐟𝐟𝐞𝐫𝐞𝐧𝐜𝐞?&lt;br&gt;
Yes! For large datasets, it’s better to use the Count property instead of the Count() method whenever possible, because Count() still has the overhead of checking the type and calling the property.&lt;/p&gt;

&lt;p&gt;❓ 𝐇𝐚𝐯𝐞 𝐲𝐨𝐮 𝐞𝐯𝐞𝐫 𝐟𝐚𝐜𝐞𝐝 𝐰𝐢𝐭𝐡 𝐬𝐮𝐜𝐡 𝐩𝐞𝐫𝐟𝐨𝐫𝐦𝐚𝐧𝐜𝐞 𝐢𝐬𝐬𝐮𝐞? 𝐒𝐡𝐚𝐫𝐞 𝐲𝐨𝐮𝐫 𝐞𝐱𝐩𝐞𝐫𝐢𝐞𝐧𝐜𝐞.&lt;/p&gt;

</description>
      <category>count</category>
    </item>
    <item>
      <title>🚀 𝐒𝐭𝐨𝐩 𝐫𝐞𝐩𝐞𝐚𝐭𝐢𝐧𝐠 @𝐦𝐞𝐝𝐢𝐚 𝐬𝐜𝐫𝐞𝐞𝐧! 𝐔𝐬𝐞 𝐒𝐚𝐬𝐬 𝐌𝐢𝐱𝐢𝐧𝐬 𝐭𝐨 𝐦𝐚𝐤𝐞 𝐲𝐨𝐮𝐫 𝐫𝐞𝐬𝐩𝐨𝐧𝐬𝐢𝐯𝐞 𝐂𝐒𝐒 𝐜𝐥𝐞𝐚𝐧𝐞𝐫 𝐚𝐧𝐝 𝐬𝐦𝐚𝐫𝐭𝐞𝐫.</title>
      <dc:creator>Shirin Monzavi</dc:creator>
      <pubDate>Sat, 15 Nov 2025 04:41:26 +0000</pubDate>
      <link>https://dev.to/shirin_monzavi_f3d63ff99d/--510j</link>
      <guid>https://dev.to/shirin_monzavi_f3d63ff99d/--510j</guid>
      <description>&lt;p&gt;𝐏𝐫𝐨𝐛𝐥𝐞𝐦?&lt;br&gt;
Assume, you are styling a responsive web application. When styling for different screen sizes, you often need to write multiple &lt;a class="mentioned-user" href="https://dev.to/media"&gt;@media&lt;/a&gt; queries. This can lead to repeating &lt;a class="mentioned-user" href="https://dev.to/media"&gt;@media&lt;/a&gt; statements throughout your CSS file. How can we avoid it?&lt;/p&gt;

&lt;p&gt;𝐒𝐨𝐥𝐮𝐭𝐢𝐨𝐧?&lt;br&gt;
Sass solves this problem by Mixin. Mixins allow you to define styles that can be re-used throughout your stylesheet.&lt;/p&gt;

&lt;p&gt;𝐇𝐨𝐰?&lt;br&gt;
💠 Install Sass → npm install sass.&lt;/p&gt;

&lt;p&gt;💠Define a mixing named it screen-style with the argument of size screen and in the body use &lt;a class="mentioned-user" href="https://dev.to/content"&gt;@content&lt;/a&gt; (take an entire block of styles).&lt;/p&gt;

&lt;p&gt;💠Define a new mixin named it small-breakpoint and use name of previous mixin with &lt;a class="mentioned-user" href="https://dev.to/include"&gt;@include&lt;/a&gt; (it will be included in the previous mixin).&lt;/p&gt;

&lt;p&gt;💠Define the desired selector.&lt;/p&gt;

&lt;p&gt;💠Use the small-breakpoint mixin with &lt;a class="mentioned-user" href="https://dev.to/include"&gt;@include&lt;/a&gt; inside the selector.&lt;/p&gt;

&lt;p&gt;💠Add the desired styles.&lt;/p&gt;

&lt;p&gt;❓ 𝐇𝐚𝐯𝐞 𝐲𝐨𝐮 𝐞𝐯𝐞𝐫 𝐮𝐬𝐞 𝐌𝐢𝐱𝐢𝐧𝐬? 𝐈𝐟 𝐬𝐨, 𝐒𝐡𝐚𝐫𝐞 𝐲𝐨𝐮𝐫 𝐞𝐱𝐩𝐞𝐫𝐢𝐞𝐧𝐜𝐞 𝐢𝐧 𝐭𝐡𝐞 𝐜𝐨𝐦𝐦𝐞𝐧𝐭.&lt;/p&gt;

&lt;p&gt;hashtag#CSS hashtag#Sass hashtag#FrontendDevelopment hashtag#WebDevelopment hashtag#CleanCode&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%2F9vflj2odtmu7s0ldmp8n.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%2F9vflj2odtmu7s0ldmp8n.jpg" alt=" " width="800" height="1000"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>𝐖𝐡𝐚𝐭 𝐢𝐬 𝐕𝐚𝐥𝐮𝐞-𝐎𝐛𝐣𝐞𝐜𝐭 𝐚𝐧𝐝 𝐇𝐨𝐰 𝐭𝐨 𝐬𝐭𝐨𝐫𝐞 𝐢𝐭 𝐢𝐧 𝐄𝐅 𝐂𝐨𝐫𝐞?</title>
      <dc:creator>Shirin Monzavi</dc:creator>
      <pubDate>Wed, 24 Sep 2025 05:20:14 +0000</pubDate>
      <link>https://dev.to/shirin_monzavi_f3d63ff99d/--2a4m</link>
      <guid>https://dev.to/shirin_monzavi_f3d63ff99d/--2a4m</guid>
      <description>&lt;p&gt;⁉️ 𝐖𝐡𝐚𝐭?&lt;br&gt;
A value object is an object that can be identified by the composition of its values. For instance, an address can be considered as a value object because the compositions of country/region, city, street defines it.&lt;/p&gt;

&lt;p&gt;𝐈𝐦𝐩𝐨𝐫𝐭𝐚𝐧𝐭 𝐜𝐡𝐚𝐫𝐚𝐜𝐭𝐞𝐫𝐢𝐬𝐭𝐢𝐜𝐬 𝐨𝐟 𝐯𝐚𝐥𝐮𝐞 𝐨𝐛𝐣𝐞𝐜𝐭𝐬:&lt;br&gt;
1- They do not have identity. (For example, two customers with the same name are not the same and they can be distinguished by their Ids. On the other hand, when two addresses are identical, they are the same.).&lt;/p&gt;

&lt;p&gt;2- They are immutable. (The values of a value object must be immutable once the object is created. Therefore, when the object is created, you must provide the required values but must not allow them to change).&lt;/p&gt;

&lt;p&gt;🌍 𝑹𝒆𝒂𝒍-𝑾𝒐𝒓𝒍𝒅 𝑺𝒄𝒆𝒏𝒂𝒓𝒊𝒐&lt;br&gt;
Consider an Order aggregate root this aggregate root contains one entity named Order Item with an id since two order items with the same products are still different and a value object named address since two addresses with the same values are considered equal.&lt;/p&gt;

&lt;p&gt;💻 𝐈𝐦𝐩𝐥𝐞𝐦𝐞𝐧𝐭 𝐕𝐚𝐥𝐮𝐞 𝐨𝐛𝐣𝐞𝐜𝐭𝐬 𝐢𝐧 𝐂#&lt;br&gt;
You can have a value object base class that has basic utility methods like equality based on the comparison between all the attributes and other fundamental characteristics. Then each value object can inherit from the base class.&lt;/p&gt;

&lt;p&gt;🗄 𝐇𝐨𝐰 𝐜𝐚𝐧 𝐰𝐞 𝐬𝐭𝐨𝐫𝐞 𝐯𝐚𝐥𝐮𝐞 𝐨𝐛𝐣𝐞𝐜𝐭𝐬 𝐢𝐧 𝐭𝐡𝐞 𝐝𝐚𝐭𝐚𝐛𝐚𝐬𝐞 𝐬𝐢𝐧𝐜𝐞 𝐭𝐡𝐞𝐲 𝐡𝐚𝐯𝐞 𝐧𝐨 𝐢𝐝𝐞𝐧𝐭𝐢𝐭𝐲?&lt;br&gt;
The best way to store value objects with EF Core 2.0 and later is using owned entity type. An owned entity type allows you to map types that do not have identity. For implementing value objects, the entity should contain navigation of the value object and in configuration file owned entity should be defined.&lt;br&gt;
For example, in Order entity the Address is a values object and it is implemented as an owned entity type within the owner entity.&lt;br&gt;
By default, EF Core conventions name the columns for the properties of the owned entity type like EntityProperty_OwnedEntityProperty. Therefore, the properties of Address will appear in the Orders table with the names Address_Street, Address_City but you can customize with the Property().HasColumnName().&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%2Fj955jjemory12cwyjs8x.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%2Fj955jjemory12cwyjs8x.jpg" alt=" " width="800" height="1000"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;❓ 𝐇𝐨𝐰 𝐡𝐚𝐯𝐞 𝐲𝐨𝐮 𝐢𝐦𝐩𝐥𝐞𝐦𝐞𝐧𝐭𝐞𝐝 𝐭𝐡𝐞 𝐯𝐚𝐥𝐮𝐞 𝐨𝐛𝐣𝐞𝐜𝐭𝐬 𝐛𝐞𝐟𝐨𝐫𝐞 𝐄𝐅 𝐂𝐨𝐫𝐞 2.0?&lt;/p&gt;

</description>
      <category>ddd</category>
      <category>valueobject</category>
      <category>efcore</category>
    </item>
    <item>
      <title>🚀 𝐈𝐎𝐩𝐭𝐢𝐨𝐧𝐬 𝐯𝐬 𝐈𝐎𝐩𝐭𝐢𝐨𝐧𝐬𝐒𝐧𝐚𝐩𝐬𝐡𝐨𝐭 𝐯𝐬 𝐈𝐎𝐩𝐭𝐢𝐨𝐧𝐬𝐌𝐨𝐧𝐢𝐭𝐨𝐫 𝐢𝐧 .𝐍𝐄𝐓 — 𝐖𝐡𝐚𝐭’𝐬 𝐭𝐡𝐞 𝐃𝐢𝐟𝐟𝐞𝐫𝐞𝐧𝐜𝐞?</title>
      <dc:creator>Shirin Monzavi</dc:creator>
      <pubDate>Thu, 28 Aug 2025 09:31:39 +0000</pubDate>
      <link>https://dev.to/shirin_monzavi_f3d63ff99d/--2mnj</link>
      <guid>https://dev.to/shirin_monzavi_f3d63ff99d/--2mnj</guid>
      <description>&lt;p&gt;⁉️ 𝐖𝐡𝐚𝐭 𝐢𝐬 𝐭𝐡𝐞 𝐎𝐩𝐭𝐢𝐨𝐧𝐬 𝐩𝐚𝐭𝐭𝐞𝐫𝐧?&lt;br&gt;
You can represent related settings using classes, which gives you strong typing for those settings.&lt;/p&gt;

&lt;p&gt;✨ &lt;strong&gt;Benefits:&lt;/strong&gt;&lt;br&gt;
By applying this pattern, your app follows two important software engineering principles:&lt;/p&gt;

&lt;p&gt;🔒 𝐄𝐧𝐜𝐚𝐩𝐬𝐮𝐥𝐚𝐭𝐢𝐨𝐧 – services only depend on the settings they actually use.&lt;br&gt;
🧩 𝐒𝐞𝐩𝐚𝐫𝐚𝐭𝐢𝐨𝐧 𝐨𝐟 𝐜𝐨𝐧𝐜𝐞𝐫𝐧𝐬 – configuration logic is separated from business logic.&lt;/p&gt;

&lt;p&gt;⚡ &lt;em&gt;&lt;strong&gt;𝑶𝒑𝒕𝒊𝒐𝒏𝒔 𝑰𝒏𝒕𝒆𝒓𝒇𝒂𝒄𝒆𝒔 𝒊𝒏 .𝑵𝑬𝑻&lt;/strong&gt;&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;𝐈𝐎𝐩𝐭𝐢𝐨𝐧𝐬&lt;br&gt;
• Reads configuration once at startup.&lt;br&gt;
• ❌ Doesn’t update if config changes while the app is running.&lt;br&gt;
• 🟢 Registered as Singleton, can be injected anywhere.&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%2Fzjsrdt0d3ts26uk10ido.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%2Fzjsrdt0d3ts26uk10ido.png" alt=" " width="800" height="547"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;𝐈𝐎𝐩𝐭𝐢𝐨𝐧𝐬𝐒𝐧𝐚𝐩𝐬𝐡𝐨𝐭&lt;br&gt;
• Reads configuration fresh on every request.&lt;br&gt;
• Useful for per-request updates (e.g., in web apps).&lt;br&gt;
• 🟡 Registered as Scoped, so cannot be injected into Singletons.&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%2Fumu851tnmmb59hpiq8dp.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%2Fumu851tnmmb59hpiq8dp.png" alt=" " width="800" height="404"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;𝐈𝐎𝐩𝐭𝐢𝐨𝐧𝐬𝐌𝐨𝐧𝐢𝐭𝐨𝐫&lt;br&gt;
• Supports real-time updates without restarting the app.&lt;br&gt;
• Can trigger callbacks when config changes.&lt;br&gt;
• 🟢 Registered as Singleton, safe to inject anywhere.&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%2Fzk45ztn9avb2m8edfwho.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%2Fzk45ztn9avb2m8edfwho.png" alt=" " width="800" height="395"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;💡** Quick Summary**&lt;br&gt;
• IOptions → Static, simple, app startup only.&lt;br&gt;
• IOptionsSnapshot → Per-request updates.&lt;br&gt;
• IOptionsMonitor → Real-time updates with change notifications.&lt;/p&gt;

&lt;p&gt;❓ Which one have you used the most in your projects?&lt;/p&gt;

&lt;h1&gt;
  
  
  DotNet #DotNetCore #AspNetCore #DotNetDeveloper #CSharp #DotNetTips
&lt;/h1&gt;

</description>
    </item>
    <item>
      <title>🚀𝐁𝐨𝐨𝐬𝐭 𝐏𝐞𝐫𝐟𝐨𝐫𝐦𝐚𝐧𝐜𝐞 &amp; 𝐒𝐞𝐜𝐮𝐫𝐢𝐭𝐲 𝐰𝐢𝐭𝐡 𝐭𝐡𝐞 𝐏𝐫𝐨𝐱𝐲 𝐏𝐚𝐭𝐭𝐞𝐫𝐧🚀</title>
      <dc:creator>Shirin Monzavi</dc:creator>
      <pubDate>Mon, 11 Aug 2025 15:30:09 +0000</pubDate>
      <link>https://dev.to/shirin_monzavi_f3d63ff99d/-2ef8</link>
      <guid>https://dev.to/shirin_monzavi_f3d63ff99d/-2ef8</guid>
      <description>&lt;p&gt;⁉️ 𝐌𝐨𝐭𝐢𝐯𝐚𝐭𝐢𝐨𝐧&lt;br&gt;
The Proxy pattern belongs to the structural category and provides a surrogate or placeholder for another object to control access to it. It is also known as a Surrogate.&lt;/p&gt;

&lt;p&gt;🌍 𝐑𝐞𝐚𝐥-𝐖𝐨𝐫𝐥𝐝 𝐒𝐜𝐞𝐧𝐚𝐫𝐢𝐨&lt;br&gt;
Imagine we are building a document editor that embeds graphical objects in documents. Creating some graphical objects, like large raster images, is expensive. However, opening a document should be fast, so we want to avoid creating all expensive objects immediately.&lt;br&gt;
These requirements suggest creating expensive objects on demand. So, what should we put in place of the image initially?&lt;/p&gt;

&lt;p&gt;🎯 𝑺𝒐𝒍𝒖𝒕𝒊𝒐𝒏 — 𝑷𝒓𝒐𝒙𝒚 𝑷𝒂𝒕𝒕𝒆𝒓𝒏&lt;br&gt;
The solution is to use another object, an image proxy, that acts like the real image. The proxy behaves just like the image and takes care of instantiating it only when needed. The image proxy creates the real image only when the document editor requests it to display it. After creation, the proxy forwards all subsequent requests directly to the real image. Therefore, the proxy keeps a reference to the real image once it’s created.&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%2F9ci437dc4ak85ktnamdp.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%2F9ci437dc4ak85ktnamdp.png" alt=" " width="800" height="344"&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%2Fspoci002je5cyfy20cpl.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%2Fspoci002je5cyfy20cpl.png" alt=" " width="800" height="158"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;🧠 𝑾𝒉𝒆𝒏 𝒕𝒐 𝑨𝒑𝒑𝒍𝒚:&lt;br&gt;
𝐑𝐞𝐦𝐨𝐭𝐞 𝐩𝐫𝐨𝐱𝐲: When the real object is located elsewhere (over the network or on a different machine), communicating directly can be complex. A proxy can handle communication instead.&lt;br&gt;
𝐕𝐢𝐫𝐭𝐮𝐚𝐥 𝐩𝐫𝐨𝐱𝐲: When creating an object is expensive, a proxy can delay creation until it’s actually needed (lazy loading). See the real-world example above.&lt;br&gt;
𝐏𝐫𝐨𝐭𝐞𝐜𝐭𝐢𝐨𝐧 𝐩𝐫𝐨𝐱𝐲: Controls access to the original object, enforcing access rights.&lt;br&gt;
𝐒𝐦𝐚𝐫𝐭 𝐫𝐞𝐟𝐞𝐫𝐞𝐧𝐜𝐞: Replaces a simple reference but adds extra behavior each time the object is accessed (e.g., counting references).&lt;/p&gt;

&lt;p&gt;💎 𝐑𝐞𝐥𝐚𝐭𝐞𝐝 𝐏𝐚𝐭𝐭𝐞𝐫𝐧𝐬:&lt;br&gt;
𝐀𝐝𝐚𝐩𝐭𝐞𝐫: Provides a different interface for an object, while a proxy provides the same interface as its subject.&lt;br&gt;
𝐃𝐞𝐜𝐨𝐫𝐚𝐭𝐨𝐫: Similar in structure to a proxy but adds responsibilities to an object, whereas a proxy controls access.&lt;/p&gt;

&lt;p&gt;📂 𝑪𝒐𝒅𝒆 𝑬𝒙𝒂𝒎𝒑𝒍𝒆:&lt;br&gt;
👉 𝐆𝐢𝐭𝐇𝐮𝐛 - &lt;a href="https://github.com/shirin-monzavi/ProxyDesignPatternSample/tree/master" rel="noopener noreferrer"&gt;https://github.com/shirin-monzavi/ProxyDesignPatternSample/tree/master&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;❓ Have you ever used the Proxy Pattern in your projects? Share your experience!&lt;/p&gt;

</description>
      <category>designpatterns</category>
      <category>softwareengineering</category>
      <category>devtips</category>
      <category>proxydesignpattern</category>
    </item>
    <item>
      <title>Memory management with Flyweight Design Pattern</title>
      <dc:creator>Shirin Monzavi</dc:creator>
      <pubDate>Sat, 28 Jun 2025 17:00:50 +0000</pubDate>
      <link>https://dev.to/shirin_monzavi_f3d63ff99d/memory-management-with-flyweight-design-pattern-1hf3</link>
      <guid>https://dev.to/shirin_monzavi_f3d63ff99d/memory-management-with-flyweight-design-pattern-1hf3</guid>
      <description>&lt;p&gt;🚀 𝐒𝐦𝐚𝐫𝐭 𝐌𝐞𝐦𝐨𝐫𝐲 𝐌𝐚𝐧𝐚𝐠𝐞𝐦𝐞𝐧𝐭 𝐰𝐢𝐭𝐡 𝐭𝐡𝐞 𝐅𝐥𝐲𝐰𝐞𝐢𝐠𝐡𝐭 𝐏𝐚𝐭𝐭𝐞𝐫𝐧 🚀&lt;/p&gt;

&lt;p&gt;⁉️ 𝑴𝒐𝒕𝒊𝒗𝒂𝒕𝒊𝒐𝒏&lt;br&gt;
The intent of flyweight is to share an object instead of having many objects.&lt;/p&gt;

&lt;p&gt;🌍 𝑹𝒆𝒂𝒍-𝑾𝒐𝒓𝒍𝒅 𝑺𝒄𝒆𝒏𝒂𝒓𝒊𝒐&lt;br&gt;
Assume you want to design a document editor, and this editor contains:&lt;br&gt;
• 📊 Tables&lt;br&gt;
• 🖼️ Figures&lt;br&gt;
• 🔤 Characters&lt;/p&gt;

&lt;p&gt;In object-oriented design, we usually represent these entities as objects.&lt;br&gt;
⚠️ But here's the problem:&lt;br&gt;
Documents can contain thousands of characters, and creating a separate object for each one leads to:&lt;br&gt;
🔻 Too many objects&lt;br&gt;
🔻 High memory usage&lt;br&gt;
🔻 Unacceptable run-time overhead&lt;/p&gt;

&lt;p&gt;💡 This is where the Flyweight Pattern becomes useful — it helps avoid the cost of creating tons of similar objects by sharing them efficiently.&lt;/p&gt;

&lt;p&gt;🎯 𝐒𝐨𝐥𝐮𝐭𝐢𝐨𝐧 — 𝐅𝐋𝐘𝐖𝐄𝐈𝐆𝐇𝐓 𝐏𝐚𝐭𝐭𝐞𝐫𝐧&lt;br&gt;
Flyweight is an object which can be shared in multiple contexts simultaneously.&lt;/p&gt;

&lt;p&gt;🔑 Flyweights cannot guess the context they operate in, so the client must pass the extrinsic state when needed.&lt;/p&gt;

&lt;p&gt;🧠 The key idea lies in the difference between:&lt;br&gt;
🔸 Intrinsic state: stored inside the flyweight — it's independent of the context and sharable.&lt;br&gt;
🔸 Extrinsic state: provided by the client — it's context-dependent and cannot be shared.&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%2Frfzq7ka6gcc338db4bqj.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%2Frfzq7ka6gcc338db4bqj.png" alt="Image description" width="800" height="506"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;📌 &lt;strong&gt;Example:&lt;/strong&gt;&lt;br&gt;
The character 'A' in a document is an intrinsic part — the alphabet symbol stays the same.&lt;br&gt;
But the font size, color, and position are extrinsic, as they vary by context.&lt;/p&gt;

&lt;p&gt;🧠 𝐀𝐩𝐩𝐥𝐲 𝐅𝐥𝐲𝐖𝐞𝐢𝐠𝐡𝐭 𝐰𝐡𝐞𝐧 𝐚𝐥𝐥 𝐨𝐟 𝐭𝐡𝐞 𝐟𝐨𝐥𝐥𝐨𝐰𝐢𝐧𝐠 𝐚𝐫𝐞 𝐭𝐫𝐮𝐞:&lt;br&gt;
✅ A program uses a lot of objects.&lt;br&gt;
✅ Storage costs are high due to the sheer quantity of objects.&lt;br&gt;
✅ Most object state can be made extrinsic.&lt;br&gt;
✅ Removing extrinsic state allows many objects to be replaced with fewer shared ones.&lt;br&gt;
✅ The application does not rely on object identity. Identity check may return true even if the instances of flyweight are different conceptually. (e.g., font, size, color).&lt;/p&gt;

&lt;p&gt;💎 𝑹𝒆𝒍𝒂𝒕𝒆𝒅 𝑷𝒂𝒕𝒕𝒆𝒓𝒏𝒔:&lt;br&gt;
◾ 𝐂𝐨𝐦𝐩𝐨𝐬𝐢𝐭𝐞: The Flyweight pattern is often combined with the Composite pattern to implement a logically hierarchical structure in terms of a directed-acyclic graph with shared leaf nodes.&lt;/p&gt;

&lt;p&gt;◾It's often best to implement 𝐒𝐭𝐚𝐭𝐞 and 𝐒𝐭𝐫𝐚𝐭𝐞𝐠𝐲 objects as flyweights.&lt;/p&gt;

&lt;p&gt;📂 𝐂𝐨𝐝𝐞 𝐄𝐱𝐚𝐦𝐩𝐥𝐞&lt;br&gt;
👉 GitHub - &lt;a href="https://github.com/shirin-monzavi/FlyWeightDesignPattern" rel="noopener noreferrer"&gt;https://github.com/shirin-monzavi/FlyWeightDesignPattern&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;❓Have you ever used the 𝐅𝐋𝐘𝐖𝐄𝐈𝐆𝐇𝐓 Pattern in your projects?&lt;/p&gt;

</description>
      <category>flyweight</category>
      <category>designpatterns</category>
      <category>devtips</category>
      <category>softwareengineering</category>
    </item>
    <item>
      <title>When to use Facade Design Pattern?</title>
      <dc:creator>Shirin Monzavi</dc:creator>
      <pubDate>Mon, 02 Jun 2025 10:37:41 +0000</pubDate>
      <link>https://dev.to/shirin_monzavi_f3d63ff99d/when-to-use-facade-design-pattern-5b0i</link>
      <guid>https://dev.to/shirin_monzavi_f3d63ff99d/when-to-use-facade-design-pattern-5b0i</guid>
      <description>&lt;p&gt;&lt;strong&gt;🚀When to use Facade Design Pattern?🚀&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;⁉️ 𝑴𝒐𝒕𝒊𝒗𝒂𝒕𝒊𝒐𝒏&lt;br&gt;
It defines a single interface for a set of interfaces in a subsystem which leads to ease of use for the clients.&lt;/p&gt;

&lt;p&gt;🌍 𝑹𝒆𝒂𝒍-𝑾𝒐𝒓𝒍𝒅 𝑺𝒄𝒆𝒏𝒂𝒓𝒊𝒐&lt;br&gt;
Assume, a programming environment provides functionalities such as Scanner, Parser, ProgramNode, and ProgramNodeBuilder that implement the compiler. Some applications might need to access these classes directly, but most clients need to use just compile code. So, for them the low-level interface, leads complexity. &lt;/p&gt;

&lt;p&gt;🎯 𝐒𝐨𝐥𝐮𝐭𝐢𝐨𝐧 — 𝐅𝐀𝐂𝐀𝐃𝐄 𝐏𝐚𝐭𝐭𝐞𝐫𝐧&lt;br&gt;
Façade defines a unified interface for the compiler’s functionality to shield clients from those classes. &lt;br&gt;
The compiler façade makes life easier for most programmers without hiding the lower-level functionality from whom that need it.&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%2Feih50xqbq6jfu0vri7b6.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%2Feih50xqbq6jfu0vri7b6.png" alt="Image description" width="800" height="510"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;🧠 𝐖𝐡𝐞𝐧 𝐭𝐨 𝐔𝐬𝐞&lt;br&gt;
✔️ Providing a simple interface from a complex subsystem.&lt;br&gt;
✔️ Decoupling the subsystems from clients and other systems.&lt;br&gt;
✔️ Layering your subsystems.&lt;/p&gt;

&lt;p&gt;💎 𝑹𝒆𝒍𝒂𝒕𝒆𝒅 𝑷𝒂𝒕𝒕𝒆𝒓𝒏𝒔:&lt;br&gt;
◾𝐀𝐛𝐬𝐭𝐫𝐚𝐜𝐭 𝐅𝐚𝐜𝐭𝐨𝐫𝐲: be used with Facade to provide an interface for creating subsystem objects in a subsystem-independent way. Abstract Factory can also be used as an alternative to Facade to hide platform-specific classes.&lt;/p&gt;

&lt;p&gt;📂 𝐂𝐨𝐝𝐞 𝐄𝐱𝐚𝐦𝐩𝐥𝐞&lt;br&gt;
👉 GitHub - &lt;a href="https://lnkd.in/dUrWeR46" rel="noopener noreferrer"&gt;https://lnkd.in/dUrWeR46&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;❓Have you ever used the 𝐅𝐀𝐂𝐀𝐃𝐄 Pattern in your projects?&lt;/p&gt;

&lt;p&gt;hashtag#DesignPatterns hashtag#SoftwareEngineering hashtag#DevTips hashtag#FacadePattern&lt;/p&gt;

</description>
      <category>designpatterns</category>
      <category>facade</category>
      <category>programming</category>
      <category>oop</category>
    </item>
    <item>
      <title>What is Decorator Design Pattern?</title>
      <dc:creator>Shirin Monzavi</dc:creator>
      <pubDate>Mon, 26 May 2025 09:06:13 +0000</pubDate>
      <link>https://dev.to/shirin_monzavi_f3d63ff99d/what-is-decorator-design-pattern-a3d</link>
      <guid>https://dev.to/shirin_monzavi_f3d63ff99d/what-is-decorator-design-pattern-a3d</guid>
      <description>&lt;p&gt;⁉️ 𝑴𝒐𝒕𝒊𝒗𝒂𝒕𝒊𝒐𝒏&lt;br&gt;
Have you ever tried to add responsibility to an object dynamically? Decorator provides a flexible alternative to subclassing. It is known as wrapper.&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%2F0aw1tip6dpe7v2kmvjun.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%2F0aw1tip6dpe7v2kmvjun.png" alt="Image description" width="800" height="365"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;🌍 𝑹𝒆𝒂𝒍-𝑾𝒐𝒓𝒍𝒅 𝑺𝒄𝒆𝒏𝒂𝒓𝒊𝒐&lt;br&gt;
Imagine, there is a graphical component that lets you add properties such as: border, scroll bar, and so forth. One way to implement it is using inheritance, but it is not flexible. Since, the border is added statically, and a client cannot control how and when to decorate a component with a border. How can we add the border in a flexible way?&lt;/p&gt;

&lt;p&gt;🎯 𝐒𝐨𝐥𝐮𝐭𝐢𝐨𝐧 — 𝐃𝐄𝐂𝐎𝐑𝐀𝐓𝐎𝐑 𝐏𝐚𝐭𝐭𝐞𝐫𝐧&lt;br&gt;
Decorator encloses the component in another object that adds the border. The decorator conforms to the interface of the component it decorates. So, its presence is transparent to clients. The decorator forwards the request to the component and it does some actions such as adding a boarder before or after forwarding.&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%2Fzfedlxygzkv9udex5ew8.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%2Fzfedlxygzkv9udex5ew8.png" alt="Image description" width="800" height="161"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;🧠 𝐖𝐡𝐞𝐧 𝐭𝐨 𝐔𝐬𝐞&lt;br&gt;
✔️Add a functionality to an object dynamically and transparently with zero effects for other objects.&lt;br&gt;
✔️ For functionalities which can be removed.&lt;br&gt;
✔️When we want to extend a functionality with subclassing, but it is impossible, due to the explosion of subclasses.&lt;/p&gt;

&lt;p&gt;💎 𝑹𝒆𝒍𝒂𝒕𝒆𝒅 𝑷𝒂𝒕𝒕𝒆𝒓𝒏𝒔:&lt;br&gt;
◾ 𝐀𝐝𝐚𝐩𝐭𝐞𝐫: the adapter grants an object a new interface, but the decorator changes the responsibilities of an object.&lt;/p&gt;

&lt;p&gt;◾𝐂𝐨𝐦𝐩𝐨𝐬𝐢𝐭𝐞: we can consider the decorator as a decadent version of composite since it has only one component. &lt;/p&gt;

&lt;p&gt;◾𝐒𝐭𝐫𝐚𝐭𝐞𝐠𝐲: the decorator changes the skin of an object while the strategy modifies mechanism.&lt;/p&gt;

&lt;p&gt;📂 𝐂𝐨𝐝𝐞 𝐄𝐱𝐚𝐦𝐩𝐥𝐞&lt;br&gt;
 👉 GitHub - &lt;a href="https://lnkd.in/dv_YvFTd" rel="noopener noreferrer"&gt;https://lnkd.in/dv_YvFTd&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;❓Have you ever used the 𝐃𝐄𝐂𝐎𝐑𝐀𝐓𝐎𝐑 Pattern in your projects?&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Composite Design Pattern In C#</title>
      <dc:creator>Shirin Monzavi</dc:creator>
      <pubDate>Fri, 09 May 2025 07:45:13 +0000</pubDate>
      <link>https://dev.to/shirin_monzavi_f3d63ff99d/composite-design-pattern-in-c-38mh</link>
      <guid>https://dev.to/shirin_monzavi_f3d63ff99d/composite-design-pattern-in-c-38mh</guid>
      <description>&lt;p&gt;🚀 &lt;strong&gt;&lt;em&gt;Design Pattern&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;⁉️ 𝑴𝒐𝒕𝒊𝒗𝒂𝒕𝒊𝒐𝒏&lt;br&gt;
Compose objects into tree structures to represent part or whole of hierarchies. Composite lets clients treat individual objects and compositions of objects uniformly.&lt;/p&gt;

&lt;p&gt;🌍 𝑹𝒆𝒂𝒍-𝑾𝒐𝒓𝒍𝒅 𝑺𝒄𝒆𝒏𝒂𝒓𝒊𝒐&lt;br&gt;
Imagine you're building a graphical editor. Users can create basic shapes like Text, Circle, etc., and combine them into complex images.&lt;br&gt;
A basic solution might involve one class for simple objects and another for containers. But this forces clients to handle each differently, increasing complexity.&lt;/p&gt;

&lt;p&gt;🎯 𝐒𝐨𝐥𝐮𝐭𝐢𝐨𝐧 — 𝐂𝐨𝐦𝐩𝐨𝐬𝐢𝐭𝐞 𝐏𝐚𝐭𝐭𝐞𝐫𝐧&lt;br&gt;
Composite pattern helps us to recursive composition so that clients are not required to make this distinction. This pattern has an abstract class for both primitives and their containers.&lt;br&gt;
For instance, in the graphics system this abstract named Graphic which declares operation like Draw for graphical objects. It also declares operations that all composite objects share, such as Get Child, Add, Remove.&lt;br&gt;
The Picture class defines a list of graphic objects and implements draw to call draw on its children. In addition, the picture implements child-related operations. Since the picture interface inherits from the Graphic interface, picture objects can compose other pictures recursively. &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%2Frkdgze9dfh2ijwirmaku.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%2Frkdgze9dfh2ijwirmaku.png" alt="Image description" width="800" height="375"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;🧠 𝐖𝐡𝐞𝐧 𝐭𝐨 𝐔𝐬𝐞&lt;br&gt;
✔️ When individual objects and object groups should be handled identically.&lt;br&gt;
✔️ When tree structures or recursive hierarchies are involved.&lt;/p&gt;

&lt;p&gt;💎 𝑹𝒆𝒍𝒂𝒕𝒆𝒅 𝑷𝒂𝒕𝒕𝒆𝒓𝒏𝒔&lt;br&gt;
🔁 Chain of Responsibility often uses parent references.&lt;br&gt;
 🎨 Decorator works well with Composite to extend behavior.&lt;br&gt;
 🧬 Flyweight can reduce memory usage but removes parent references.&lt;br&gt;
 🔍 Iterator helps traverse composite structures.&lt;br&gt;
 🧭 Visitor centralizes operations across Composite and Leaf classes.&lt;/p&gt;

&lt;p&gt;📂 𝑪𝒐𝒅𝒆 𝑬𝒙𝒂𝒎𝒑𝒍𝒆&lt;br&gt;
👉 GitHub - &lt;a href="https://lnkd.in/dy9h_VuA" rel="noopener noreferrer"&gt;https://lnkd.in/dy9h_VuA&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;💬 𝐘𝐨𝐮𝐫 𝐓𝐮𝐫𝐧!&lt;br&gt;
❓𝐇𝐚𝐯𝐞 𝐲𝐨𝐮 𝐞𝐯𝐞𝐫 𝐮𝐬𝐞𝐝 𝐭𝐡𝐞 𝐂𝐨𝐦𝐩𝐨𝐬𝐢𝐭𝐞 𝐏𝐚𝐭𝐭𝐞𝐫𝐧 𝐢𝐧 𝐲𝐨𝐮𝐫 𝐩𝐫𝐨𝐣𝐞𝐜𝐭𝐬?&lt;/p&gt;

&lt;p&gt;hashtag#DesignPatterns hashtag#SoftwareEngineering hashtag#DevTips hashtag#CompositePattern&lt;/p&gt;

</description>
    </item>
    <item>
      <title>What is Bridge Design Pattern?</title>
      <dc:creator>Shirin Monzavi</dc:creator>
      <pubDate>Sat, 26 Apr 2025 17:34:37 +0000</pubDate>
      <link>https://dev.to/shirin_monzavi_f3d63ff99d/what-is-bridge-design-pattern-3ic6</link>
      <guid>https://dev.to/shirin_monzavi_f3d63ff99d/what-is-bridge-design-pattern-3ic6</guid>
      <description>&lt;p&gt;🚀All things you should know about bridge design pattern&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;⁉️ Motivation&lt;/strong&gt;&lt;br&gt;
Decouple an abstraction from its implementation so that both can evolve independently. It belongs to the structural category.&lt;/p&gt;

&lt;p&gt;🌍 &lt;strong&gt;Real-World Scenario&lt;/strong&gt;&lt;br&gt;
When an abstraction can have multiple implementations, the typical approach is inheritance. But this leads to some issues.&lt;br&gt;
Let’s say we have an abstract class Window, with two implementations: XWindow and PMWindow. If we use inheritance and want to add a new type like IconWindow, we’ll need to create XIconWindow and PMIconWindow. &lt;br&gt;
This leads to:&lt;/p&gt;

&lt;p&gt;1️⃣ &lt;strong&gt;Class explosion&lt;/strong&gt; – For every new window type, we must implement it for each platform.&lt;/p&gt;

&lt;p&gt;2️⃣ &lt;strong&gt;Tight coupling&lt;/strong&gt; – The client is forced to choose a concrete platform (XWindow or PMWindow), tying the code to a specific implementation.&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%2F7n0e570oddq3hzdf6p50.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%2F7n0e570oddq3hzdf6p50.png" alt="Image description" width="800" height="261"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;🎯 &lt;strong&gt;Solution — Bridge Pattern&lt;/strong&gt;&lt;br&gt;
The Bridge pattern solves this by splitting the abstraction (Window, IconWindow, TransientWindow, etc.) from the implementation (WindowImp, XWindowImp, PMWindowImp, etc.).&lt;br&gt;
💡 The abstraction holds a reference to the implementation, and they communicate through a defined interface. This bridges the two hierarchies, enabling independent evolution and better flexibility.&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%2Fujgtvy0c6za8doze83tb.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%2Fujgtvy0c6za8doze83tb.png" alt="Image description" width="800" height="505"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;💎 &lt;em&gt;&lt;strong&gt;Related Patterns&lt;/strong&gt;&lt;/em&gt;&lt;br&gt;
• Abstract Factory can help create and configure a particular Bridge.&lt;br&gt;
• Adapter lets unrelated classes work together, but it's applied after design.&lt;br&gt;
• Bridge is a design-time decision to decouple abstraction from implementation.&lt;/p&gt;

&lt;p&gt;📂** Code Example**&lt;br&gt;
See it in action:&lt;br&gt;
👉 GitHub - &lt;a href="https://github.com/shirin-monzavi/BridgeDesignPatternSample" rel="noopener noreferrer"&gt;https://github.com/shirin-monzavi/BridgeDesignPatternSample&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;💬 &lt;strong&gt;Your Turn!&lt;/strong&gt;&lt;br&gt;
&lt;em&gt;❓Have you ever used the Bridge Pattern in your projects?&lt;/em&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%2F4joybvlm95cxyny1d4pm.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%2F4joybvlm95cxyny1d4pm.png" alt="Image description" width="225" height="225"&gt;&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Adapter Design Pattern</title>
      <dc:creator>Shirin Monzavi</dc:creator>
      <pubDate>Thu, 10 Apr 2025 17:57:12 +0000</pubDate>
      <link>https://dev.to/shirin_monzavi_f3d63ff99d/adapter-design-pattern-410</link>
      <guid>https://dev.to/shirin_monzavi_f3d63ff99d/adapter-design-pattern-410</guid>
      <description>&lt;p&gt;𝐓𝐢𝐭𝐥𝐞🔌𝐀𝐝𝐚𝐩𝐭𝐞𝐫 𝐃𝐞𝐬𝐢𝐠𝐧 𝐏𝐚𝐭𝐭𝐞𝐫𝐧&lt;/p&gt;

&lt;p&gt;⁉️ 𝐈𝐧𝐭𝐞𝐧𝐭&lt;br&gt;
Allows classes work together although they have incompatible interfaces.&lt;/p&gt;

&lt;p&gt;🤯𝐏𝐫𝐨𝐛𝐥𝐞𝐦&lt;br&gt;
Have you ever tried to integrate two existing system…but they just don’t fit together?&lt;/p&gt;

&lt;p&gt;🌏 𝐑𝐞𝐚𝐥-𝐖𝐨𝐫𝐥𝐝 𝐒𝐜𝐞𝐧𝐚𝐫𝐢𝐨&lt;br&gt;
For example a drawing editor provides users actions such as: draw and arrange of graphical elements (lines, text, etc.). This editor provides an abstract class named Shape. Classes for elementary shapes like LineShape and PolygonShape are easy to implement, but TextShape is not because it displays and edits text. Meanwhile, there is a toolkit class which already implements displaying and editing text named TextView, but it was not designed to work with Shape classes. Therefore, we cannot use TextView and Shape interchangeably. How can we cope with this issue?&lt;/p&gt;

&lt;p&gt;🎯 𝐒𝐨𝐥𝐮𝐭𝐢𝐨𝐧 — 𝐀𝐝𝐚𝐩𝐭𝐞𝐫 𝐏𝐚𝐭𝐭𝐞𝐫𝐧&lt;br&gt;
We can define TextShape so that it adapts the TextView to Shape. We can do it in one of two ways:&lt;br&gt;
1️⃣𝐈𝐧𝐡𝐞𝐫𝐢𝐭𝐚𝐧𝐜𝐞&lt;br&gt;
2️⃣𝐂𝐨𝐦𝐩𝐨𝐬𝐢𝐭𝐢𝐨𝐧&lt;/p&gt;

&lt;p&gt;💎𝐑𝐞𝐥𝐚𝐭𝐞𝐝 𝐏𝐚𝐭𝐭𝐞𝐫𝐧𝐬&lt;br&gt;
Bridge has a structure similar to an object adapter, but Bridge has a different intent: It is meant to separate an interface from its implementation so that they can be varied independently. An Adapter is meant to change the interface of an existing object. Decorator enhances another object without changing its interface. A decorator is thus more transparent to the application than an adapter is. As a consequence, Decorator supports recursive composition, which isn't possible with pure adapters. &lt;/p&gt;

&lt;p&gt;📂 𝐂𝐨𝐝𝐞 𝐄𝐱𝐚𝐦𝐩𝐥𝐞&lt;br&gt;
See it in action:&lt;br&gt;
👉 GitHub - (&lt;a href="https://github.com/shirin-monzavi/AdapterSample" rel="noopener noreferrer"&gt;https://github.com/shirin-monzavi/AdapterSample&lt;/a&gt;)&lt;/p&gt;

&lt;p&gt;❓𝐖𝐡𝐢𝐜𝐡 𝐝𝐞𝐬𝐢𝐠𝐧 𝐩𝐚𝐭𝐭𝐞𝐫𝐧 𝐝𝐨 𝐲𝐨𝐮 𝐬𝐭𝐫𝐮𝐠𝐠𝐥𝐞 𝐰𝐢𝐭𝐡 𝐭𝐡𝐞 𝐦𝐨𝐬𝐭?&lt;/p&gt;

&lt;p&gt;👇 I’d love to hear your thoughts!&lt;/p&gt;

</description>
      <category>designpatterns</category>
      <category>adapter</category>
      <category>programming</category>
      <category>adapterdesignpattern</category>
    </item>
  </channel>
</rss>
