Engineering Practices in AI-Assisted Programming: From Explanation to Verification
This article explores engineering practices for intelligent programming collaboration, emphasizing that reliable execution and verification are more important than fluent explanations. It introduces a structured workflow that includes establishing task contracts before AI deployment, separating business semantics from computed data in mobile measurement tools, and running trusted simulations for tower defense games. Additionally, the piece discusses verifying rendering performance separately from game logic, implementing cross-review mechanisms to challenge assumptions, and evaluating collaboration based on total delivery cost. By building a complete evidence chain—where requirements have boundaries, solutions are implementable, results are reproducible, and failures are reversible—AI assistance can truly transition from merely participating in discussions to undertaking engineering work.
1. The Core Problem of AI-Assisted Programming: It’s Not About “Who is Smarter”
In real-world development, explaining clearly and executing reliably are two distinct capabilities.
A well-structured, fluently written optimization proposal might fail to verify critical assumptions, while a rigid analysis full of implementation details might accurately pinpoint boundary defects. Therefore, evaluating AI programming assistants should not rely solely on conversational experience, nor should performance in a single task be generalized into an overall capability ranking.
A more reasonable approach is to break down the workflow into four phases:
- Understand Requirements: Identify user goals, constraints, and actual usage scenarios.
- Design Solutions: Propose implementable architectures, processes, and modification scopes.
- Execute Verification: Confirm the solution through code review, testing, measurement, or simulation.
- Explain Deliverables: Clarify the reasons for changes, applicable boundaries, risks, and rollback methods.
These four phases are interrelated but cannot replace one another. Being good at describing a solution does not prove its effectiveness; being able to run numerous experiments does not mean the experimental design is sound.
From an engineering perspective, the most critical focus is not the assistant’s “personality,” but whether the workflow can connect requirements, code, evidence, and acceptance criteria.
2. Establish a Task Contract Before Letting the AI Act
Much inefficient collaboration stems not from a lack of capability, but from poorly defined tasks.
For example, “make the floor measurement tool faster” could include at least three goals: reducing scan wait time, improving floor plan editing smoothness, or shortening report export time. These involve different data paths and require different optimization methods. Without clarifying the scope first, the AI assistant can easily invest significant effort into the wrong problem.
An effective task specification should include:
- Business Goals: Where and what obstacles users encounter.
- Inputs and Outputs: Where the operation begins and what the result should be upon completion.
- Constraints: Compatibility, offline requirements, data precision, resource budget, and security needs.
- Allowed Modification Scope: Which modules can be modified and which public contracts must remain stable.
- Acceptance Criteria: What tests, data, and measurement methods will determine success.
Acceptance criteria are particularly crucial. Instead of simply writing “better experience,” describe observable behaviors: “When a user continuously modifies wall dimensions, the view should remain responsive; export tasks must not block editing; if export fails, completed measurement data should be retained.”
Performance metrics should be established after setting a baseline, rather than arbitrarily filling in an improvement percentage just to sound specific.
3. Scenario: Mobile Floor Measurement Tool — Separate Business Semantics from Computed Results
A typical workflow for a mobile floor measurement tool includes spatial capture, geometric reconstruction, dimension annotation, photo association, and report generation. The difficulty lies not only in computational complexity but also in potential conflicts among multiple data sources.
3.1 Automatic Estimates and Manual Measurements Should Not Overwrite Each Other
Spatial sensors can provide geometric estimates, but these do not necessarily equate to precise on-site measurements. In practice, you should distinguish between:
- Raw geometric data captured by scans;
- Dimension estimates calculated by the system;
- Actual dimensions manually input by users;
- Derived data generated for display and export.
If this information is mixed into the same field, a rescan or recalculation could overwrite manually confirmed data.
A more robust design preserves the data source, modification status, and association relationships, while explicitly defining conflict resolution rules. For instance, should manually confirmed dimensions take priority in reports? Should the geometric view adjust synchronously with actual measurements? If adjusted, should the system prompt that the graphic no longer fully corresponds to the original scan?
These rules are product decisions first and code implementations second. An AI assistant can help list options, but it cannot decide data semantics for the developer without confirmation.
3.2 Entity Identity Must Remain Stable
The association between walls, rooms, and photos cannot rely simply on the current position in a collection. After geometric reorganization, the element order might change, causing a photo originally attached to one wall to link to another.
Therefore, business entities require stable identifiers. When geometric reconstruction causes entities to merge, split, or be deleted, migration rules must be defined:
- When two walls merge, how are original dimensions and photos retained?
- When a wall splits, to which part do annotations belong?
- For old data that cannot be reliably matched, should the system prompt the user for confirmation or enter a pending state?
The goal here is not to require the system to match automatically at all times, but to avoid silently establishing incorrect associations when uncertain.
3.3 Performance Optimization Should Measure the Complete Chain
“Page stuttering” does not directly prove that rendering is the bottleneck. The cause could be geometric calculations, image decoding, frequent state updates, file writing, or multiple tasks competing for the same execution resources.
A measurement chain should be established along user operations:
Operation input → Data update → Geometric calculation → View refresh → File generation.
Record duration, call frequency, and resource changes for each stage before deciding where to optimize. Common measures include:
- Moving heavy calculations out of the critical execution path of the UI;
- Merging calculations triggered repeatedly within a short timeframe;
- Updating only the local data that has changed;
- Generating appropriately sized images for previews;
- Setting capacity limits and invalidation rules for caches;
- Providing progress, cancellation, and failure recovery mechanisms for long-running tasks.
Note that asynchronous execution does not automatically solve consistency problems. If an older calculation returns later than a newer one, it might overwrite the current state with stale results. Implementation should verify result validity based on task or data version.
4. Scenario: Tower Defense Game — Numerical Analysis Must Rely on Trusted Simulations
Game balance issues can easily be misled by a seemingly precise spreadsheet.
Unit attack power, attack interval, range, and price do support preliminary analysis, but actual combat is also influenced by pathfinding, target selection, damage overflow, attack timing, and resource acquisition rhythm. Comparing only static panels cannot prove that a strategy is stronger in actual levels.
4.1 Prioritize Reusing Real Combat Rules
Simulations used for numerical validation should reuse actual combat logic as much as possible, including:
- Enemy movement and arrival judgment;
- Defense unit target selection;
- Attack cooldown and damage settlement;
- Area-of-effect attacks and status effects;
- Resource consumption and acquisition;
- Win/loss conditions.
Graphics and sound effects can be removed to improve runtime efficiency, but rules determining combat outcomes cannot be arbitrarily simplified. Otherwise, no matter how fast the simulation runs, it might just be efficiently computing a system inconsistent with the actual game.
Furthermore, the simulator itself requires validation. Select several fixed scenarios and compare key events and final results between visualized runs and headless (no graphics) runs to confirm that both use consistent rules.
4.2 Experiment Quantity Cannot Replace Coverage
Running a large number of repetitions is only meaningful if the input design is reasonable. If the same defensive layout, same path, and same enemy configuration are always used, increasing the number of runs will not cover new problems.
An experiment matrix should be established first, covering:
- Resource conditions at different stages;
- Single unit vs. mixed unit combinations;
- Different enemy types;
- Different timing for building, upgrading, and selling;
- Different paths and placement positions;
- Multiple random seeds.
For experiments involving randomness, record seeds and parameter versions. When comparing two solutions, use identical input conditions as much as possible to avoid misinterpreting random fluctuations as improvements. If the system is entirely deterministic, repeating identical inputs mainly checks consistency rather than expanding conclusion credibility.
4.3 Don’t Just Look at Win Rates
Win rates reflect outcomes but cannot fully explain the process. Two combinations might have similar win rates, but one might rely on early investment while the other dominates in the late game.
You should simultaneously observe:
- Remaining health or key objective status;
- Resource consumption;
- Effective damage vs. overflow damage;
- Enemy breach positions;
- Survival rates at different stages;
- Yield gaps between different strategies.
If one combination is superior across a wide range of scenarios, a dominant strategy might exist. However, the solution isn’t necessarily just reducing attack power; it could also involve adjusting price, attack interval, applicable targets, or resource curves. After modifications, rerun the complete experiment matrix to check for new imbalances.
5. Verify Rendering Performance and Game Logic Separately
Faster game logic simulation does not mean smoother graphics. Logic correctness and rendering performance should serve as two separate verification chains.
Rendering issues must be measured in an environment close to real-world conditions, focusing on:
- Frame time distribution and high percentiles;
- Sustained fluctuations under high-load scenarios;
- Object creation and destruction frequency;
- Transparency effects, particles, and overdraw;
- Image resource consumption;
- Memory and temperature changes after prolonged runtime.
Average frame rates can mask short-term stuttering, so worst-case scenarios and frame time spikes should also be examined. If object reuse is used to reduce allocations, the reuse pool size must be limited simultaneously. If effects are reduced to lower the load, confirm that key visual information like attack range and hit feedback is not lost.
Effective optimization is not about making a single metric look impressive, but maintaining an acceptable balance among performance, readability, and gameplay feedback.
6. Cross-Review: Let Solutions Face Disproof, Not Mutual Echoing
The most valuable division of labor in AI collaboration is separating “proposing solutions” from “verifying solutions.”
Phase 1: Design
Design tasks should require outputting requirement understanding, data flow, modification scope, risks, and acceptance methods. Any unconfirmed business rules should be explicitly marked as pending decisions.
Phase 2: Review
Review tasks should target specific solutions and code, looking for reproducible issues:
- Which premise is not yet established?
- Which input would cause the result to fail?
- Is data intact after an abnormal interruption?
- Can concurrent tasks overwrite each other?
- Can the cache return stale results?
- Are new and old data compatible?
Review conclusions should provide at least the trigger conditions, impact, and verification methods. A mere “there might be an issue here” is insufficient to support changes.
Phase 3: Evidence Delivery
Upon implementation completion, deliver a modification list, test results, performance comparisons, and unresolved risks. All conclusions should distinguish between “verified by execution,” “inferred from code only,” and “pending verification.”
Execution logs, test artifacts, and measurement records are more credible than an assistant merely claiming “optimization complete.” If the execution environment is unavailable, state the limitations explicitly; do not use speculation to masquerade as test results.
7. Evaluate Collaboration Based on Total Delivery Cost
The cost of intelligent programming includes not just API call fees, but also the time spent reading explanations, providing context, fixing errors, running experiments, and handling regressions.
A practical evaluation method is to track per task:
- Total time from task definition to acceptance;
- Number of manual corrections required;
- Rework volume after initial delivery;
- New defects and their impact;
- Completeness of verification evidence;
- Future maintainability of the solution.
These records reflect actual ROI better than a “stunning performance” in a single demo.
Meanwhile, when AI assistants execute code and modify projects, they should follow the principle of least privilege. Conduct experiments in isolated environments first; use desensitized samples for sensitive data; retain rollback versions before batch changes; and require developer confirmation for critical business rules and deployment operations.
8. Conclusion: Let Expression Serve Decisions, Let Experiments Support Conclusions
Reliable intelligent programming collaboration is not about choosing an assistant that is always right, but about establishing a process that can discover errors, verify assumptions, and control risks.
For mobile tools, the focus is on clarifying data semantics, stabilizing associations, and locating real bottlenecks. For game systems, the focus is on reusing real rules, designing comprehensive experiments, and validating numerical balance and rendering performance separately.
Ultimately, what is worth delivering is not a beautiful explanation, nor an isolated experimental figure, but a complete evidence chain: requirements have boundaries, solutions are implementable, results are reproducible, and failures are reversible. Only by forming this chain can AI assistance truly transition from “participating in discussions” to “undertaking engineering work.”
