🏠 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
Advanced

Legacy Spaghetti Code Refactoring

#refactoring #legacy-code #clean-code #design-patterns

Analyze a monolithic legacy code snippet and propose a refactoring strategy to improve maintainability and testability.

You are presented with a hypothetical 500-line monolithic function written in a mix of C++ and procedural styles that handles flight booking logic. It contains global variables, goto statements, and deeply nested conditionals. Provide a step-by-step refactoring plan to convert this into a modular, object-oriented structure. Specifically, identify the 'Extract Method,' 'Replace Conditional with Polymorphism,' and 'Introduce Null Object' opportunities. Write the final refactored class pseudocode and explain how each change reduces cyclomatic complexity.