Usage of formalized knowledge about source code for refactoring actions in Swift
DOI:
https://doi.org/10.15587/2706-5448.2022.267160Keywords:
Swift programming language, knowledge base, analysis and refactoring tools, open-source codeAbstract
The object of research in the paper is the source code of a software product written in the Swift programming language. Most programs as a product of a certain project during the life cycle require changes and modifications, which is costly or impossible to implement in the case of poor code quality. One of the options for solving the problem of poor code quality is the timely application of refactoring principles. The existing problem is that implementation of high-level refactoring must be done manually by the developer without the use of automated tools as built-in solutions cannot fulfill the need due to the architectural complexity of the product.
To reduce the number of errors made during refactoring, to simplify the process of performing routine actions, it is suggested to use a new software product for refactoring. It works with high-level user commands based on a formalized description of the source code together with a knowledge base containing a description of code entities and their properties (what specific actions can be performed with them). In the work, the refactoring of the source code was carried out using the example of the Swift programming language. The proposed approach of component architecture (knowledge base, software engine) further allows to expand the functionality of the software product to other programming languages.
The work was directed to the development of a prototype of a software product using the proposed approach to check and compare the results with other refactoring tools. A command line utility has been developed that accepts a verbal command as an input and outputs the results of processing and analysis of the source code (search for complex structures in the code) or applies the proposed change. As a result of the conducted testing, it was established that the use of the proposed approach allows performing complex refactoring tasks with the help of a simple verbal formalized command. Accomplishing the same task using only the built-in refactoring tools requires significantly more time and effort or is impossible at all.
References
- Swift Documentation. Swift Local Refactoring. Available at: https://www.swift.org/blog/swift-local-refactoring/
- Lacerda, G., Petrillo, F., Pimenta, M., Guéhéneuc, Y. G. (2020). Code smells and refactoring: A tertiary systematic review of challenges and observations. Journal of Systems and Software, 167. doi: https://doi.org/10.1016/j.jss.2020.110610
- Almogahed, A., Omar, M., Zakaria, N. H. (2022). Refactoring Codes to Improve Software Security Requirements. Procedia Computer Science, 204, 108–115. doi: https://doi.org/10.1016/j.procs.2022.08.013
- Code refactoring best practices. Available at: https://www.altexsoft.com/blog/engineering/code-refactoring-best-practices-when-and-when-not-to-do-it/
- Kaur, S., Singh, P. (2019). How does object-oriented code refactoring influence software quality? Research landscape and challenges. Journal of Systems and Software, 157. doi: https://doi.org/10.1016/j.jss.2019.110394
- Fowler, M. (1999). Refactoring. Improving the Design of Existing Code. Addison-Wesley, 63.
- Morales, R., Soh, Z., Khomh, F., Antoniol, G., Chicano, F. (2017). On the use of developers’ context for automatic refactoring of software anti-patterns. Journal of Systems and Software, 128, 236–251. doi: https://doi.org/10.1016/j.jss.2016.05.042
- Don, R., Brant, J. Refactoring tools. Available at: http://www.laputan.org/pub/patterns/fowler/Roberts-Brant.doc
- De Nicola, R., Di Stefano, L., Inverso, O., Uwimbabazi, A. (2022). Automated replication of tuple spaces via static analysis. Science of Computer Programming, 223. doi: https://doi.org/10.1016/j.scico.2022.102863
- Hammad, M., Babur, Ö., Basit, H. A., van den Brand, M. (2022). Clone-Writer: An effective editor for developing code by using code clones. Software Impacts, 13. doi: https://doi.org/10.1016/j.simpa.2022.100323
- Al Dallal, J. (2012). Constructing models for predicting extract subclass refactoring opportunities using object-oriented quality metrics. Information and Software Technology, 54 (10), 1125–1141. doi: https://doi.org/10.1016/j.infsof.2012.04.004
- Swift Syntax Command Line Tool (2019). Available at: https://www.pointfree.co/episodes/ep55-swift-syntax-command-line-tool
- Almeida, L. (2019). An Overview of SwiftSyntax. Available at: https://medium.com/@lucianoalmeida1/an-overview-of-swiftsyntax-cf1ae6d53494
- Mattt (2018). SwiftSyntax. Available at: https://nshipster.com/swiftsyntax/
- SwiftSyntax Documentation. Available at: https://github.com/apple/swift-syntax/tree/main/Documentation
- A set of Swift bindings for the libSyntax library. Available at: https://iosexample.com/a-set-of-swift-bindings-for-the-libsyntax-library/
Downloads
Published
How to Cite
Issue
Section
License
Copyright (c) 2022 Andrii Tkachuk, Bogdan Bulakh
This work is licensed under a Creative Commons Attribution 4.0 International License.
The consolidation and conditions for the transfer of copyright (identification of authorship) is carried out in the License Agreement. In particular, the authors reserve the right to the authorship of their manuscript and transfer the first publication of this work to the journal under the terms of the Creative Commons CC BY license. At the same time, they have the right to conclude on their own additional agreements concerning the non-exclusive distribution of the work in the form in which it was published by this journal, but provided that the link to the first publication of the article in this journal is preserved.