Architecture & Patterns
Synthesis of the previous four sections. Layered/clean/hexagonal architecture, DDD tactical patterns, CQRS + MediatR, the repository/unit-of-work debate (when EF's DbContext already IS your UoW), the result-pattern-vs-exceptions debate, vertical slice architecture, and pragmatic SOLID.
The sidebar under this section is grouped into Patterns Fundamentals (GoF, SOLID, Result vs exceptions, object-mapping libraries — the OO and toolchain primitives) and Architectural Styles (the opinionated, application-shape choices: Clean / Onion / Hex, DDD, CQRS, VSA, Repository).
Topics (canonical order)
-
What they share, where they differ, when each pays off, the criticisms
-
Entities, aggregates, value objects, domain events, invariants, aggregate boundaries
-
Read vs write models, MediatR pipeline behaviors, when CQRS is overkill
-
When
DbContextIS your UoW, when a repository helps, when it's noise -
When to throw, when to return Result, integration with Minimal APIs, perf trade-offs
-
Feature folders, slice handlers, REPR pattern, comparing to clean architecture
-
What each principle actually means, when slavish application is wrong
-
AutoMapper / Mapster / Riok.Mapperly / hand-rolled, EF projection trade-offs, decision matrix
-
Practical .NET-flavored survey: where each classic pattern lives in modern .NET (DI, MediatR, middleware, channels, records)
Why this order
Big-picture architectures (Clean / Onion / Hexagonal) come first because they frame everything. DDD comes next because it's the dominant tactical vocabulary. CQRS+MediatR follows because it operationalizes DDD and intersects with EF Core. The Repo/UoW debate and Result/exceptions debate come after because they're informed by EF Core mechanics. VSA closes the structural conversation. SOLID is intentionally last because over-application of SOLID is itself an anti-pattern; the senior view is "use it as a sanity check, not a religion."
Cross-references
- Result pattern cross-links into Exception Design.
- DDD links to EF Core Fundamentals for aggregate persistence and to Sagas: Orchestration vs Choreography for cross-aggregate workflows.
- VSA cross-links to Minimal APIs.