domain-specific program checking
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
Domain-Specific Program Checking
Lukas Renggli, Stéphane Ducasse, Tudor Gîrba, Oscar Nierstrasz
Web Application Framework
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
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
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
<a href="...">Remove Task 1</a> <br /><a href="...">Remove Task 2</a> <br /><a href="...">Remove Task 3</a> <br />
renderTasksOn: html tasks do: [ :task | html anchor with: 'Remove Task ' , task number; callback: [ tasks remove: task ]. html break ]
renderTasksOn: html tasks do: [ :task | html anchor with: 'Remove Task ' , task number; callback: [ tasks remove: task ]. html break ]
Modifies collection while iterating over it
‣ HTML generation
‣ Javascript generation
‣ Composition definition
‣ Control flow
‣ Application configuration
Internal Domain-Specific Languages
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
Generic (Lint)Program Checker
Generic (Lint)Program Checker
ArchitectureChecker
Generic (Lint)Program Checker
Domain-SpecificProgram Checker
ArchitectureChecker
30 Domain-Specific Rules
‣ Possible Bugs
‣ Bad Style
‣ Suboptimal Code
‣ Non-Portable Code
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
renderTasksOn: html tasks do: [ :task | html anchor callback: [ tasks remove: task ]; with: 'Remove Task ' , task number. html break ]
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
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
Designed for
Framework Development
Now used for
Application Development
69% developers state
“Slime produces more relevant results than Lint”
81% developers state
“Slime helped me to detect critical bugs”
Generic (Lint)Program Checker
Domain-SpecificProgram Checker
ArchitectureChecker
Magritte Metamodel
Personusernamebirthday
Description
accessorlabelrequiredpriority
*
description
* description
Personusernamebirthday
Description
accessorlabelrequiredpriority
*
description
* descriptionmodel
Personusernamebirthday
Description
accessorlabelrequiredpriority
*
description
* descriptionmodel
metamodel
Personusernamebirthday
Description
accessorlabelrequiredpriority
*
description
* descriptionmodel
metamodel
<<described by>>
Personusernamebirthday
Description
accessorlabelrequiredpriority
*
description
* descriptionmodel
metamodel
<<described by>>
meta-metamodel
Personusernamebirthday
Description
accessorlabelrequiredpriority
*
description
* descriptionmodel
metamodel
<<described by>>
meta-metamodel<<described by>>
Person class>>descriptionUsername ^ StringDescription new accessor: #username; beRequired; default: nil; yourself
Personusernamebirthday
Description
accessorlabelrequiredpriority
*
description
* description
Description class>>descriptionLabel ^ StringDescription new accessor: #label; label: ‘Label’; beRequired; yourself
Personusernamebirthday
Description
accessorlabelrequiredpriority
*
description
* description
Generic (Lint)Program Checker
Domain-SpecificProgram Checker
ArchitectureChecker
Generic (Lint)Program Checker
Domain-SpecificProgram Checker
ArchitectureChecker
Domain-SpecificModel Checker
Person class>>descriptionUsername ^ StringDescription new accessor: #username; beRequired; default: nil; yourself
Personusernamebirthday
Description
accessorlabelrequiredpriority
*
description
* description
Person class>>descriptionUsername ^ StringDescription new accessor: #username; label: ‘Username’; beRequired; default: nil; yourself
Personusernamebirthday
Description
accessorlabelrequiredpriority
*
description
* description
Person class>>descriptionUsername ^ StringDescription new accessor: #username; label: ‘Username’; beRequired; default: nil; yourself
Personusernamebirthday
Description
accessorlabelrequiredpriority
*
description
* description
#label is a required value
Invalid default value
Person class>>descriptionUsername ^ StringDescription new accessor: #username; label: ‘Username’; beRequired; default: nil; yourself
Personusernamebirthday
Description
accessorlabelrequiredpriority
*
description
* description
70000 Lines of Code
1100 Classes
300 Described Classes
12000 Methods
70000 Lines of Code
1100 Classes
300 Described Classes
12000 Methods
500 Magritte Issues
Implementation
Extends existing Program-Checker
Parse Tree Matching
scg.unibe.ch/research/helvetia
DeclarativeRule System
Generic (Lint)Program Checker
Domain-SpecificProgram Checker
ArchitectureChecker
Domain-SpecificModel Checker
Domain-SpecificProgram Checking