domain-specific program checking

48
Domain-Specific Program Checking Lukas Renggli, Stéphane Ducasse, Tudor Gîrba, Oscar Nierstrasz

Upload: lukas-renggli

Post on 25-Dec-2014

683 views

Category:

Technology


3 download

DESCRIPTION

Lint-like program checkers are popular tools that ensure code quality by verifying compliance with best practices for a particular programming language. The proliferation of internal domain-specific languages and models, however, poses new challenges for such tools. Traditional program checkers produce many false positives and fail to accurately check constraints, best practices, common errors, possible optimizations and portability issues particular to domain-specific languages. We advocate the use of dedicated rules to check domain-specific practices. We demonstrate the implementation of domain-specific rules, the automatic repair of violations, and their application to two case-studies: (1) Seaside defines several internal DSLs through a creative use of the syntax of the host language; and (2) Magritte adds meta-descriptions to existing code by means of special methods. Our empirical validation demonstrates that domain-specific program checking significantly improves code quality when compared with general purpose program checking.

TRANSCRIPT

Page 1: Domain-Specific Program Checking

Domain-Specific Program Checking

Lukas Renggli, Stéphane Ducasse, Tudor Gîrba, Oscar Nierstrasz

Page 2: Domain-Specific Program Checking

Web Application Framework

Page 3: Domain-Specific Program Checking

14000

16000

18000

Sea

sid

e 2.

6

Sea

sid

e 2.

7

Sea

sid

e 2.

8

Sea

sid

e 2.

8.1

Sea

sid

e 2.

8.2

Sea

sid

e 2.

8.3

Sea

sid

e 2.

9a1

Sea

sid

e 2.

9a2

Sea

sid

e 2.

9a3

LOC

Page 4: Domain-Specific Program Checking

1

2

3

4

Lint

14000

16000

18000

Sea

sid

e 2.

6

Sea

sid

e 2.

7

Sea

sid

e 2.

8

Sea

sid

e 2.

8.1

Sea

sid

e 2.

8.2

Sea

sid

e 2.

8.3

Sea

sid

e 2.

9a1

Sea

sid

e 2.

9a2

Sea

sid

e 2.

9a3

LOC

Page 5: Domain-Specific Program Checking

1

2

3

4

Lint

???

14000

16000

18000

Sea

sid

e 2.

6

Sea

sid

e 2.

7

Sea

sid

e 2.

8

Sea

sid

e 2.

8.1

Sea

sid

e 2.

8.2

Sea

sid

e 2.

8.3

Sea

sid

e 2.

9a1

Sea

sid

e 2.

9a2

Sea

sid

e 2.

9a3

LOC

Page 6: Domain-Specific Program Checking

<a href="...">Remove Task 1</a> <br /><a href="...">Remove Task 2</a> <br /><a href="...">Remove Task 3</a> <br />

Page 7: Domain-Specific Program Checking

renderTasksOn: html tasks do: [ :task | html anchor with: 'Remove Task ' , task number; callback: [ tasks remove: task ]. html break ]

Page 8: Domain-Specific Program Checking

renderTasksOn: html tasks do: [ :task | html anchor with: 'Remove Task ' , task number; callback: [ tasks remove: task ]. html break ]

Modifies collection while iterating over it

Page 9: Domain-Specific Program Checking

‣ HTML generation

‣ Javascript generation

‣ Composition definition

‣ Control flow

‣ Application configuration

Internal Domain-Specific Languages

Page 10: Domain-Specific Program Checking

1

2

3

4

Lint

???

14000

16000

18000

Sea

sid

e 2.

6

Sea

sid

e 2.

7

Sea

sid

e 2.

8

Sea

sid

e 2.

8.1

Sea

sid

e 2.

8.2

Sea

sid

e 2.

8.3

Sea

sid

e 2.

9a1

Sea

sid

e 2.

9a2

Sea

sid

e 2.

9a3

LOC

Page 11: Domain-Specific Program Checking

Generic (Lint)Program Checker

Page 12: Domain-Specific Program Checking

Generic (Lint)Program Checker

ArchitectureChecker

Page 13: Domain-Specific Program Checking

Generic (Lint)Program Checker

Domain-SpecificProgram Checker

ArchitectureChecker

Page 14: Domain-Specific Program Checking

30 Domain-Specific Rules

‣ Possible Bugs

‣ Bad Style

‣ Suboptimal Code

‣ Non-Portable Code

Page 15: Domain-Specific Program Checking

renderTasksOn: html tasks do: [ :task | html anchor with: 'Remove Task ' , task number; callback: [ tasks remove: task ]. html break ]

#with: has to be last message in cascade

Page 16: Domain-Specific Program Checking

renderTasksOn: html tasks do: [ :task | html anchor callback: [ tasks remove: task ]; with: 'Remove Task ' , task number. html break ]

Page 17: Domain-Specific Program Checking

1

2

3

4

Lint

14000

16000

18000

Sea

sid

e 2.

6

Sea

sid

e 2.

7

Sea

sid

e 2.

8

Sea

sid

e 2.

