Refactoring is the process of restructuring existing computer code without changing its external behavior. Refactoring aims to improve the design, structure, and implementation of software while preserving its functionality. While classical programs have benefited from various refactoring methods, the field of quantum programming lacks dedicated refactoring techniques. This paper bridges this gap by presenting a preliminary catalog of refactorings designed for quantum programs in Q#. The paper also highlights the importance of tool support in automating the refactoring process for quantum programs.
Refactoring is the process of restructuring existing computer code without changing its external behavior. Refactoring aims to improve the design, structure, and implementation of software while preserving its functionality. While classical programs have benefited from various refactoring methods, the field of quantum programming lacks dedicated refactoring techniques. This paper bridges this gap by presenting a preliminary catalog of refactorings designed for quantum programs in Q#. The paper also highlights the importance of tool support in automating the refactoring process for quantum programs.
Refactoring is a crucial technique for improving the efficiency and maintainability of software by restructuring its internal design while preserving its external behavior. While classical programs have benefited from various refactoring methods, the field of quantum programming lacks dedicated refactoring techniques. The distinct properties of quantum computing, such as quantum superposition, entanglement, and the no-cloning principle, necessitate specialized refactoring techniques. This paper bridges this gap by presenting a comprehensive set of refactorings specifically designed for quantum programs. Each refactoring is carefully designed and explained to ensure the effective restructuring of quantum programs. Additionally, we highlight the importance of tool support in automating the refactoring process for quantum programs. Although our study focuses on the quantum programming language Q\#, our approach is applicable to other quantum programming languages, offering a general solution for enhancing the maintainability and efficiency of quantum software.
Quantum computing is advancing rapidly, with developers increasingly adopting quantum programming languages. However, despite progress in quantum research, there is a notable lack of development tools and technologies that assist developers in designing and analyzing quantum programs. This work aims to address this gap using a software engineering approach. Specifically, we leverage the srcML infrastructure to automate the static analysis and refactoring of OpenQASM quantum programs by implementing a tool, QStatic. We then demonstrate QStatic’s potential by identifying and refactoring common code patterns. Our approach enables the exploration and manipulation of quantum source code, effectively addressing numerous challenges in quantum programming, such as optimizing quantum gates to reduce runtime costs.
Abstract Quantum computing is now a reality, and its incomparable computational power has led companies to show a great interest in being able to work with quantum software in order to support part of their current and future business operations. However, the quantum computing paradigm differs significantly from its classical counterparts, which has brought about the need to revolutionise how the future software is designed, built, and operated in order to work with quantum computers. Since companies cannot discard all their current (and probably mission-critical) information systems, they must adapt their classical information systems to new specific quantum applications, thus evolving towards hybrid information systems. Unfortunately, there are no specific methods with which to deal with this challenge. We believe that reengineering, and more specifically, software modernisation using model-driven engineering principles, could be useful as regard migrating classical systems and existing quantum programs towards hybrid information systems. This paper, therefore, presents QRev, a reverse engineering tool that analyses quantum programs developed in Q# in order to identify its components and interrelationships, and then generates abstract models that can be used in software modernisation processes. The platform-independent models are generated according to the Knowledge Discovery Metamodel (KDM) standard. QRev is validated in a case study involving five quantum programs in order to demonstrate its effectiveness and scalability. The main implication of the study is that QRev can be used in order to attain KDM models, which can subsequently be employed to restructure or add new quantum functionality at a higher abstraction level, i.e. independently of the specific quantum technology.
The work aims to enable the use of common software engineering techniques and tools for quantum programming languages (e.g., OpenQASM). With the increased interest in quantum computing, researchers are adopting the use of higher-level quantum programming languages versus low-level circuit diagrams. While general purpose programming languages (e.g., C++, Python) are highly supported by a variety of software engineering tools, these novel programming languages for quantum computing have almost no support. Useable tools for debugging, static analysis, error detection, and transformation are currently non-existent. This work extends an existing software infrastructure (i.e., srcML) for the analysis, exploration, and manipulation of source code to OpenQASM. The srcML infrastructure, via parsing, generates abstract syntax information of programs to support high-level querying and analysis of the source code. With this, quantum developers can extract information and identify possible errors or inefficiencies in their programs. The paper presents the basic syntactic markup for OpenQASM. Also, a number of relevant quantum-based problems (e.g., iteration patterns, control recursion) are described and examples of how they are addressed using srcML are given.
Bug-fix pattern detection has been investigated in the past in the context of classical software.However, while quantum software is developing rapidly, the literature is still lacking automated methods and tools to identify, analyze, and detect bug-fix patterns.To the best of our knowledge, our work is the first to leverage classical techniques to detect bug-fix patterns in quantum code.In this paper, we propose an automated framework, called Q-Diff, for detecting bug-fix patterns in IBM Qiskit quantum code.In the framework, we develop a proof-of-concept tool based on Abstract Syntax Trees.To validate our method, we test Q-Diff with a variety of quantum bug-fix patterns using examples.We hope our work will attract the attention of the quantum software engineering community to improve the quality of quantum software.
Abstract Quantum computing holds great promise for solving complex problems that classical computing cannot address, with applications in various industries and sectors. However, developing efficient quantum software remains a challenge. Quantum software engineering (QSE) has emerged to address this, adapting classical software engineering practices for quantum systems. Design patterns, widely used in classical software, can provide reusable solutions for common quantum development issues, but their use in quantum software remains underexplored. This paper presents an empirical study investigating the use of design patterns in 2610 Qiskit programs from GitHub. Using the QCPD Tool to detect four design patterns (initialization, superposition, entanglement, and oracle) and QMetrics to compute software metrics, the study creates a dataset linking patterns with code characteristics. Three research questions guide the study: RQ1 examines the prevalence of design patterns in quantum software, RQ2 explores the relationship between design patterns and code metrics, and RQ3 analyzes the combinations of patterns that occur together. The findings provide insights into quantum software development, offering developers practical guidance on applying specific patterns. The results contribute to QSE by revealing key relationships between patterns and metrics, which can inform future research and tool development. These findings support improved performance, maintainability, and scalability, fostering the broader adoption of quantum computing.