Domain-Specific Program Checking

1,117 views

Published on

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.

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
1,117
On SlideShare
0
From Embeds
0
Number of Embeds
112
Actions
Shares
0
Downloads
5
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Domain-Specific Program Checking

  1. 1. Domain-Specific Program Checking Lukas Renggli, Stéphane Ducasse, Tudor Gîrba, Oscar Nierstrasz
  2. 2. Web Application Framework
  3. 3. 14000 16000 18000 Seaside 2.6 Seaside 2.7 Seaside 2.8 Seaside 2.8.1 Seaside 2.8.2 Seaside 2.8.3 Seaside 2.9a1 Seaside 2.9a2 Seaside 2.9a3 LOC
  4. 4. 14000 16000 18000 1 2 3 4 Seaside 2.6 Seaside 2.7 Seaside 2.8 Seaside 2.8.1 Seaside 2.8.2 Seaside 2.8.3 Seaside 2.9a1 Seaside 2.9a2 Seaside 2.9a3 Lint LOC
  5. 5. 14000 16000 18000 1 2 3 4 Seaside 2.6 Seaside 2.7 Seaside 2.8 Seaside 2.8.1 Seaside 2.8.2 Seaside 2.8.3 Seaside 2.9a1 Seaside 2.9a2 Seaside 2.9a3 ??? Lint LOC
  6. 6. <a href="...">Remove Task 1</a> <br /> <a href="...">Remove Task 2</a> <br /> <a href="...">Remove Task 3</a> <br />
  7. 7. renderTasksOn: html tasks do: [ :task | html anchor with: 'Remove Task ' , task number; callback: [ tasks remove: task ]. html break ]
  8. 8. renderTasksOn: html tasks do: [ :task | html anchor with: 'Remove Task ' , task number; callback: [ tasks remove: task ]. html break ] Modifies collection while iterating over it
  9. 9. Internal Domain- Specific Languages ‣ HTML generation ‣ Javascript generation ‣ Composition definition ‣ Control flow ‣ Application configuration
  10. 10. 14000 16000 18000 1 2 3 4 Seaside 2.6 Seaside 2.7 Seaside 2.8 Seaside 2.8.1 Seaside 2.8.2 Seaside 2.8.3 Seaside 2.9a1 Seaside 2.9a2 Seaside 2.9a3 ??? Lint LOC
  11. 11. Generic (Lint) Program Checker
  12. 12. Architecture Checker Generic (Lint) Program Checker
  13. 13. Architecture Checker Generic (Lint) Domain-Specific Program Checker Program Checker
  14. 14. 30 Domain-Specific Rules ‣ Possible Bugs ‣ Bad Style ‣ Suboptimal Code ‣ Non-Portable Code
  15. 15. 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
  16. 16. renderTasksOn: html tasks do: [ :task | html anchor callback: [ tasks remove: task ]; with: 'Remove Task ' , task number. html break ]
  17. 17. 14000 16000 18000 1 2 3 4 Seaside 2.6 Seaside 2.7 Seaside 2.8 Seaside 2.8.1 Seaside 2.8.2 Seaside 2.8.3 Seaside 2.9a1 Seaside 2.9a2 Seaside 2.9a3 Lint LOC
  18. 18. 14000 16000 18000 1 2 3 4 Seaside 2.6 Seaside 2.7 Seaside 2.8 Seaside 2.8.1 Seaside 2.8.2 Seaside 2.8.3 Seaside 2.9a1 Seaside 2.9a2 Seaside 2.9a3 Lint LOC Slime
  19. 19. Designed for Framework Development
  20. 20. Now used for Application Development
  21. 21. 69% developers state “Slime produces more relevant results than Lint”
  22. 22. 81% developers state “Slime helped me to detect critical bugs”
  23. 23. Architecture Checker Generic (Lint) Domain-Specific Program Checker Program Checker
  24. 24. Magritte Metamodel
  25. 25. * description Description Person accessor username * label birthday description required priority
  26. 26. model * description Description Person accessor username * label birthday description required priority
  27. 27. model * description Description Person accessor username * label birthday description required priority metamodel
  28. 28. model * description Description Person accessor username * label birthday description required priority <<described by>> metamodel
  29. 29. meta-metamodel model * description Description Person accessor username * label birthday description required priority <<described by>> metamodel
  30. 30. meta-metamodel <<described by>> model * description Description Person accessor username * label birthday description required priority <<described by>> metamodel
  31. 31. Person class>>descriptionUsername ^ StringDescription new accessor: #username; beRequired; default: nil; yourself * description Description Person accessor username * label birthday description required priority
  32. 32. Description class>>descriptionLabel ^ StringDescription new accessor: #label; label: ‘Label’; beRequired; yourself * description Description Person accessor username * label birthday description required priority
  33. 33. Architecture Checker Generic (Lint) Domain-Specific Program Checker Program Checker
  34. 34. Architecture Domain-Specific Checker Model Checker Generic (Lint) Domain-Specific Program Checker Program Checker
  35. 35. Person class>>descriptionUsername ^ StringDescription new accessor: #username; beRequired; default: nil; yourself * description Description Person accessor username * label birthday description required priority
  36. 36. Person class>>descriptionUsername ^ StringDescription new accessor: #username; label: ‘Username’; beRequired; default: nil; yourself * description Description Person accessor username * label birthday description required priority
  37. 37. Person class>>descriptionUsername ^ StringDescription new accessor: #username; label: ‘Username’; beRequired; default: nil; yourself * description #label is a required value Description Person accessor username * label birthday description required priority
  38. 38. Person class>>descriptionUsername ^ StringDescription new accessor: #username; label: ‘Username’; beRequired; default: nil; yourself * description Description Person Invalid default value accessor username * label birthday description required priority
  39. 39. 70000 Lines of Code 12000 Methods 1100 Classes 300 Described Classes
  40. 40. 70000 Lines of Code 12000 Methods 1100 Classes 300 Described Classes 500 Magritte Issues
  41. 41. Implementation
  42. 42. Extends existing Program-Checker
  43. 43. Parse Tree Matching
  44. 44. scg.unibe.ch/research/helvetia
  45. 45. Declarative Rule System
  46. 46. Domain-Specific Program Checking Architecture Domain-Specific Checker Model Checker Generic (Lint) Domain-Specific Program Checker Program Checker

×