Advanced
Legacy Spaghetti Code Refactoring
Analyze a monolithic legacy code snippet and propose a refactoring strategy to improve maintainability and testability.
📝 Prompt Content
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.