<?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: Gürkan</title>
    <description>The latest articles on DEV Community by Gürkan (@esat).</description>
    <link>https://dev.to/esat</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%2F3502195%2F9490ef09-d218-475b-8ade-c9782b32a24c.png</url>
      <title>DEV Community: Gürkan</title>
      <link>https://dev.to/esat</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/esat"/>
    <language>en</language>
    <item>
      <title>The Pattern-Layer Correspondence: A Practical Guide to Organizing Design Patterns</title>
      <dc:creator>Gürkan</dc:creator>
      <pubDate>Sun, 14 Sep 2025 23:20:10 +0000</pubDate>
      <link>https://dev.to/esat/the-pattern-layer-correspondence-a-practical-guide-to-organizing-design-patterns-k9h</link>
      <guid>https://dev.to/esat/the-pattern-layer-correspondence-a-practical-guide-to-organizing-design-patterns-k9h</guid>
      <description>&lt;p&gt;Hey dev community! 👋 Ever found yourself wondering: "Should this Factory pattern go in the Domain or Infrastructure layer?"&lt;/p&gt;

&lt;p&gt;After years of working with layered architecture, I noticed a natural pattern in where design patterns belong. Let me introduce you to the Pattern-Layer Correspondence Principle!&lt;/p&gt;

&lt;h2&gt;
  
  
  🔍 &lt;strong&gt;The Problem: Pattern Chaos&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;We've all seen this anti-pattern:&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%2Fkgox2sbn4hsjcxcuw1w1.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%2Fkgox2sbn4hsjcxcuw1w1.png" alt=" " width="665" height="642"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  🎯 &lt;strong&gt;The Aha Moment: Natural Mapping&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;There's a beautiful correspondence between GoF pattern categories and software layers:&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%2F9dunvvf7zahioxyo39zt.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%2F9dunvvf7zahioxyo39zt.png" alt=" " width="800" height="148"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  🏗️ &lt;strong&gt;Deep Dive with C# Examples&lt;/strong&gt;
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. ✅ Creational Patterns in Domain Layer
&lt;/h3&gt;

&lt;p&gt;Why? Because object creation often involves business rules and domain knowledge.&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%2Fd21gbvvmz9l1ru1o3wml.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%2Fd21gbvvmz9l1ru1o3wml.png" alt=" " width="543" height="677"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  2. ✅ Behavioral Patterns in Application Layer
&lt;/h3&gt;

&lt;p&gt;Why? Because application layer coordinates behaviors and workflows.&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%2Fljcx64lz51soo1av85l2.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%2Fljcx64lz51soo1av85l2.png" alt=" " width="725" height="1294"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  3. ✅ Structural Patterns in Infrastructure Layer
&lt;/h3&gt;

&lt;p&gt;Why? Because infrastructure handles technical implementation and integration.&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%2F12zcux0oqq0bthu44v3q.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%2F12zcux0oqq0bthu44v3q.png" alt=" " width="734" height="1437"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  🎯 &lt;strong&gt;Interactive: Pattern Placement Quiz&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Where would you put these patterns?&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;code&gt;EmailNotificationDecorator&lt;/code&gt; - Adds email notifications to repository operations

&lt;ul&gt;
&lt;li&gt;Domain&lt;/li&gt;
&lt;li&gt;Application&lt;/li&gt;
&lt;li&gt;Infrastructure ✅&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;OrderProcessingWorkflow&lt;/code&gt; - Coordinates multiple steps in order processing

&lt;ul&gt;
&lt;li&gt;Domain&lt;/li&gt;
&lt;li&gt;Application ✅&lt;/li&gt;
&lt;li&gt;Infrastructure&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;ProductBuilder&lt;/code&gt; - Constructs complex product objects with validation

&lt;ul&gt;
&lt;li&gt;Domain ✅&lt;/li&gt;
&lt;li&gt;Application&lt;/li&gt;
&lt;li&gt;Infrastructure&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  📊 &lt;strong&gt;Benefits of This Approach&lt;/strong&gt;
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. Cleaner Architecture
&lt;/h3&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%2Fa998yo7w8dzwe3317rj5.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%2Fa998yo7w8dzwe3317rj5.png" alt=" " width="294" height="585"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  2. Better Code Reviews
&lt;/h3&gt;

&lt;p&gt;Now you can say:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"This Decorator pattern should be in Infrastructure, not Domain, because it's structural."&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  3. Easier Onboarding
&lt;/h3&gt;

&lt;p&gt;New developers get a mental model:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;"Need a Factory? That goes in Domain layer."&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  ⚠️ &lt;strong&gt;Exceptions and Nuances&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Of course, software architecture isn't always black and white:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Domain Events&lt;/strong&gt; might use Observer pattern in Domain layer&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Composite pattern&lt;/strong&gt; can be in Domain (product bundles) or Infrastructure (tree structures)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Bridge pattern&lt;/strong&gt; might span Application and Infrastructure&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  🚀 &lt;strong&gt;Practical Application&lt;/strong&gt;
&lt;/h2&gt;

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

&lt;ul&gt;
&lt;li&gt;Move creational patterns to Domain layer&lt;/li&gt;
&lt;li&gt;Move behavioral patterns to Application layer&lt;/li&gt;
&lt;li&gt;Move structural patterns to Infrastructure layer&lt;/li&gt;
&lt;li&gt;Update imports and dependencies&lt;/li&gt;
&lt;li&gt;Verify layer boundaries are respected&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;New Project Template:&lt;/strong&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%2F8pgxmxqe82uqy2h4rw2r.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%2F8pgxmxqe82uqy2h4rw2r.png" alt=" " width="353" height="307"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  💬 &lt;strong&gt;Let's Discuss!&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;What do you think?&lt;/strong&gt;&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Have you seen this pattern in your projects?&lt;/li&gt;
&lt;li&gt;What exceptions have you encountered?&lt;/li&gt;
&lt;li&gt;Do you disagree with any of these mappings?&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Share your experiences in the comments! 👇&lt;/p&gt;

&lt;p&gt;Follow me for more architecture insights! 🚀&lt;/p&gt;

</description>
      <category>designpatterns</category>
      <category>cleancode</category>
      <category>ddd</category>
      <category>architecture</category>
    </item>
  </channel>
</rss>
