🏠 Home
Benchmark Hub
📊 All Benchmarks 🦖 Dinosaur v1 🦖 Dinosaur v2 ✅ To-Do List Applications 🎨 Creative Free Pages 🎯 FSACB - Ultimate Showcase 🌍 Translation Benchmark
Models
🏆 Top 10 Models 🆓 Free Models 📋 All Models ⚙️ Kilo Code
Resources
💬 Prompts Library 📖 AI Glossary 🔗 Useful Links
Hard

Refactor Spaghetti Code to SOLID

#python #refactoring #clean-code #oop

Identify violations in a legacy code description and refactor it using SOLID principles.

Imagine a Python script class named 'ReportManager' that reads from a CSV, formats data to HTML, PDF, and JSON, saves to a disk, sends an email via SMTP, and logs errors to a file all within single methods. This class is 2000 lines long. 1) Identify which SOLID principles (Single Responsibility, Open/Closed, Liskov Substitution, Interface Segregation, Dependency Inversion) are being violated. 2) Provide a refactored architecture plan outlining new classes and interfaces. 3) Write the Python code for the refactored solution, ensuring dependencies are injected rather than hard-coded.