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 Waterfall model, design patterns, and multi-agent collaboration to systematically enhance cohesion, reduce coupling, and improve adaptability. We also introduce MaintainBench, a benchmark comprising requirement changes and corresponding dynamic metrics on maintainance effort. Experiments demonstrate that existing code generation methods struggle to meet maintainability standards when requirements evolve. In contrast, MaintainCoder improves maintainability metrics by 14-30% with even higher correctness, i.e. pass@k. Our work not only provides the foundation of maintainable code generation, but also highlights the need for more holistic code quality research. Resources: https://github.com/IAAR-Shanghai/MaintainCoder.
翻译:现代代码生成在功能正确性和执行效率方面已取得显著进展。然而,这些系统往往忽视了实际软件开发中的一个关键维度:可维护性。为以最小返工量应对动态需求,我们提出MaintainCoder作为开创性解决方案。该方法融合瀑布模型、设计模式与多智能体协作机制,系统性地增强内聚性、降低耦合度并提升适应能力。我们同时引入MaintainBench基准数据集,其包含需求变更场景及对应的动态可维护性度量指标。实验表明,现有代码生成方法在需求演化时难以满足可维护性标准。相比之下,MaintainCoder将可维护性指标提升14-30%,同时获得更高的功能正确性(即pass@k)。本研究不仅为可维护代码生成奠定基础,更凸显了对代码质量进行更系统性研究的必要性。项目资源:https://github.com/IAAR-Shanghai/MaintainCoder。