1.9 KiB
1.9 KiB
StrategySort-MVC-WinForms
A lightweight C# WinForms application that demonstrates string sorting using various algorithms. This project implements the Strategy Pattern for algorithm selection and the MVC (Model-View-Controller) Pattern to ensure a clean separation of concerns.
🚀 Features
- Custom String Sorting: Input any text and sort its characters alphabetically.
- Multiple Algorithms: Choose between Bubble Sort, Merge Sort, and Quick Sort.
- Architectural Excellence: Built using MVC and Strategy design patterns.
- Robustness: Includes a dedicated Unit Test project to ensure sorting accuracy.
🛠 Architecture
This project is designed with scalability and maintainability in mind:
1. Strategy Pattern
The sorting logic is decoupled from the main application. Each algorithm implements a common ISortStrategy interface, allowing the program to swap sorting behaviors at runtime without changing the client code.
2. MVC Pattern
- Model: Handles the data logic and the execution of the sorting strategies.
- View: The WinForms interface (
TextSortWindow) which captures user input and displays results. - Controller: Acts as the bridge between the View and the Model, processing user commands and updating the UI.
📸 How It Works
- Input: Enter any string into the text box (e.g.,
github). - Select Strategy: Choose a sorting algorithm from the ComboBox:
Bubble SortMerge SortQuick Sort
- Sort: Click the Sort button.
- Output: The sorted result (e.g.,
bgghitu) appears in the output label.
🧪 Unit Testing
The solution includes a Testing project using MSTest to validate the sorting logic.
- Tests verify character sorting for empty strings, special characters, and long strings.
- Ensures all three strategies return consistent results.