Journal of Software: Evolution and Process Программное обеспечение

Refactoring Swift: A Catalog of 10 Essential Practices for Code Improvement

Mohamed Rafat, Mohammed El‐Ramly, Lamia Abo Zaid
Wiley · 2026-11-01 · DOI 10.1002/smr.70180

Аннотация

ABSTRACT Code refactoring is crucial for maintaining a clean and efficient codebase, thereby enhancing readability, reducing complexity, and improving maintainability. Refactoring catalogs provide a grouping of frequent and crucial refactorings, making available reusable solutions to recurring problems. Despite its popularity, Swift lacks such a standardized resource. Furthermore, Swift code undergoes frequent updates due to the rapid pace associated with mobile application development. This practice necessitates refactoring to maintain code quality. However, the lack of a standardized resource for refactoring leads to inconsistent, ad hoc practices among developers, potentially resulting in more harm than good. This paper addresses this gap by introducing a Swift‐specific refactoring catalog derived from an empirical analysis of 10 popular open‐source Swift repositories. Through this analysis, we identified and documented the most essential recurrent refactoring types that leverage Swift‐specific features, such as protocols and extensions. Each entry in the catalog is presented in a structured format: a clear problem context, a step‐by‐step solution, and a “before‐and‐after” code example, supplemented by design diagrams. We validated the proposed catalog through an exploratory expert survey with 16 Swift developers. The results strongly confirm the catalog's value. The expert panel validated the importance, clarity, and significance of the presented refactorings and confirmed a broad consensus on their effectiveness and value in enhancing overall code quality. This work provides a practical, validated resource to help Swift developers improve code quality and maintainability.

Читать у издателя →