program comprehension for domain-specific languages maria joão varanda 1, marjan mernik 2, daniela...

39
CoRTA'08 - Bragança, 2008-Jul y-11 1 Program Comprehension Program Comprehension for Domain-Specific for Domain-Specific Languages Languages Maria João Varanda 1 , Marjan Mernik 2 , Daniela da Cruz 3 , Pedro Henriques 3 1 Polytechnic Institute of Bragança, Dep. of Computing and Communications, Portugal 2 University of Maribor, Fac. of Electrical Engineering and Computer Science, Slovenia 3 University of Minho, Dep. of Computer Science, Portugal

Upload: roderick-west

Post on 18-Jan-2016

220 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Program Comprehension for Domain-Specific Languages Maria João Varanda 1, Marjan Mernik 2, Daniela da Cruz 3, Pedro Henriques 3 1 Polytechnic Institute

CoRTA'08 - Bragança, 2008-July-11 1

Program Comprehension for Program Comprehension for Domain-Specific LanguagesDomain-Specific Languages

Maria João Varanda1, Marjan Mernik2,

Daniela da Cruz3, Pedro Henriques3

1 Polytechnic Institute of Bragança, Dep. of Computing and Communications, Portugal

2 University of Maribor, Fac. of Electrical Engineering and Computer Science, Slovenia

3 University of Minho, Dep. of Computer Science, Portugal

Page 2: Program Comprehension for Domain-Specific Languages Maria João Varanda 1, Marjan Mernik 2, Daniela da Cruz 3, Pedro Henriques 3 1 Polytechnic Institute

CoRTA'08 - Bragança, 2008-July-11 2

ContextContext

Program Comprehension (PC) is really an hard and complex task,

requiring: cognitive models, data extraction, information representation, knowledge exploration, sw visualization, sw metrics…

Page 3: Program Comprehension for Domain-Specific Languages Maria João Varanda 1, Marjan Mernik 2, Daniela da Cruz 3, Pedro Henriques 3 1 Polytechnic Institute

CoRTA'08 - Bragança, 2008-July-11 3

ContextContext

In order to reach a full understanding of software systems, it is crucial to relate problem and program domains.

Program Visualization and Program Animation are important aids to make this process easier, more effective!

Page 4: Program Comprehension for Domain-Specific Languages Maria João Varanda 1, Marjan Mernik 2, Daniela da Cruz 3, Pedro Henriques 3 1 Polytechnic Institute

CoRTA'08 - Bragança, 2008-July-11 4

ContextContext

The outcome of existing tools for General Purpose Languages (GPL) is far away from being as good as desirable !

Page 5: Program Comprehension for Domain-Specific Languages Maria João Varanda 1, Marjan Mernik 2, Daniela da Cruz 3, Pedro Henriques 3 1 Polytechnic Institute

CoRTA'08 - Bragança, 2008-July-11 5

MotivationMotivation

To introduce a research project aimed at understanding how the

standard approaches for the comprehension of GPL can be adapted for the comprehension of domain specific languages (DSL).

Page 6: Program Comprehension for Domain-Specific Languages Maria João Varanda 1, Marjan Mernik 2, Daniela da Cruz 3, Pedro Henriques 3 1 Polytechnic Institute

CoRTA'08 - Bragança, 2008-July-11 6

MotivationMotivation

We believe that specific visualizations could be defined to improve the comprehension of the descriptions in that particular domain !

Page 7: Program Comprehension for Domain-Specific Languages Maria João Varanda 1, Marjan Mernik 2, Daniela da Cruz 3, Pedro Henriques 3 1 Polytechnic Institute

CoRTA'08 - Bragança, 2008-July-11 7

OutlineOutlineDSLsDSLpc ProjectCognitive Dimensions FrameworkMethods and Techniques for PCUser-centric visualization for DSL

◦ Case-studiesConclusion

Page 8: Program Comprehension for Domain-Specific Languages Maria João Varanda 1, Marjan Mernik 2, Daniela da Cruz 3, Pedro Henriques 3 1 Polytechnic Institute

CoRTA'08 - Bragança, 2008-July-11 8

Domain Specific Domain Specific LanguagesLanguages

Languages tailored to specific application domain that offer to users more appropriate notations and abstractions.

DSLs are more expressive and are easier to use than GPLs for the domain in question, with gains in productivity and maintenance costs.

Page 9: Program Comprehension for Domain-Specific Languages Maria João Varanda 1, Marjan Mernik 2, Daniela da Cruz 3, Pedro Henriques 3 1 Polytechnic Institute

CoRTA'08 - Bragança, 2008-July-11 9

Domain Specific Domain Specific LanguagesLanguagesSome specific goals behind the