8.1

Sea

sid

e 2.

8.2

Sea

sid

e 2.

8.3

Sea

sid

e 2.

9a1

Sea

sid

e 2.

9a2

Sea

sid

e 2.

9a3

LOC

Page 18: Domain-Specific Program Checking

1

2

3

4

Lint

Slime

14000

16000

18000

Sea

sid

e 2.

6

Sea

sid

e 2.

7

Sea

sid

e 2.

8

Sea

sid

e 2.

8.1

Sea

sid

e 2.

8.2

Sea

sid

e 2.

8.3

Sea

sid

e 2.

9a1

Sea

sid

e 2.

9a2

Sea

sid

e 2.

9a3

LOC

Page 19: Domain-Specific Program Checking

Designed for

Framework Development

Page 20: Domain-Specific Program Checking

Now used for

Application Development

Page 21: Domain-Specific Program Checking

69% developers state

“Slime produces more relevant results than Lint”

Page 22: Domain-Specific Program Checking

81% developers state

“Slime helped me to detect critical bugs”

Page 23: Domain-Specific Program Checking
Page 24: Domain-Specific Program Checking

Generic (Lint)Program Checker

Domain-SpecificProgram Checker

ArchitectureChecker

Page 25: Domain-Specific Program Checking

Magritte Metamodel

Page 26: Domain-Specific Program Checking

Personusernamebirthday

Description

accessorlabelrequiredpriority

*

description

* description

Page 27: Domain-Specific Program Checking

Personusernamebirthday

Description

accessorlabelrequiredpriority

*

description

* descriptionmodel

Page 28: Domain-Specific Program Checking

Personusernamebirthday

Description

accessorlabelrequiredpriority

*

description

* descriptionmodel

metamodel

Page 29: Domain-Specific Program Checking

Personusernamebirthday

Description

accessorlabelrequiredpriority

*

description

* descriptionmodel

metamodel

<<described by>>

Page 30: Domain-Specific Program Checking

Personusernamebirthday

Description

accessorlabelrequiredpriority

*

description

* descriptionmodel

metamodel

<<described by>>

meta-metamodel

Page 31: Domain-Specific Program Checking

Personusernamebirthday

Description

accessorlabelrequiredpriority

*

description

* descriptionmodel

metamodel

<<described by>>

meta-metamodel<<described by>>

Page 32: Domain-Specific Program Checking

Person class>>descriptionUsername ^ StringDescription new accessor: #username; beRequired; default: nil; yourself

Personusernamebirthday

Description

accessorlabelrequiredpriority

*

description

* description

Page 33: Domain-Specific Program Checking

Description class>>descriptionLabel ^ StringDescription new accessor: #label; label: ‘Label’; beRequired; yourself

Personusernamebirthday

Description

accessorlabelrequiredpriority

*

description

* description

Page 34: Domain-Specific Program Checking

Generic (Lint)Program Checker

Domain-SpecificProgram Checker

ArchitectureChecker

Page 35: Domain-Specific Program Checking

Generic (Lint)Program Checker

Domain-SpecificProgram Checker

ArchitectureChecker

Domain-SpecificModel Checker

Page 36: Domain-Specific Program Checking

Person class>>descriptionUsername ^ StringDescription new accessor: #username; beRequired; default: nil; yourself

Personusernamebirthday

Description

accessorlabelrequiredpriority

*

description

* description

Page 37: Domain-Specific Program Checking

Person class>>descriptionUsername ^ StringDescription new accessor: #username; label: ‘Username’; beRequired; default: nil; yourself

Personusernamebirthday

Description

accessorlabelrequiredpriority

*

description

* description

Page 38: Domain-Specific Program Checking

Person class>>descriptionUsername ^ StringDescription new accessor: #username; label: ‘Username’; beRequired; default: nil; yourself

Personusernamebirthday

Description

accessorlabelrequiredpriority

*

description

* description

#label is a required value

Page 39: Domain-Specific Program Checking

Invalid default value

Person class>>descriptionUsername ^ StringDescription new accessor: #username; label: ‘Username’; beRequired; default: nil; yourself

Personusernamebirthday

Description

accessorlabelrequiredpriority

*

description

* description

Page 40: Domain-Specific Program Checking

70000 Lines of Code

1100 Classes

300 Described Classes

12000 Methods

Page 41: Domain-Specific Program Checking

70000 Lines of Code

1100 Classes

300 Described Classes

12000 Methods

500 Magritte Issues

Page 42: Domain-Specific Program Checking
Page 43: Domain-Specific Program Checking

Implementation

Page 44: Domain-Specific Program Checking

Extends existing Program-Checker

Page 45: Domain-Specific Program Checking

Parse Tree Matching

Page 46: Domain-Specific Program Checking

scg.unibe.ch/research/helvetia

Page 47: Domain-Specific Program Checking

DeclarativeRule System

Page 48: Domain-Specific Program Checking

Generic (Lint)Program Checker

Domain-SpecificProgram Checker

ArchitectureChecker

Domain-SpecificModel Checker

Domain-SpecificProgram Checking