Towards a Taxonomy of Grammar Smells
- V. Zaytsev @ SLE’17 @ SPLASH
joint work with M. Stijlaart
Towards a Taxonomy of Grammar Smells V. Zaytsev @ SLE17 @ SPLASH - - PowerPoint PPT Presentation
Towards a Taxonomy of Grammar Smells V. Zaytsev @ SLE17 @ SPLASH joint work with M. Stijlaart Mntyl-Vanhanen-Lassenius Taxonomy of Bad Smells Bloaters OO abusers Change preventers Dispensables Encapsulators
joint work with M. Stijlaart
○ incomplete + comments
○ Convention ○ Notation ○ Parsing ○ Duplication
○ Spaghetti ○ Shortage ○ Mixture
○ Proxy ○ Dependency ○ Complexity
Convention Notation Parsing Duplicat ion Spaghetti Shortage Mixture Complexity Dependency Proxy Organisation Navigation Structure
○ misleading formatting
○ problems with naming policies
○ a misspelling or improper use of the natural language
○ mixing horizontal and vertical styles
○ nonterminal fragments scattered over the grammar
abc : def; ghi: Jkl; mno : pqr;
○ semantic action is code
define expression [expression] [op] [expression] | [id] [expression+] | if [expression] then [expression] else [expression] | ( [expression] ) | [id] | [number] end define
○ same rule occurs twice or more
○ same right hand side occurs twice or more
○ nonterminal's right hand side is not unique
○ common subexpressions
○ permutations in commutative combinators
○
near-clones
Shortage
Spaghetti
Mixture
○ right hand side is a nonterminal
○ a nonterminal used only once
○ a nonterminal does not form a proper abstraction
○ a subexpression that should have been a nonterminal
○
a nonterminal that represents two or more concepts
○
○ a circular dependency among modules
○ nonterminals or modules are always changed together
○ a nonterminal that is too linked to the adjacent symbols
○
an alternative that is never exercised in the codebase
reference-type ::= class-type | interface-type | delegate-type | ... ; class-type ::= type-name | "object" | "string"; interface-type ::= type-name ; delegate-type ::= type-name ;
○ right hand side length too big
○ too much branching
○ too much recursion
○ groups are too deeply nested
○ distance from the root too big
○ large non-modular grammar
○ too many modules
○
○ vice versa
○
low cohesion, high coupling
[1] Khomh, Di Penta, Guéhéneuc, WCRE 2006 [2] Mäntylä, Vanhanen, Lassenius, ICSM 2003, ICSM 2004 [3] Marinescu, TOOLS 2001, ICSM 2004 [4] Sjøberg, Yamashita, Anda, Mockus, Dybå, TSE 2012 [5] Al-Kofahi, Kothari, Kästner, GPCE 2017 [6] Sousa, Oliveira, Garcia, Lee, Conte, Oizumi, de Mello, Lopes, Valentim, Oliveira, Lucena, SBES’17