让代码生成适应需求变化,减少重写。
MaintainCoder: Maintainable Code Generation Under Dynamic Requirements
- 融合瀑布模型与多智能体协作,提升代码可维护性
- 动态可维护性指标提升超60%,初始代码正确率更高
- 提出新评估体系,更适合真实开发场景
现代代码生成在功能正确性和执行效率上已取得显著进展,但往往忽视了实际软件开发中的关键维度——可维护性。为应对需求动态变化并最小化重写工作量,我们提出MaintainCoder,一个开创性解决方案。它结合瀑布模型、设计模式与多智能体协作,系统性提升代码内聚性、降低耦合度,实现清晰的责任边界和更好的可维护性。同时,我们构建了MaintainCoder基准数据集,包含需求变更和新型动态维护度量指标。实验表明,现有代码生成方法在需求演化时难以满足可维护性标准;而MaintainCoder在保持更高初始代码正确率的前提下,使动态可维护性指标提升超过60%。此外,静态指标无法准确反映可维护性,甚至相互矛盾,而我们的动态指标表现出高度一致性。本研究不仅为可维护代码生成奠定基础,也强调了更真实、全面的代码生成研究的必要性。
原文摘要 · Abstract (English)
Modern code generation has made significant strides in functional correctness and execution efficiency. However, these systems often overlook a critical dimension in real-world software development: maintainability. To handle dynamic requirements with minimal rework, we propose MaintainCoder as a pioneering solution. It integrates the Waterfall model, design patterns, and multi-agent collaboration to systematically enhance cohesion, reduce coupling, achieving clear responsibility boundaries and better maintainability. We also introduce MaintainCoder, a benchmark comprising requirement changes and novel dynamic metrics on maintenance efforts. Experiments demonstrate that existing code generation methods struggle to meet maintainability standards when requirements evolve. In contrast, MaintainCoder improves dynamic maintainability metrics by more than 60% with even higher correctness of initial codes. Furthermore, while static metrics fail to accurately reflect maintainability and even contradict each other, our proposed dynamic metrics exhibit high consistency. Our work not only provides the foundation for maintainable code generation, but also highlights the need for more realistic and comprehensive code generation research. Resources: https://github.com/IAAR-Shanghai/MaintainCoder.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。