Cuestionario vinculado a una guía · duro Nivel
How to Refactor Legacy Code with AI Quiz
Practice behavior-preserving refactoring with AI by establishing baselines, making small changes, and testing edge cases.
Pregunta 1 de 8
Una función heredada no tiene ninguna especificación escrita. ¿Qué debe capturar un equipo antes de cambiar su estructura?
Vista previa de cada pregunta8 preguntas
Las respuestas y explicaciones aparecen a medida que realiza el cuestionario.
- Una función heredada no tiene ninguna especificación escrita. ¿Qué debe capturar un equipo antes de cambiar su estructura?
- 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 propuesta de IA extrae un ayudante y cambia la forma en que se manejan las entradas con formato incorrecto. ¿Cuál es el plan de revisión más seguro?
- 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
- ¿Por qué una prueba generada por un modelo no prueba automáticamente que una refactorización sea segura?
- 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
- Una refactorización cambia el orden de iteración de los registros devueltos y un cliente posterior depende de ese orden. ¿Qué riesgo expuso el cambio?
- 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
- ¿Qué patrón de trabajo limita mejor el riesgo cuando se le pide a la IA que refactorice un módulo desconocido?
- 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