design of DSLs are:to make programming more

accessible to end-users, to improve correctness of the

written programs, and to improve the program

developing time.to make maintenance easier.

Page 10: Program Comprehension for Domain-Specific Languages Maria João Varanda 1, Marjan Mernik 2, Daniela da Cruz 3, Pedro Henriques 3 1 Polytechnic Institute

CoRTA'08 - Bragança, 2008-July-11 10

DSLpc ProjectDSLpc Project

In this project we have the following objectives:◦ to measure how easy is to use DSLs

(comparing with the use of GPLs), ◦ to understand which one of the existing PC

approaches are applicable to DSLs and how could they be improved,

◦ to propose a set of techniques to improve the PC of DSLs, and

◦ to allow the enhancement of DSL program comprehension by enabling user-centric visualization.

Page 11: Program Comprehension for Domain-Specific Languages Maria João Varanda 1, Marjan Mernik 2, Daniela da Cruz 3, Pedro Henriques 3 1 Polytechnic Institute

CoRTA'08 - Bragança, 2008-July-11 11

DSLpc Project how easy is to understand DSLs prgs

As it does not exists any formal study on advantges of DSLs,

our purpose is to identify the aspects among the CDF that are enhanced in the context of DS Languages

Page 12: Program Comprehension for Domain-Specific Languages Maria João Varanda 1, Marjan Mernik 2, Daniela da Cruz 3, Pedro Henriques 3 1 Polytechnic Institute

CoRTA'08 - Bragança, 2008-July-11 12

DSLpc Project how easy is to understand DSLs prgsCognitive dimensions framework

(CDF) – a set of 13 guidelines – provides relevant aspects to be used to determine how easy is:

◦ to learn the language, ◦ to develop a program, ◦ to evolve a program, ◦ to comprehend a program.

Page 13: Program Comprehension for Domain-Specific Languages Maria João Varanda 1, Marjan Mernik 2, Daniela da Cruz 3, Pedro Henriques 3 1 Polytechnic Institute

CoRTA'08 - Bragança, 2008-July-11 13

DSLpc Project PC Approaches

Page 14: Program Comprehension for Domain-Specific Languages Maria João Varanda 1, Marjan Mernik 2, Daniela da Cruz 3, Pedro Henriques 3 1 Polytechnic Institute

CoRTA'08 - Bragança, 2008-July-11 14

DSLpc Project PC Approaches -- Data Extraction

Data necessary for DSL comprehension, that must be extracted, is specific and should be identified case-by-case.

Page 15: Program Comprehension for Domain-Specific Languages Maria João Varanda 1, Marjan Mernik 2, Daniela da Cruz 3, Pedro Henriques 3 1 Polytechnic Institute

CoRTA'08 - Bragança, 2008-July-11 15

DSLpc Project PC Approaches -- Data ExtractionWe will consider 2 families of

extraction methods:◦ Non-invasive: that does not

modify the source program and uses abstract interpretation techniques.

◦ Invasive: program instrumentation modifies the source code (inserting inspector functions) to be able to collect dynamic information at runtime.

Page 16: Program Comprehension for Domain-Specific Languages Maria João Varanda 1, Marjan Mernik 2, Daniela da Cruz 3, Pedro Henriques 3 1 Polytechnic Institute

CoRTA'08 - Bragança, 2008-July-11 16

DSLpc Project PC Approaches -- Data Extraction

The development of both approaches completely rely on traditional grammar-oriented techniques for compiler writing and implementation.

We use Translation Grammars or Attribute Grammars, and resort to Compiler Generators to automatically produce the code of the desired processors.

Page 17: Program Comprehension for Domain-Specific Languages Maria João Varanda 1, Marjan Mernik 2, Daniela da Cruz 3, Pedro Henriques 3 1 Polytechnic Institute

CoRTA'08 - Bragança, 2008-July-11 17

DSLpc Project PC Approaches -- Data Extraction

If DSLs processing is supported by grammars technology

we can affirm that existing PC approches (methods and techniques) for extraction, are reusable in that specific context.

Page 18: Program Comprehension for Domain-Specific Languages Maria João Varanda 1, Marjan Mernik 2, Daniela da Cruz 3, Pedro Henriques 3 1 Polytechnic Institute

CoRTA'08 - Bragança, 2008-July-11 18

DSLpc Project PC Approaches – Information Rep.

We also believe that traditional PC methods and techniques for Information Representation and storage

are reusable in that specific context.

Page 19: Program Comprehension for Domain-Specific Languages Maria João Varanda 1, Marjan Mernik 2, Daniela da Cruz 3, Pedro Henriques 3 1 Polytechnic Institute

