In this lecture, we will discuss two papers:
Although not compulsory, I also recommend the following papers:
The term “code smell” doesn’t refer only to simple implementation mistakes, but also to design and architectural problems.
There is a lot of studies and papers about implementation code smell where researchers try to quantitatively measure the effects of these smells. Papers measuring code smells on the design and architectural level are less frequent.
Code smells on one levels can lead to smells on another level and this relation is bidirectional. For example, bad architecture can forces developers to make hacks, but also the existence of hacks in code can cause bad architectural decisions.
Researchers in the 2nd paper used Designite to automatically detect higher level smells. Unlike most other tools, this one focuses on detecting design and architectural smells instead of implementation ones.
Disposable code isn’t always bad. The agile methodology actually has disposing and changing the code in its core. However there will be always parts of the systems that cannot be remade.
Searching for code smells in a given context, for example for a specific design pattern, can give better resuts compared to generic code smells. Searching for code smells within the context of a single company may be to specific and not very useful since the lack of generalizability. However companies still frequently define own convention and support them with e.g. SonarCube rules. It’s good to start generic, but then zoom into specific patterns to gain better insights.
Book “Object-Oriented Design Heuristics” describes ways of measuring code and calculating metrics when looking for code smells. Book “Object-Oriented Metrics in Practice” proposes concrete strategies to detect code smells. PMD static code analyzer measures metrics and detects code smells, but uses same hardcoded thresholds for all classes.
Code smells and code metrics should be interpreted differently depending on the role of the class. Distribution of most metrics is significantly different for different class kinds (such like Controllers, Services, Entities). This requires to detect what is the kind of a class - for some this is easy (e.g. Controllers have to inherit from a base controller class) but for some this may require user input (which makes the tool much less handy) or parsing the class name (which can introduce errors). However, it’s hard to define context specific code smells and at the moment is no way to automate the process for different patterns and architectures.
Models trained on a specific dataset perform better than on general dataset. For example the system suggesting extract method refactor performed much better at ING when trained on the ING system compared to when trained at open source systems.
Grey literature studies leverage blogs and other non-peer-review sources to gain knowledge. In the case of code smells these are developer podcasts and conferences where people discuss problems and solutions they encountered in their work.