Quiz collegato alla guida · Difficile Livello
How to Refactor Legacy Code with AI Quiz
Practice behavior-preserving refactoring with AI by establishing baselines, making small changes, and testing edge cases.
Domanda 1 di 8
Una funzione legacy non ha alcuna specifica scritta. Cosa dovrebbe acquisire un team prima di modificarne la struttura?
Anteprima di ogni domanda8 domande
Le risposte e le spiegazioni vengono visualizzate mentre rispondi al quiz.
- Una funzione legacy non ha alcuna specifica scritta. Cosa dovrebbe acquisire un team prima di modificarne la struttura?
- Current observable behavior with tests or representative fixtures
- Only the model’s summary of what the function should do
- A shorter replacement implementation
- The number of lines removed
- Una proposta dell'intelligenza artificiale estrae una funzione di supporto e modifica il modo in cui viene gestito l'input non valido. Qual è il piano di revisione più sicuro?
- Merge both because the new code is cleaner
- Delete the malformed-input tests
- Assume the behavior change is required by refactoring
- Separate the structural refactor from the behavior change and review each on its own
- Perché un test generato da un modello non costituisce automaticamente la prova che un refactoring è sicuro?
- Tests cannot be run after refactoring
- It may encode the same mistaken assumption as the generated implementation
- AI-generated tests always fail
- A test suite makes behavior irrelevant
- Un refactoring modifica l'ordine di iterazione per i record restituiti e un client a valle dipende da quel ordine. Quale rischio ha evidenziato la modifica?
- Only the function’s internal naming changed
- The source file became easier to navigate
- An observable behavior or compatibility contract may have changed
- The tests now run faster
- Quale modello di lavoro limita al meglio il rischio quando si chiede all'intelligenza artificiale di effettuare il refactoring di un modulo sconosciuto?
- One small transformation, full diff review and focused tests before the next step
- A complete rewrite followed by one final test run
- Accept every suggestion and review only changed filenames
- Combine feature work and cleanup in one opaque patch
- A test calls a live external service whose response changes over time. What can make the characterization test more dependable?
- Increase the number of retries until it passes
- Remove all assertions
- Ask AI to predict the service’s next response
- Use a deterministic test double or recorded fixture for the external interaction
- After helper extraction, the focused tests pass. What should happen before merging?
- Assume every possible behavior is preserved
- Run broader checks and inspect compatibility, side effects and representative edge cases
- Skip review because the diff is small
- Delete tests that document old behavior
- A reviewer finds that “cleaned up” code now logs less information on failures. What is the relevant next question?
- Whether the assistant used a modern syntax feature
- Whether the refactor reduced line count
- Whether logging is an observable operational behavior the system needs to preserve
- Whether comments can be generated automatically