AI English Shift · Lessons / C02-case
Coding case: repair a misleading export
编程案例:修复误报成功的导出功能
Open the interactive lesson · 打开互动课程A fictional learning application lets a learner select glossary terms and export them for review.
一个虚构的学习应用允许学习者选择术语表条目,并将它们导出用于复习。
架空の学習アプリで、学習者が用語を選び、復習用に書き出せるとします。
A learner selects twelve terms, but the exported file contains only ten because the export function reads the currently visible page.
学习者选中了十二个术语,但导出的文件只有十个,因为导出函数读取的是当前可见页面。
学習者が12語選んでも、書き出し関数が現在表示中のページだけを読むため、ファイルには10語しか入りません。
The user interface nevertheless reports that the export succeeded.
尽管如此,用户界面仍报告导出成功。
それでも画面には書き出し成功と表示されます。
Before asking an agent to fix the code, state the required behavior: every selected term must appear once, even when selections span pages.
在让智能体修复代码之前,先说明所需行为:每个选中的术语必须恰好出现一次,即使选择跨越多个页面。
エージェントにコード修正を頼む前に、複数ページにまたがる選択でも、選んだ用語が1回ずつすべて含まれるという要件を明示します。
This acceptance criterion is more useful than an instruction to improve the export component, because it defines an observable outcome.
这个验收标准比“改进导出组件”的指令更有用,因为它定义了可观察的结果。
この受け入れ基準は、観察できる結果を定義するため、書き出し部品を改善するという指示より有用です。
Inspect the selection state, pagination logic, export function, and existing tests before proposing a change.
提出修改方案之前,应先检查选择状态、分页逻辑、导出函数和现有测试。
変更を提案する前に、選択状態、ページ分割のロジック、書き出し関数、既存テストを調べます。
Reproduce the defect with a small example containing selected terms on two pages, including one selection that is currently hidden.
用一个小例子复现缺陷:在两个页面上选择术语,其中包含一个当前不可见的选择项。
2ページに選択した用語があり、現在は見えない選択も含む小さな例で、不具合を再現します。
A focused unit test can check that the export function uses the complete selection rather than the visible page's records.
一项有针对性的单元测试可以检查导出函数是否使用了完整选择集合,而不是可见页面上的记录。
対象を絞った単体テストで、書き出し関数が表示ページの記録ではなく、選択全体を使っているか確認できます。
An integration test can check that navigation between pages preserves the selections and that the final downloaded content contains them.
集成测试可以检查切换页面时是否保留了选择,以及最终下载的内容是否包含这些选择项。
結合テストでは、ページを移動しても選択が保持され、最後にダウンロードした内容に含まれるか確認できます。
The tests should fail on the original behavior, pass after the fix, and inspect exported content rather than only a success notification.
测试应在原有行为下失败、修复后通过,并检查实际导出内容,而不只是成功通知。
テストは元の動作では失敗し、修正後には合格し、成功通知だけでなく書き出した内容を確認すべきです。
Review the diff to ensure the agent did not make the test pass by removing pagination or silently changing what selection means.
审阅代码差异,确认智能体没有通过移除分页,或悄悄改变“选择”的含义来让测试通过。
差分を読み、ページ分割を削除したり、選択の意味を黙って変えたりしてテストを通していないか確認します。
Also inspect empty selections, duplicate identifiers, and a record that becomes unavailable before export.
还应检查未选择任何条目、标识符重复,以及某条记录在导出前变为不可用的情况。
選択なし、識別子の重複、書き出し前に利用できなくなった記録も確認します。
A clear failure message should describe an incomplete export accurately rather than claim that all selected records were included.
清楚的失败提示应准确说明导出不完整,而不是宣称所有选中记录都已包含在内。
書き出しが不完全なら、すべての選択記録を含んだと主張せず、不完全であることを正確に伝えるメッセージが必要です。
The final review note should explain the trigger, the corrected behavior, the evidence from tests, and any unresolved boundary.
最终审阅说明应解释触发条件、修复后的行为、测试证据,以及仍未解决的边界情况。
最終レビューには、発生条件、修正後の動作、テストの証拠、未解決の範囲を記述します。
This workflow uses AI to support software work while keeping the specification and verification understandable to a human reviewer.
这套流程利用 AI 辅助软件工作,同时让人类审阅者仍能理解规格与验证方式。
この流れは、仕様と検証を人が理解できる状態に保ちながら、AIでソフトウェア作業を支援します。
Key terms
- Specification: A description of required behavior, constraints and acceptance criteria for a product or change.
- Regression: A previously acceptable behavior that worsens after a system change.
- Acceptance criteria: Observable conditions that a change must satisfy to count as complete.
- Repository: A version-controlled collection of project files and their recorded history.
- Diff: A representation of changes between two versions of files or other artifacts.
- Unit test: A test focused on a bounded component or unit of behavior under controlled conditions.
- Integration test: A test of interactions among components or external interfaces.