• Aucun résultat trouvé

Program Transformation based Views for Modular Maintenance

N/A
N/A
Protected

Academic year: 2021

Partager "Program Transformation based Views for Modular Maintenance"

Copied!
3
0
0

Texte intégral

(1)

HAL Id: hal-00670378

https://hal.archives-ouvertes.fr/hal-00670378

Submitted on 15 Feb 2012

HAL is a multi-disciplinary open access

archive for the deposit and dissemination of

sci-entific research documents, whether they are

pub-lished or not. The documents may come from

teaching and research institutions in France or

abroad, or from public or private research centers.

L’archive ouverte pluridisciplinaire HAL, est

destinée au dépôt et à la diffusion de documents

scientifiques de niveau recherche, publiés ou non,

émanant des établissements d’enseignement et de

recherche français ou étrangers, des laboratoires

publics ou privés.

Program Transformation based Views for Modular

Maintenance

Akram Ajouli, Julien Cohen, Rémi Douence

To cite this version:

Akram Ajouli, Julien Cohen, Rémi Douence. Program Transformation based Views for Modular

Maintenance. Troisièmes journées nationales du GDR GPL, Jun 2011, Lille, France. pp.218-219.

�hal-00670378�

(2)

Program Transformation based Views for Modular Maintenance

Akram AJOULI, Julien COHEN, and R´emi DOUENCE

ASCOLA group: EMN-INRIA, LINA

1

Context

Since modular programming is a practical solution for separation of concerns, it participates in reducing development time and it favors maintainability and reuse [5]. Despite of these benefits, modularity does not resolve the classical expression problem [7] and more generally the tyranny of the dominant decompo-sition [6]: evolutions are modular only on the principal axis of decompodecompo-sition.

This is illustrated by the two possible structures for a same program given in Fig. 1. The architecture given in Fig. 1(a) is modular with respect to functions (it is modular to add or modify a function), its dominant decomposition is function-oriented. The architecture given in Fig. 1(b) is modular with respect to data constructors (when the data-structure is extended or adapted, it is modular to extend or update the corresponding functions), its dominant decomposition is data-oriented. In object oriented programming, the same duality is observed between the Visitor and the Composite design patterns.



m o d u l e Expr w h e r e

data Expr = C o n s t Int | Add ( Expr , Expr )



m o d u l e Eval w h e r e i m p o r t Expr

eval ( C o n s t i ) = i

eval ( Add ( e1 , e2 )) = eval e1 + eval e2

 m o d u l e T o S t r i n g w h e r e i m p o r t Expr t o S t r i n g ( C o n s t i ) = show i t o S t r i n g ( Add ( e1 , e2 )) = t o S t r i n g e1 ++ "+" ++ t o S t r i n g e2

(a) Functional decomposition.



m o d u l e Expr w h e r e

data Expr = C o n s t Int | Add ( Expr , Expr )

fold fc fa ( C o n s t i ) = fc i fold fc fa ( Add ( e1 , e2 ))= fa ( fold fc fa e1 ) ( fold fc fa e2 )  m o d u l e C o n s t w h e r e eval i = i t o S t r i n g i = show i  m o d u l e Add w h e r e eval x y = x + y t o S t r i n g x y = x ++ "+" ++ y  m o d u l e C l i e n t w h e r e i m p o r t Expr i m p o r t C o n s t i m p o r t Add t o S t r i n g x = fold C o n s t . t o S t r i n g Add . t o S t r i n g x

eval x = fold C o n s t . eval Add . eval x

(b) Constructor decomposition.

(3)

Whatever structure is chosen, some evolutions will be cross-cutting (non modular). In particular, adapt-ing a function in the data-oriented architecture is cross-cuttadapt-ing and vice versa.