CoRTA'08 - Bragança, 2008-July-11 19

DSLpc Project PC Approaches -- Knowledge Exploration

Inference mechanisms, metrics, and visualization/navigation over the information so far collected,

may also be inherited from generic PC approaches.

That intuition comes directly from the previous slide --- the same IR schema is used for GPL/DSL contexts.

Page 20: Program Comprehension for Domain-Specific Languages Maria João Varanda 1, Marjan Mernik 2, Daniela da Cruz 3, Pedro Henriques 3 1 Polytechnic Institute

CoRTA'08 - Bragança, 2008-July-11 20

DSLpc Project PC Approaches -- Knowledge Exploration

Working with DSLs, we can take total profit of the inherent speciality,

and look for more expressive and adequate visual representations for each domain

and also metrics and visual interaction and querying.

Page 21: Program Comprehension for Domain-Specific Languages Maria João Varanda 1, Marjan Mernik 2, Daniela da Cruz 3, Pedro Henriques 3 1 Polytechnic Institute

CoRTA'08 - Bragança, 2008-July-11 21

DSLpc Project PC Approaches -- Knowledge Exploration

Program and Problem comprehension can be achieved easily because it is easier to present a conceptual mapping between both.

Page 22: Program Comprehension for Domain-Specific Languages Maria João Varanda 1, Marjan Mernik 2, Daniela da Cruz 3, Pedro Henriques 3 1 Polytechnic Institute

CoRTA'08 - Bragança, 2008-July-11 22

DSLpc Project User-centric Visualization

It would be useful to construct visualization tools where end-users, not language designer or developer, can easily specify their own visualization---problem and person specific.

Page 23: Program Comprehension for Domain-Specific Languages Maria João Varanda 1, Marjan Mernik 2, Daniela da Cruz 3, Pedro Henriques 3 1 Polytechnic Institute

CoRTA'08 - Bragança, 2008-July-11 23

DSLpc Project User-centric Visualization

Concerning the implementation, we think that we can rely upon the approach followed in Alma,

a system for program visualization and animation that deals easily with different programming languages and allows the construction of the most appropriate visualizations for each domain.

Page 24: Program Comprehension for Domain-Specific Languages Maria João Varanda 1, Marjan Mernik 2, Daniela da Cruz 3, Pedro Henriques 3 1 Polytechnic Institute

CoRTA'08 - Bragança, 2008-July-11 24

DSLpc Project User-centric Visualization

The core of Alma is similar to a compiler's Back-End that takes as input an abstract representation, a DAST (Decorated Abstract Syntax Tree), and implements the visualizer and the animator components in a systematic way.

Page 25: Program Comprehension for Domain-Specific Languages Maria João Varanda 1, Marjan Mernik 2, Daniela da Cruz 3, Pedro Henriques 3 1 Polytechnic Institute

CoRTA'08 - Bragança, 2008-July-11 25

DSLpc Project User-centric Visualization

This is achieved by means of two rule bases, one for the visualization of tree nodes,and another for tree rewriting.

Page 26: Program Comprehension for Domain-Specific Languages Maria João Varanda 1, Marjan Mernik 2, Daniela da Cruz 3, Pedro Henriques 3 1 Polytechnic Institute

CoRTA'08 - Bragança, 2008-July-11 26

DSLpc Project User-centric Visualization

We plan to build a graphical editor that will provide to the end-user the chance to associate to each node of the DAST:◦ a geometric figure (a square, circle,

etc), or an image.◦ an external (end-user defined)

drawing function.

Page 27: Program Comprehension for Domain-Specific Languages Maria João Varanda 1, Marjan Mernik 2, Daniela da Cruz 3, Pedro Henriques 3 1 Polytechnic Institute

CoRTA'08 - Bragança, 2008-July-11 27

DSLpc Project User-centric Visualization

This will permit to build specific drawings parameterized to fit well in each particular DSL.

The external function will be called using the attributes available in the DAST nodes to tune the picture to each concrete situation.

Page 28: Program Comprehension for Domain-Specific Languages Maria João Varanda 1, Marjan Mernik 2, Daniela da Cruz 3, Pedro Henriques 3 1 Polytechnic Institute

CoRTA'08 - Bragança, 2008-July-11 28

DSLpc Project User-centric Visualization

We can include that functionality, keeping the tree visualizer engine generic and unchanged; also the animator system, based on a tree rewriting engine, will be kept unchanged.

Page 29: Program Comprehension for Domain-Specific Languages Maria João Varanda 1, Marjan Mernik 2, Daniela da Cruz 3, Pedro Henriques 3 1 Polytechnic Institute

CoRTA'08 - Bragança, 2008-July-11 29

