Testing New LLMs on Coding: Engineering Practices for Building a Responsive GUI Tool
This article evaluates whether new-generation large language models can deliver complete software rather than just code snippets. Using a batch audio extraction tool with a responsive GUI as a case study, it covers writing verifiable specifications, separating UI and worker threads with queues and a task state machine, handling dependency detection, naming conflicts, real progress reporting and error isolation, and running layered acceptance tests. It closes with transferable practices for turning model output into reviewable, testable engineering work.
1. Background: Why “Generating Code” Is Not the Same as “Delivering Software”
Progress in code generation over the past two years is hard to miss. Public benchmarks and engineering practice both show that new-generation models are already fairly mature on short-chain tasks such as algorithm problems and script writing. On the long chain from requirements to deliverable software, however, three problems still show up often:
- The model returns fragments and omits a complete project structure.
- It ignores runtime dependencies, so the code will not start locally.
- It puts time-consuming logic on the main thread, leaving the UI unresponsive.
So evaluating whether a model has real engineering value is not about whether it can produce syntactically correct code. It is about whether it can produce a program with a complete structure, controllable exceptions, and a usable experience under given constraints. This article uses a typical scenario: a batch tool that accepts common video formats, exports mainstream audio formats, and deliberately adds a hard constraint — the UI must not freeze.
2. Requirements Engineering: Turning a Vague Idea into an Acceptable Specification
A vague prompt only yields vague results. A reusable approach is to break requirements into four layers:
- Functional layer: which input containers and audio encodings are supported, how output target formats are enumerated, and whether recursive subdirectory scanning is allowed.
- Interaction layer: file import list, output directory selection, format dropdown, start and exit buttons, progress bar, status bar.
- Non-functional layer: UI responsiveness, cancellability, traceable logs, locatable errors.
- Environment layer: the range of supported operating systems, availability detection for external transcoding components, and a fallback message when dependencies are missing.
A skeleton prompt looks like this:
Role: senior desktop application developerGoal: implement a batch audio track extraction toolConstraints:- Use standard library GUI components; do not pull in a heavy framework- All time-consuming work must be moved off the main thread- Must provide progress feedback, a status bar, and an error list- Append an incrementing suffix automatically when an output file name already exists; overwriting is forbidden- On startup, detect whether the external transcoding component is available; show installation guidance if it is missingAcceptance: recursive directory scanning, batch conversion, cancellation, and error reporting must all work
Writing the acceptance criteria into the prompt is the key to a higher first-pass success rate. It effectively hands the model a checklist of test cases, so the generation process carries its own self-check target.
3. Architecture: Threads, Queues, and a Task State Machine
The root cause of a freezing desktop program is almost always the same: a time-consuming operation occupies the event loop. The correct approach is to separate the UI thread from the worker thread and pass tasks and results through a thread-safe queue.
A minimal layered structure:
- Data layer: a task object describes the source file, target format, target path, and status.
- Scheduling layer: a producer puts tasks into the queue; consumer threads take them out one by one and execute them.
- Execution layer: calls the external transcoding component to demux and encode, and parses its output to compute progress.
- Presentation layer: the main thread polls the queue on a timer and updates the progress bar and status bar.
Sample code:
import queueimport threadingtask_q = queue.Queue()event_q = queue.Queue()def worker():while True:task = task_q.get()if task is None:task_q.task_done()breaktry:event_q.put(("start", task.name))# Call the external transcoding component and parse progress outputevent_q.put(("progress", 100))event_q.put(("done", task.name))except Exception as exc:event_q.put(("error", (task.name, str(exc))))finally:task_q.task_done()threading.Thread(target=worker, daemon=True).start()
On the UI side, you only need to pull events periodically and render them:
def poll():while not event_q.empty():kind, payload = event_q.get_nowait()if kind == "progress":bar.set(payload)elif kind == "error":status.set(f"Failed: {payload[0]}, reason: {payload[1]}")root.after(100, poll)
This “producer–consumer plus event callback” structure supports cancellation naturally: insert a sentinel object into the task queue and check a cancellation flag in the execution layer.
4. Key Details: The Engineering Constraints That Decide Whether It Is Usable
- Dependency detection and fallback. Batch transcoding usually depends on an external command-line component. The program should probe for it at startup and show clear guidance if it is missing, instead of throwing an obscure error only after the button is clicked.
- Naming conflict handling. Batch tasks easily produce duplicate output names. The strategy is to append an incrementing suffix before the extension and check for existence before writing, avoiding parameters that silently overwrite.
- Progress authenticity. Progress should come from parsing transcoder output or estimating the file write ratio, not from a fake animation that increments on a timer; otherwise long tasks seriously mislead users.
- Error isolation. A single failed file should not abort the whole batch. Keep a failure list, present it after the run, and support exporting logs.
- Encoding and path compatibility. Chinese characters, spaces, and special symbols in paths are common crash sources. Build command arguments as a list rather than concatenating strings, which also avoids injection and truncation.
- Resource release. Threads, child processes, and temporary files must be reclaimed on exception paths so that leftover processes do not hold handles after a batch run.
5. Acceptance: From “Looks Like It Runs” to “Actually Reliable”
Four layers of acceptance are recommended:
- Syntax and static checks: compile first, then check for undefined variables and unused imports.
- Empty-environment and missing-dependency test: start on a machine without the external component and confirm the message is friendly and nothing crashes.
- Functional matrix test: multiple input formats × multiple output formats × subdirectories included × duplicate file names, covering combinations.
- Experience test: build a long task with hundreds of files and observe whether the UI stays responsive, whether cancellation takes effect immediately, and whether memory stays flat.
An executable acceptance snippet:
cases = [("single.mp4", "mp3"),("folder/sub/a.mkv", "wav"),("dup.mp4", "mp3"), # duplicate name conflict]for src, fmt in cases:assert build_plan(src, fmt) is not None
6. Transferable Engineering Conclusions
This exercise shows that the value of a model is not writing all the code for you, but turning a specification into structure. It is good at filling in engineering details that are easy to miss — recursive scanning, format enumeration, suffix-based overwrite prevention, dependency pre-checks — while the threading model, cancellation semantics, error isolation, and acceptance criteria still need explicit constraints from the developer.
Three practices are reusable for teams. First, write prompts like interface documentation, with clear inputs, constraints, and acceptance criteria. Second, put non-functional requirements up front, especially responsiveness and cancellability. Third, bring generated results into the normal code review and automated testing flow. For large-scale task scheduling, log retention, and monitoring and alerting, general cloud capabilities such as container platforms, log services, and monitoring and alerting can carry the load; Baidu AI Cloud offers corresponding product categories in this general engineering foundation area, which can serve as a reference for architecture selection.
