This directory contains practice exercises to help you apply SOLID principles in different programming languages.
The OrderProcessor class violates multiple SOLID principles. Your task is to refactor it to follow all five SOLID principles:
- Single Responsibility Principle
- Open/Closed Principle
- Liskov Substitution Principle
- Interface Segregation Principle
- Dependency Inversion Principle
OrderProcessor.cs- C# implementationOrderProcessor.java- Java implementationorder_processor.py- Python implementationorder_processor.rb- Ruby implementationOrderProcessor.ts- TypeScript implementation
- Choose your preferred language
- Review the code in the corresponding file
- Identify which SOLID principles are being violated
- Refactor the code to follow all SOLID principles
- Consider how each principle applies to this example
The current OrderProcessor class:
- Handles multiple responsibilities (validation, calculation, persistence, notification)
- Uses hard-coded dependencies
- Contains magic strings and numbers
- Is difficult to test and extend
Think about how you can:
- Separate concerns into different classes
- Use dependency injection
- Create abstractions for extensibility
- Make the code more testable
Good luck! 🚀