Key points are not available for this paper at this time.
Refactoring by design patterns is difficult to do in practice as it requires inferring and enforcing architectural intent across multiple abstractions while maintaining correct behavior. Managing these abstraction layers has been a challenge for automated approaches to address in a controlled and unified way. Prior work addresses smell detection, pattern recommendation, and refactoring largely in isolation, lacking an end-to-end workflow that integrates role-level planning with systematic validation. This article presents PatternForge, a multi-agent large language model framework for architecture-level refactoring that transforms code smells into canonical design-pattern implementations through an explicit, staged reasoning and validation pipeline. PatternForge decomposes refactoring into specialized agents responsible for architectural diagnosis, pattern selection, role-level planning, structural transformation, and validation. By explicitly constraining architectural intent prior to code generation and coupling transformation with bounded validation and recovery, the framework enables more controlled and interpretable refactoring than metric-driven or single-agent approaches. Quantitative results are reported on 72 controlled instances; four additional real-world cases are used solely for qualitative analysis. We evaluate PatternForge using a controlled capability study on a curated benchmark covering six representative code smells—Long Method, God Class, Feature Envy, Switch Statement, Data Class, and Duplicated Code—across three complexity levels and two statically typed languages, Java and C#. We report compilation success ratio and test-pass ratio conditional on successful compilation separately; instances that fail compilation are excluded from test execution and are counted only in compilation statistics. Traditional structural metrics are reported to characterize architectural trade-offs rather than being treated as direct optimization objectives. PatternForge compiled all but one of the 72 refactored instances. Architecturally relevant results were rated as High, Medium, and Low according to Pattern Conformance Level. The non-compiled instance was due to incomplete pattern implementation rather than behavioral failure. Across the benchmark, PatternForge preserves observed program behaviors under the provided test suites, achieving high compilation success ratios while producing refactorings with a higher Pattern Conformance Level than ablated variants and single-agent baselines. Ablation analysis demonstrates that explicit architectural planning primarily determines pattern conformance level, whereas systematic validation is essential for behavioral reliability, highlighting their complementary roles in architecture-level refactoring. These results suggest that multi-agent decomposition with plan-grounded validation provides a practical and controllable foundation for pattern-driven refactoring in statically typed software systems.
Fatma Gülşah Tan (Thu,) studied this question.
Synapse has enriched 5 closely related papers on similar clinical questions. Consider them for comparative context: