Skip to content

Latest commit

Β 

History

History
70 lines (40 loc) Β· 2.75 KB

File metadata and controls

70 lines (40 loc) Β· 2.75 KB

Command Processor

.NET [Architecture] License

πŸ“– Overview

A robust, enterprise-grade C# console application demonstrating the Command Design Pattern and Dependency Injection with a "Fortress" architecture. This project allows users to perform arithmetic operations with full Undo capabilities.

πŸ—οΈ Architecture: The "Fortress" Model

This solution is divided into two distinct layers to ensure strict Separation of Concerns and Data Integrity:

  • CommandProcessor.Core (Class Library): The "Fortress." All business logic, the Calculator state, and specific ICommand implementations are marked as internal. They are inaccessible to the UI, preventing external tampering.

  • CommandProcessor.Console (Console App): The UI layer. It interacts only with the ICommandManager interface and is responsible for user input and output.

  • CommandProcessor.Tests (xUnit): A comprehensive suite of unit tests to verify the Undo stack and DI container registration.

πŸ› οΈ Design Patterns Used

  • Command Pattern: Encapsulates requests as objects.

  • Service Locator (via IoC): Used within the Manager to resolve commands.

  • Facade: The CommandManager acts as the single point of entry for the Core library.

✨ Key Features

  • Undo Support: Every command is reversible. The system uses a LIFO (Last-In-First-Out) stack to track operations.

  • Modern DI (.NET 10): Leverages Keyed Services to resolve commands dynamically at runtime based on user input.

  • Type Safety: Uses Enums for command identification instead of error-prone magic strings.

  • Unit Tested: Isolated testing of the Command Manager.

Supported Commands

Command Description
increment Adds 1 to the current value.
decrement Subtracts 1 from the current value.
double Multiplies the current value by 2.
randadd Adds a random number (1-100) to the value.
undo Reverts the last operation.
exit Terminates the application.

πŸš€ Getting Started

Prerequisites

βœ… .NET 9.0 SDK (or later)

βœ… Visual Studio 2022 / VS Code

πŸ§ͺ Testing

The solution includes xUnit tests that verify the internal logic of the core library.

🀝 Contributing

Contributions are welcome! Please ensure that any PR maintains the "Green" status of the Tests.

✍️ Author

Aman Toumaj Senior Software Developer & Architecture Enthusiast

Medium