Composition Over Inheritance: Refactoring a .NET Class Hierarchy
A realistic inheritance hierarchy that rots under new requirements, and a step-by-step refactor into composed behaviours that stay easy to change and test.
Hi, I'm Vichea Nath. With 6+ years architecting C# .NET Core backends, distributed microservices, and reactive TypeScript/React interfaces, I build software engineered for speed, scale, and longevity.
Explore how enterprise systems handle decoupled domain business logic, high-throughput asynchronous persistence, and optimistic frontend cache synchronization.
Optimistic cache snapshot in onMutate, Bearer JWT injection, client-side input normalization.
JWT validation, rate-limiter bucket (100 req/s), MediatR IPipelineBehavior pre-validation.
CreateOrderCommandHandler loads aggregate, executes business invariants, and raises OrderCreatedDomainEvent.
Single ACID transaction writes Order entity + OutboxMessage table. Concurrency token verified.
HTTP 201 Created returned. Background Outbox Worker publishes domain events to subscribers.
Encapsulated Aggregate Roots (`Order`) guard business rules with strongly typed IDs and Value Objects (`Money`). Domain events are captured inside aggregates without premature dispatch.
`SaveChangesInterceptor` atomically persists Domain Events into an Outbox table alongside business state changes, guaranteeing At-Least-Once Delivery with zero distributed dual-write bugs.
Query Key Factories govern caching, while mutations leverage `onMutate` optimistic rollbacks. Read queries bypass domain entities to execute fast `AsNoTracking` DTO projections.
Over 6 years mastering backend systems, cloud architectures, and modern responsive frontend web applications.
ASP.NET Core, Minimal APIs, Async/Await, Memory Optimization
Aggregate Roots, Value Objects, Domain Events, Invariant Enforcement
Command/Query Handlers, Pipeline Behaviors, Railway-Oriented Result
Complex types, Value converters, SaveChangesInterceptor, Outbox table
Indexing, Query optimization, ACID transactions, Execution plans
Contract-first, RFC 7807 ProblemDetails, Rate limiting, OpenAPI
Cache-aside pattern, Pub/Sub, Distributed locks, SWR caching
Server Components, Custom Hooks, State Machines, SSR
Query Key Factory, Optimistic Mutations, Cache Invalidation, Rollbacks
Strict typing, Generics, Utility types, DTO contracts
Core Web Vitals, Optimistic UI, Bundle Splitting, SPA
RxJS, NgRx, Enterprise Component Architecture
Flexbox, CSS Grid, Fluid Typography, Vanilla CSS & Tailwind
App Services, Azure Functions, Azure SQL, Key Vault, Service Bus
Multi-stage builds, Docker Compose, Microservices
Automated test suites, Deployment pipelines, Linting
Transactional Outbox, Eventual consistency, Azure Service Bus
Inspect how I write clean, resilient, and performant code with DDD Aggregate Roots, CQRS Handlers, EF Core 9 Persistence, and TanStack React Query.
1// Domain/Orders/Order.cs - Pure DDD Invariants & Domain Events
2public sealed class Order : AggregateRoot<OrderId>
3{
4 private readonly List<OrderItem> _items = [];
5 public Guid CustomerId { get; private set; }
6 public OrderStatus Status { get; private set; }
7 public IReadOnlyCollection<OrderItem> Items => _items.AsReadOnly();
8
9 private Order() { } // EF Core reflection
10
11 public static Order Create(Guid customerId)
12 {
13 var order = new Order(OrderId.New(), customerId);
14 order.RaiseDomainEvent(new OrderCreatedDomainEvent(Guid.NewGuid(), order.Id, customerId));
15 return order;
16 }
17
18 public Result AddItem(Guid productId, int quantity, Money unitPrice)
19 {
20 if (Status != OrderStatus.Draft)
21 return Result.Failure(new Error("Order.NotModifiable", "Cannot edit locked order."));
22
23 if (quantity <= 0)
24 return Result.Failure(new Error("Order.InvalidQty", "Quantity must be > 0."));
25
26 _items.Add(new OrderItem(Guid.NewGuid(), productId, quantity, unitPrice));
27 return Result.Success();
28 }
29
30 public Money TotalAmount => _items.Count == 0
31 ? Money.Zero("USD")
32 : _items.Select(i => i.TotalPrice).Aggregate((a, b) => (a + b).Value);
33}Open-source software, developer tools, and full-stack solutions built with modern .NET and React.
Modern, high-performance audio/visual labeling studio and dataset management suite built for AI/ML teams.
High-speed bug, log search, and diagnostics telemetry engine designed for microservices and cloud backends.
Full-stack Point of Sale & inventory system designed for high availability, multi-tenant outlets, and real-time receipts.
Enterprise Clean Architecture solution template with CQRS, MediatR, FluentValidation, EF Core 9, and JWT Auth.
6+ years delivering scalable enterprise software across Fintech, E-commerce, and high-load web platforms.
Maharishi International University
Master's degree, Computer Science (Aug 2023 – Apr 2026)
Royal University Phnom Penh
Bachelor's degree, Computer Science (Aug 2018 – Jun 2022)
Notes from day-to-day engineering: backend patterns in C# .NET, CQRS, frontend performance, and what holds up in production.
A realistic inheritance hierarchy that rots under new requirements, and a step-by-step refactor into composed behaviours that stay easy to change and test.
A practical guide to building ASP.NET Core APIs that stay predictable under load, handle failures well, and remain easy to change.
How to use async and await in .NET without creating hidden deadlocks, thread starvation, or unnecessarily complicated code.
A practical EF Core checklist for reducing slow queries, oversized object graphs, and unnecessary database work in production systems.