Code modification requires developers to comprehend code, plan changes, articulate intent, and validate outcomes, making it cognitively demanding. While natural language (NL) code summaries offer a promising external representation of this process, existing approaches remain limited. Systems grounded in exploratory data analysis are restricted to narrow domains, while general-purpose systems enforce fixed NL representations and assume that developers can directly translate vague intent into precise textual edits. We present NaturalEdit, which treats NL code summaries as interactive representations tightly linked to source code. Grounded in the Cognitive Dimensions of Notations, NaturalEdit introduces three key features: (1) adaptive, multi-faceted code summaries with a flexible Abstraction Gradient; (2) interactive mapping mechanisms between summaries and code that ensure tight, structurally stable Closeness of Mapping; and (3) intent-driven bidirectional synchronization that reduces Viscosity during editing while preserving Visibility and Consistency through incremental diffs. A technical evaluation confirms the viability of NaturalEdit, and a user study with 20 developers shows that it improves comprehension, intent articulation, and validation while increasing developers' confidence and sense of control.
翻译:代码修改要求开发者理解代码、规划变更、表达意图并验证结果,这一过程对认知能力要求极高。尽管自然语言代码摘要为此过程提供了有前景的外部表示方法,但现有方法仍存在局限。基于探索性数据分析的系统局限于狭窄领域,而通用系统则强制使用固定自然语言表示,并假设开发者能够将模糊意图直接转化为精确文本编辑。我们提出NaturalEdit,将自然语言代码摘要视为与源代码紧密关联的交互式表示。基于符号认知维度理论,NaturalEdit引入三个关键特性:(1)具有灵活抽象梯度的自适应多层面代码摘要;(2)摘要与代码之间的交互映射机制,确保紧密、结构稳定的映射贴近性;(3)意图驱动的双向同步,通过增量差异减少编辑过程中的粘滞性,同时保持可见性和一致性。技术评估证实了NaturalEdit的可行性,针对20名开发者的用户研究表明,该方法能提升理解、意图表达和验证能力,同时增强开发者的信心和掌控感。