<?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: Miroslav Thompson</title>
    <description>The latest articles on DEV Community by Miroslav Thompson (@czmirek).</description>
    <link>https://dev.to/czmirek</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%2F3957179%2F38f67c69-376c-45d3-8b8d-9750e4e8f163.jpeg</url>
      <title>DEV Community: Miroslav Thompson</title>
      <link>https://dev.to/czmirek</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/czmirek"/>
    <language>en</language>
    <item>
      <title>Building software in C#: part 1 - history.</title>
      <dc:creator>Miroslav Thompson</dc:creator>
      <pubDate>Thu, 28 May 2026 20:29:09 +0000</pubDate>
      <link>https://dev.to/czmirek/building-software-in-c-part-1-history-1p1i</link>
      <guid>https://dev.to/czmirek/building-software-in-c-part-1-history-1p1i</guid>
      <description>&lt;h2&gt;
  
  
  3-Layer Architecture
&lt;/h2&gt;

&lt;p&gt;When I started programming in C# back in 2010 in Prague (Czech Republic), the dominant trend was the 3-layer monolithic architecture. This approach splits an application into a presentation layer, a business layer, and a database layer.&lt;/p&gt;

&lt;p&gt;For some reason, however, this concept was often misunderstood. Instead of layers, people treated them as independent components that could talk to each other "whenever it made sense." Senior developers during interviews would strictly insist that the business layer must sit precisely between the presentation and database layers, and that you must never communicate directly from the presentation layer to the database—or, God forbid, vice versa.&lt;/p&gt;

&lt;p&gt;The bizarre legacy projects where the UI and the database communicate directly with each other in both directions, while the "business layer" serves merely as a dumping ground for helper code "when things get too complicated," date back to this era.&lt;/p&gt;

&lt;h2&gt;
  
  
  Onion Architecture
&lt;/h2&gt;

&lt;p&gt;Some time later, the Onion Architecture technique became popular. Developers got incredibly excited about it—after all, software is never just about three simple layers, right? That would be too easy. Software is complicated, like life itself, so it needs many layers. Therefore, this had to be the correct approach.&lt;/p&gt;

&lt;p&gt;In the center of the onion is &lt;strong&gt;the core&lt;/strong&gt;—the ultimate &lt;strong&gt;root of your business&lt;/strong&gt; and the &lt;strong&gt;very center of everything&lt;/strong&gt;. Everything on top of it consists of technical layers that stack up sequentially. These outer layers aren't considered important; only the center matters.&lt;/p&gt;

&lt;p&gt;It sounded so good on paper that teams rushed to put it into practice, inadvertently creating immense technical debt for future years to come.&lt;/p&gt;

&lt;p&gt;To this day, the practical implications of the "onion" model remain vague. If you search Google Images for "onion layer architecture," you will find wildly different and conflicting interpretations. Is the center of the onion your business logic or the shape of your database entities? Can layers that touch communicate in both directions? What is the outermost layer actually supposed to be?&lt;/p&gt;

&lt;h2&gt;
  
  
  Domain-Driven Design (DDD)
&lt;/h2&gt;

&lt;p&gt;I suspect that Domain-Driven Design (DDD) gained popularity because people were overemphasizing the importance of the Onion Architecture's "core." The "core" represented the vital part: the business logic.&lt;/p&gt;

&lt;p&gt;DDD became very explicit about this: the "domain" is the holy grail of your business. As a developer, you are expected to step back and prioritize the business logic above all else. You act as a translator of business requirements into code, and nothing more. This is DDD—business first!&lt;/p&gt;

&lt;p&gt;So, how do we implement it? Well, you need a &lt;strong&gt;domain expert&lt;/strong&gt;—a dedicated role responsible for maintaining the &lt;strong&gt;ubiquitous language&lt;/strong&gt; of the domain and translating business goals into requirements.&lt;/p&gt;

&lt;p&gt;In my entire career, I have never met anyone who officially held the title of a domain expert. Never, even in highly formalized multinational corporations, have I seen this role officially established. (Though some rumored they actually had them at Netflix).&lt;/p&gt;

&lt;p&gt;Ultimately, this approach often circled back to implementing a standard 3-layer architecture, just doing it &lt;em&gt;correctly&lt;/em&gt; this time. The domain served as the business layer, and the data flow moved strictly in one direction: from presentation to business, and then to the database. As for background processes, WSDL SOAP APIs, or webhooks—we just pretended they fit cleanly into the onion so the codebase wouldn't turn into spaghetti. Are you hungry?&lt;/p&gt;

&lt;h2&gt;
  
  
  DDD, ES, and CQRS
&lt;/h2&gt;

