Thesis
Sven Konings
Thesis Sven Konings
How can we improve code quality when combining object-oriented and functional programming in Scala?
The combination of Object-Oriented Programming (OOP) and Functional Programming (FP) is becoming more and more common. Popular OOP languages like Java and C# have incorporated concepts from FP languages like lambdas and higher-order functions. Furthermore, Multi-paradigm Programming (MP) languages like Scala and Kotlin are becoming increasingly common.
This combination of programming paradigms allows for powerful new programming constructs. However, the combination of these paradigms also leads to new pitfalls. For example, FP code often assumes lambda functions have no side-effects. In MP languages this is not guaranteed. These new pitfalls are not detected by traditional metrics and tooling.

Example
An advantage of having functions without side-effects, also called pure functions, is that they can be lazily evaluated and operations using them can easily be parallelized. In MP languages functions are not guaranteed to be pure. An example where this causes issues is when using parallel collections. This is demonstrated in Listing 1.
Listing 1: Parallel collection impure lambda example
Scala
Scala is statically typed JVM language that combines object-oriented and functional programming. Scala is designed to fully support both OOP and FP styles of programming and contains a more extensive mix of constructs compared to languages which have added FP constructs later on. Support for Scala within code analysis tooling like SonarQube is available. However, the tooling doesn’t detect pitfalls that occur when mixing paradigms.

Researching pitfalls

To find out which pitfalls commonly occur we have analyzed several open-source Scala projects. For these projects we have measured the fault-proneness of each part of the code. Fault-proneness is the likelihood a piece of code contains bugs. The fault-proneness has been measured by analyzing which code was changed to fix bugs in the past. Next we have measured all the different (combinations of) OOP and FP constructs that are used by these projects and analyzed which constructs are the best predictors for fault-prone code. These fault-prone constructs have been used to find common pitfalls that occur when combining OOP and FP.

Code metrics

Common pitfalls should be detected before code enters production. Code metrics can be used to give a warning when code is likely to contain faults. Based on the fault-prone constructs we have designed new metrics to detect fault-prone code when combining OOP and FP in Scala.
 
Sven Konings, master student Computer Science at the University of Twente, will present his results during the Demo Day 2020
 
Want to know more about this thesis?
Registrate now!
 
 
Geen formulier beschikbaar.
 
Facebook   Youtube   Linkedin   Instagram   Twitter
Info Support
info@infosupport.com
www.infosupport.com
...