To solve this problem, a practical solution would be to be able to choose the architecture each time one has an evolution to implement. This corresponds to a concept of views of programs where each view expresses the whole program, but with a different code structure (as in [1]). With such a solution, a pro-grammer can implement an evolution in the view which is the most convenient. The practicability of this solution depends on the availability of a tool (possibly based on program transformations) to be able to pass from one view to another (from one code structure to another).

2

Contributions

We provide a prototype tool for the Haskell language to support the concept of views described above [2]. Our tool allows to build transformations to switch Haskell programs from one view to another. We do this by providing high-level interfaces to a refactoring tool for Haskell (HaRe [4]): transformations are built by chaining elementary operations of refactoring. Moreover, the refactoring tool ensures that the transformations preserve the semantics of the programs: since each elementary refactoring preserves the semantics, the whole transformation also does.

3

Challenges

To be practicable, our proposal must respond to the following challenges:

Automatic inference of program transformations. A disadvantage of our proposal is that the

transfor-mation has to be defined imperatively, which is tedious. To solve this, we must provide automatic transformation inference based on constraints expressed by the user. This would also avoid to have to maintain the transformations as the programs evolve.

Invertibility of program transformations. Once a first transformation is set up (automatically or not),

the inverse transformation could be computed from the first one. However, all refactoring operations are not invertible and we cannot tell now what architecture transformations can be built with invertible elementary transformations.

Minimum precondition. As static type checking has advantages over dynamic typing with respect to

assistance for development, a minimal precondition analysis performed on transformations can help to set up transformations and check their properties [3]. Thus, one could have the guaranty that a transformation will succeed before performing it.

References

1. Andrew P. Black and Mark P. Jones. The case for multiple views. In ICSE 2004 Workshop on Directions in Software

Engineering Environments, 2004.

2. Julien Cohen and R´emi Douence. Views, Program Transformations, and the Evolutivity Problem in a Functional Language. 19 pages, Research Report hal-00481941, version 2, January 2011.

3. G¨unter Kniesel and Helge Koch. Static composition of refactorings. Science of Computer Programming, 52(Issues 1-3):9–51, Aug. 2004. Special Issue on Program Transformation.

4. Huiqing Li and Simon Thompson. Tool Support for Refactoring Functional Programs. In Partial Evaluation and

Program Manipulation, San Francisco, CA, USA, Jan. 2008.

5. David L. Parnas. On the criteria to be used in decomposing systems into modules. Commun. ACM, 15:1053–1058, December 1972.

6. Peri Tarr, Harold Ossher, William Harrison, and Stanley M. Jr. Sutton. N degrees of separation: multi-dimensional separation of concerns. In Proceedings of the 21st international conference on Software engineering, ICSE ’99, pages 107–119, New York, NY, USA, 1999. ACM.

Figure

Fig. 1. Two alternative architectures for a same Haskell program.

Références

Documents relatifs

Such approach shifts the focus of attention from relationships to their truth-makers, considered indeed in most cases as maximal perdurants (i.e., episodes, like a marriage, a loan,

Indeed, if B passes the control back to the manager after a pause transition (taking the edge from main B to main B in the DUTA in Fig. 18), the clock x B will continue evolving

To be able to specify these refactoring operations on a higher abstraction level as proposed in the Java Refactoring Case at the Transformation Tool Contest (TTC) 2015, we propose

To solve this, SDMLib provides a recursive descent parser that analyzes java source code files and create an abstract graph model.. Using the parser is really easy due to the fact

The definition of the distribution semantics can be given quite simply in the case of no function symbols in the program: a probabilistic logic program under the distribution

Even if truth conditions are often close, dynamic properties, especially anaphora and apposition, give a basis for distinguishing numerals, numerical comparatives (more than), and

In Proceedings of ACM SIGPLAN International Workshop on Libraries, Languages, and Compilers for Array Programming (ARRAY’14). Array Program Transformation with Loo.Py by

The structure of this article is as follows: I start by pointing to work in the philosophy of language, pragmatics, cognitive psychology, and conversational analysis, which