&lt;p&gt;For a time, this combination was the ultimate trend that suddenly made everything look pristine and perfect.&lt;/p&gt;

&lt;p&gt;You isolate your &lt;strong&gt;holy grail business core&lt;/strong&gt; into an immutable stream of changes called &lt;strong&gt;event sourcing&lt;/strong&gt; (ES). Your domain remains pure and spotless. Your classes represent domain objects in a perfect 1:1 relationship with the business, and their methods reflect real-world business processes.&lt;/p&gt;

&lt;p&gt;CQRS (Command-Query Responsibility Segregation) made the whole setup feel like an encounter with programming perfection. Commands are sent straight to your domain, while queries are handled by read models constructed asynchronously from events. Because, let’s face it, "eventual consistency" is a beautiful concept.&lt;/p&gt;

&lt;p&gt;It worked beautifully until someone asked a fundamental question: &lt;em&gt;"How do we ensure user email addresses are unique?"&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;This simple requirement made some architects so defensive they argued back: &lt;em&gt;"That's a stupid requirement, you don't actually need unique emails, go away."&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;But seriously, how do you handle this in a pure DDD/ES/CQRS setup?&lt;/p&gt;

&lt;p&gt;You cannot easily enforce it inside a &lt;code&gt;User&lt;/code&gt; class because that class only knows the context of a single user. Do you create a &lt;code&gt;UserCollection&lt;/code&gt; class in front of your commands to manage emails? If so, how does a &lt;code&gt;UserCollection&lt;/code&gt; capture the meaningful business knowledge that DDD advocates so strongly for?&lt;/p&gt;

&lt;p&gt;Furthermore, how do you validate uniqueness across a collection if you rely on event sourcing to load your domain state? Loading every single historical email into memory to run a check is clearly inefficient. You are left with no choice but to store user emails separately, outside of the primary event store.&lt;/p&gt;

&lt;p&gt;This highlights the biggest drawback of the DDD/ES/CQRS paradigm: extreme complexity. Managing snapshots, command/event versioning, data anonymization (for GDPR) within the event store, event ordering, concurrency, and read-model desynchronization means you often spend more time engineering a starship than shipping production-ready features.&lt;/p&gt;

&lt;h2&gt;
  
  
  MediatR
&lt;/h2&gt;

&lt;p&gt;Not long ago, MediatR and the mediator pattern gained massive popularity in the C# ecosystem. Suddenly, applications were structured around commands, notifications, and interfaces like &lt;code&gt;IMediator&lt;/code&gt;, &lt;code&gt;ISender&lt;/code&gt;, or &lt;code&gt;IPublisher&lt;/code&gt; to build request pipelines.&lt;/p&gt;

&lt;p&gt;Developers, likely exhausted by the overhead of DDD/ES/CQRS, looked for something simpler.&lt;/p&gt;

&lt;p&gt;MediatR helped many realize that treating the "domain" as a flat list of distinct, single units of work is highly maintainable, predictable, and clean.&lt;/p&gt;

&lt;h2&gt;
  
  
  Clean Architecture
&lt;/h2&gt;

&lt;p&gt;Looking at our industry's history, the name "Clean Architecture" itself highlights how deeply developers crave perfection. It often feels like the field is driven by an ongoing effort to prove architectural points.&lt;/p&gt;

&lt;p&gt;In reality, Clean Architecture is essentially a modernized 3-layer architecture split across five or more projects. It leverages the mediator pattern and offers a structured separation of concerns that—once you gain experience with it—makes it highly obvious where every piece of code belongs.&lt;/p&gt;

&lt;h2&gt;
  
  
  Vertical Slicing
&lt;/h2&gt;

&lt;p&gt;Vertical slicing shifts the focus toward the componentization of your code. Instead of organizing your project by technical layers, you group code by distinct business features, ensuring each folder contains all the layers relevant to that specific functionality.&lt;/p&gt;

&lt;p&gt;For example, instead of scattering a feature across a &lt;code&gt;UserRepository&lt;/code&gt; (in a data project), a &lt;code&gt;UserService&lt;/code&gt; (in a business project), and a &lt;code&gt;UserPage.razor&lt;/code&gt; (in a UI project), you place them all into a single &lt;code&gt;User&lt;/code&gt; folder. Everything related to users lives in one place.&lt;/p&gt;

&lt;p&gt;This approach delivers excellent modularity. It is arguably one of the best ways to build single-server web applications or UIs, though it requires careful boundary management when designing complex APIs.&lt;/p&gt;

</description>
      <category>architecture</category>
      <category>csharp</category>
      <category>dotnet</category>
      <category>softwareengineering</category>
    </item>
  </channel>
</rss>