Case-study 1:Programming a Cleaning Robot

A sample program to move Roby:xi= 0 yi= 0 DOWN 3 RIGHT 7 UP 2 LEFT 4

Page 30: Program Comprehension for Domain-Specific Languages Maria João Varanda 1, Marjan Mernik 2, Daniela da Cruz 3, Pedro Henriques 3 1 Polytechnic Institute

CoRTA'08 - Bragança, 2008-July-11 30

Case-study 1:Programming a Cleaning Robot

A Program Domain View (operational)

Page 31: Program Comprehension for Domain-Specific Languages Maria João Varanda 1, Marjan Mernik 2, Daniela da Cruz 3, Pedro Henriques 3 1 Polytechnic Institute

CoRTA'08 - Bragança, 2008-July-11 31

Case-study 1:Programming a Cleaning Robot

A Problem Domain View (behavioral)

Page 32: Program Comprehension for Domain-Specific Languages Maria João Varanda 1, Marjan Mernik 2, Daniela da Cruz 3, Pedro Henriques 3 1 Polytechnic Institute

CoRTA'08 - Bragança, 2008-July-11 32

Case-study 2:FDL – Feature Description Language An FDL Description

Car: all(carBody,Transmission,Engine,HorsePower,

pullsTrailer?) Transmission:

one_of (automatic, manual)

Engine:

more_of (electric, gasoline )

HorsePower:

one_of(lowPower, mediumPower, highPower)

Page 33: Program Comprehension for Domain-Specific Languages Maria João Varanda 1, Marjan Mernik 2, Daniela da Cruz 3, Pedro Henriques 3 1 Polytechnic Institute

CoRTA'08 - Bragança, 2008-July-11 33

Case-study 2:FDL – Feature Description Language A Program Domain View

(operational)

Page 34: Program Comprehension for Domain-Specific Languages Maria João Varanda 1, Marjan Mernik 2, Daniela da Cruz 3, Pedro Henriques 3 1 Polytechnic Institute

CoRTA'08 - Bragança, 2008-July-11 34

Case-study 2:FDL – Feature Description Language A Problem Domain View

(behavioral)

Page 35: Program Comprehension for Domain-Specific Languages Maria João Varanda 1, Marjan Mernik 2, Daniela da Cruz 3, Pedro Henriques 3 1 Polytechnic Institute

CoRTA'08 - Bragança, 2008-July-11 35

ConclusionConclusion

We have introduced the 2 main directions of our new bilateral (Portugal/Slovenia) project for joint research:◦ to understand and measure how easy is

to comprehend and handle programs written in DSLs;

◦ to addapt and improve Program Comprehension Tools for DSLs programs.

Page 36: Program Comprehension for Domain-Specific Languages Maria João Varanda 1, Marjan Mernik 2, Daniela da Cruz 3, Pedro Henriques 3 1 Polytechnic Institute

CoRTA'08 - Bragança, 2008-July-11 36

ConclusionConclusion

In the first case, we believe that DSL concept implies that a DSL program should be more natural and clearer than the equivalent solution expressed in a General Purpose Language (GPL),

but we intent to prove it analyzing DSL actual impact according to the aspects defined in the Cognitve Dimension Framework

Page 37: Program Comprehension for Domain-Specific Languages Maria João Varanda 1, Marjan Mernik 2, Daniela da Cruz 3, Pedro Henriques 3 1 Polytechnic Institute

CoRTA'08 - Bragança, 2008-July-11 37

ConclusionConclusion

We feel that some of the cognitive dimensions (like hidden dependencies, hard mental operations, secondary notation, visibility, role expressiveness) can benefit from DSL program visualization and program comprehension tools,

and we intend to prove that!

Page 38: Program Comprehension for Domain-Specific Languages Maria João Varanda 1, Marjan Mernik 2, Daniela da Cruz 3, Pedro Henriques 3 1 Polytechnic Institute

CoRTA'08 - Bragança, 2008-July-11 38

ConclusionConclusion

In the second case, we have to directions:

to corroborate our statement that classic approaches for GPLs Program Comprehension, can be reused for DSLs;

to enhance DSL program comprehension tools, by enabling user-centric visualization.

Page 39: Program Comprehension for Domain-Specific Languages Maria João Varanda 1, Marjan Mernik 2, Daniela da Cruz 3, Pedro Henriques 3 1 Polytechnic Institute

CoRTA'08 - Bragança, 2008-July-11 39

ConclusionConclusion

We made a concrete proposal:to improve the program

understanding tool Alma with extra functionality to allow the user to specify the visual representation he wants to apply for each particular DSL .

This allows a better visualization of the Problem Domain, making it closer to Program Domain.