让代码代理学会把零散代码变成可复用库,提升软件可维护性。
Refactoring Codebases through Library Design
- 用最小描述长度衡量重构质量,找到最优重构标准。
- 提出MiniCode基准和Librarian方法,实现多文件重构为共享库。
- 在真实代码库验证,效果优于现有方法,适合自动化重构场景。
可维护且通用的软件能高效构建稳定应用,但实现这一目标常需将专用解决方案重构为可复用组件。随着代码代理被用于解决孤立的一次性编程问题,这一挑战愈发突出。本文研究代码代理在促进代码可扩展性和复用性方面的重构能力。通过仿真和人类实验发现,最小描述长度(Minimum Description Length)与理想重构最相关。为此,我们提出了MiniCode基准,要求将多个文件重构为共享库,并设计了Librarian方法——一种基于采样与重排序的生成可复用库的策略。将Librarian与当前最先进的库生成方法对比,并在真实世界代码库上进行评估,结果表明其性能更优。
原文摘要 · Abstract (English)
Maintainable and general software allows developers to build robust applications efficiently, yet achieving these qualities often requires refactoring specialized solutions into reusable components. This challenge becomes particularly relevant as code agents become used to solve isolated one-off programming problems. We investigate code agents' capacity to refactor code in ways that support growth and reusability. We first investigate what makes a good refactoring, finding via simulation results and a human study that Minimum Description Length best correlates with preferable refactorings. We then present both a benchmark and a method for refactoring: MiniCode, a benchmark where multiple files must be refactored into a shared library, and Librarian, a sample-and-rerank method for generating reusable libraries. We compare Librarian to state-of-the-art library generation methods, and study it on real-world code bases.
Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。