Tactical Domain-Driven Design (DDD) Reference Implementation in C# / .NET
VendingMachine is a clean-architecture reference model demonstrating tactical Domain-Driven Design (DDD), object-oriented encapsulation, and Test-Driven Development (TDD) in C#.
Rather than treating a state machine as procedural UI logic, it models financial value objects, inventory aggregates, and wallet change-dispensing strategies with strict invariant enforcement.
- Financial Value Objects (
Money,Coin,Currency,CoinsBuilder):- Immutable monetary primitives enforcing currency consistency (
MoneyCurrencyMismatchException).
- Immutable monetary primitives enforcing currency consistency (
- Wallet & Change Allocation Strategy (
IWallet,MinCoinsWallet):- Encapsulates coin denomination inventory and optimal change-making algorithms with explicit domain exceptions (
NotAnoughCoinsException,NotAnoughMoneyException).
- Encapsulates coin denomination inventory and optimal change-making algorithms with explicit domain exceptions (
- Aggregate Boundaries (
IVendingMachine,NumpadVendingMachine,ProductBusket,Customer):- Decouples product catalog (
IProduct,IShowcaseItem) and basket state transitions from presentation view-models (MainWindowViewModelTests).
- Decouples product catalog (
- Comprehensive Unit Test Suite (
VendingMachine.Tests):- Full test coverage across coin arithmetic, wallet dispensing, product basket invariants, and view-model interaction.
Andrey Leskov — CTO & Principal Systems Architect (illumi.one · LinkedIn).