advanced
Refactor Spaghetti Code into SOLID Principles
Analyze a poorly structured monolithic function and refactor it into a modular architecture adhering to SOLID principles.
📝 Prompt Content
You are a Senior Software Engineer specializing in clean code and architectural design. Analyze the following legacy code snippet which suffers from tight coupling, god object anti-pattern, and lack of abstraction. Refactor the code into a language-agnostic pseudo-code structure that adheres strictly to SOLID principles. Specifically, break it down into distinct classes with clear responsibilities, utilize dependency injection where appropriate, and implement design patterns (such as Strategy or Factory) to eliminate conditional logic sprawl. Provide the refactored architecture and a brief explanation of how each SOLID principle is applied in your solution.