4,968 research outputs found
A Case Study in Refactoring Functional Programs
Refactoring is the process of redesigning existing code without changing its functionality. Refactoring has recently come to prominence in the OO community. In this paper we explore the prospects for refactoring functional programs. Our paper centres on the case study of refactoring a 400 line Haskell program written by one of our students. The case study illustrates the type and variety of program manipulations involved in refactoring. Similarly to other program transformations, refactorings are based on program equivalences, and thus ultimately on language semantics. In the context of functional languages, refactorings can be based on existing theory and program analyses. However, the use of program transformations for program restructuring emphasises a different kind of transformation from the more traditional derivation or optimisation: characteristically, they often require wholesale changes to a collection of modules, and although they are best controlled by programmers, their application may require nontrivial semantic analyses. The paper also explores the background to refactoring, provides a taxonomy for describing refactorings and draws some conclusions about refactoring for functional programs
A heuristic-based approach to code-smell detection
Encapsulation and data hiding are central tenets of the object oriented paradigm. Deciding what data and behaviour to form into a class and where to draw the line between its public and private details can make the difference between a class that is an understandable, flexible and reusable abstraction and one which is not. This decision is a difficult one and may easily result in poor encapsulation which can then have serious implications for a number of system qualities. It is often hard to identify such encapsulation problems within large software systems until they cause a maintenance problem (which is usually too late) and attempting to perform such analysis manually can also be tedious and error prone. Two of the common encapsulation problems that can arise as a consequence of this decomposition process are data classes and god classes. Typically, these two problems occur together – data classes are lacking in functionality that has typically been sucked into an over-complicated and domineering god class. This paper describes the architecture of a tool which automatically detects data and god classes that has been developed as a plug-in for the Eclipse IDE. The technique has been evaluated in a controlled study on two large open source systems which compare the tool results to similar work by Marinescu, who employs a metrics-based approach to detecting such features. The study provides some valuable insights into the strengths and weaknesses of the two approache
Safe Concurrency Introduction through Slicing
Traditional refactoring is about modifying the structure of existing code without changing its behaviour, but with the aim of making code easier to understand, modify, or reuse. In this paper, we introduce three novel refactorings for retrofitting concurrency to Erlang applications, and demonstrate how the use of program slicing makes the automation of these refactorings possible
Refactoring Functional Programs
Refactoring is the process of redesigning existing code without changing its functionality. Refactoring has recently come to prominence in the OO community. In this paper we explore the prospects for refactoring functional programs. Our paper centres on the case study of refactoring a 400 line Haskell program written by one of our students. The case study illustrates the type and variety of program manipulations involved in refactoring. Similarly to other program transformations, refactorings are based on program equivalences, and thus ultimately on language semantics. In the context of functional languages, refactorings can be based on existing theory and program analyses. However, the use of program transformations for program restructuring emphasises a different kind of transformation from the more traditional derivation or optimisation: characteristically, they often require wholesale changes to a collection of modules, and although they are best controlled by programmers, their application may require nontrivial semantic analyses. The paper also explores the background to refactoring, provides a taxonomy for describing refactorings and draws some conclusions about refactoring for functional programs
Invertible Program Restructurings for Continuing Modular Maintenance
When one chooses a main axis of structural decompostion for a software, such
as function- or data-oriented decompositions, the other axes become secondary,
which can be harmful when one of these secondary axes becomes of main
importance. This is called the tyranny of the dominant decomposition. In the
context of modular extension, this problem is known as the Expression Problem
and has found many solutions, but few solutions have been proposed in a larger
context of modular maintenance. We solve the tyranny of the dominant
decomposition in maintenance with invertible program transformations. We
illustrate this on the typical Expression Problem example. We also report our
experiments with Java and Haskell programs and discuss the open problems with
our approach.Comment: 6 pages, Early Research Achievements Track; 16th European Conference
on Software Maintenance and Reengineering (CSMR 2012), Szeged : Hungary
(2012
Views, Program Transformations, and the Evolutivity Problem in a Functional Language
We report on an experience to support multiple views of programs to solve the
tyranny of the dominant decomposition in a functional setting. We consider two
possible architectures in Haskell for the classical example of the expression
problem. We show how the Haskell Refactorer can be used to transform one view
into the other, and the other way back. That transformation is automated and we
discuss how the Haskell Refactorer has been adapted to be able to support this
automated transformation. Finally, we compare our implementation of views with
some of the literature.Comment: 19 page
Trustworthy Refactoring via Decomposition and Schemes: A Complex Case Study
Widely used complex code refactoring tools lack a solid reasoning about the
correctness of the transformations they implement, whilst interest in proven
correct refactoring is ever increasing as only formal verification can provide
true confidence in applying tool-automated refactoring to industrial-scale
code. By using our strategic rewriting based refactoring specification
language, we present the decomposition of a complex transformation into smaller
steps that can be expressed as instances of refactoring schemes, then we
demonstrate the semi-automatic formal verification of the components based on a
theoretical understanding of the semantics of the programming language. The
extensible and verifiable refactoring definitions can be executed in our
interpreter built on top of a static analyser framework.Comment: In Proceedings VPT 2017, arXiv:1708.0688
A Framework for Datatype Transformation
We study one dimension in program evolution, namely the evolution of the
datatype declarations in a program. To this end, a suite of basic
transformation operators is designed. We cover structure-preserving
refactorings, but also structure-extending and -reducing adaptations. Both the
object programs that are subject to datatype transformations, and the meta
programs that encode datatype transformations are functional programs.Comment: Minor revision; now accepted at LDTA 200
Deuce: A Lightweight User Interface for Structured Editing
We present a structure-aware code editor, called Deuce, that is equipped with
direct manipulation capabilities for invoking automated program
transformations. Compared to traditional refactoring environments, Deuce
employs a direct manipulation interface that is tightly integrated within a
text-based editing workflow. In particular, Deuce draws (i) clickable widgets
atop the source code that allow the user to structurally select the
unstructured text for subexpressions and other relevant features, and (ii) a
lightweight, interactive menu of potential transformations based on the current
selections. We implement and evaluate our design with mostly standard
transformations in the context of a small functional programming language. A
controlled user study with 21 participants demonstrates that structural
selection is preferred to a more traditional text-selection interface and may
be faster overall once users gain experience with the tool. These results
accord with Deuce's aim to provide human-friendly structural interactions on
top of familiar text-based editing.Comment: ICSE 2018 Paper + Supplementary Appendice
Domain-Specific Acceleration and Auto-Parallelization of Legacy Scientific Code in FORTRAN 77 using Source-to-Source Compilation
Massively parallel accelerators such as GPGPUs, manycores and FPGAs represent
a powerful and affordable tool for scientists who look to speed up simulations
of complex systems. However, porting code to such devices requires a detailed
understanding of heterogeneous programming tools and effective strategies for
parallelization. In this paper we present a source to source compilation
approach with whole-program analysis to automatically transform single-threaded
FORTRAN 77 legacy code into OpenCL-accelerated programs with parallelized
kernels.
The main contributions of our work are: (1) whole-source refactoring to allow
any subroutine in the code to be offloaded to an accelerator. (2) Minimization
of the data transfer between the host and the accelerator by eliminating
redundant transfers. (3) Pragmatic auto-parallelization of the code to be
offloaded to the accelerator by identification of parallelizable maps and
reductions.
We have validated the code transformation performance of the compiler on the
NIST FORTRAN 78 test suite and several real-world codes: the Large Eddy
Simulator for Urban Flows, a high-resolution turbulent flow model; the shallow
water component of the ocean model Gmodel; the Linear Baroclinic Model, an
atmospheric climate model and Flexpart-WRF, a particle dispersion simulator.
The automatic parallelization component has been tested on as 2-D Shallow
Water model (2DSW) and on the Large Eddy Simulator for Urban Flows (UFLES) and
produces a complete OpenCL-enabled code base. The fully OpenCL-accelerated
versions of the 2DSW and the UFLES are resp. 9x and 20x faster on GPU than the
original code on CPU, in both cases this is the same performance as manually
ported code.Comment: 12 pages, 5 figures, submitted to "Computers and Fluids" as full
paper from ParCFD conference entr
- …