Code smells, we all know them, and they are bad 🙂 We know from research on professional developers that code smell can make performance on reading and maintaining code worse. So the question we wanted to answer was: does this hold for novice users programming Scratch as well? tr;dr: Yes! Code clones and long methods make performance worse, but for different reasons.
We recruited 3 high school classes in Delft with kids aged 12 to 14, in total consisting of 61 kids. In the study the kids got 1 hour of introductory Scratch lessons from us, after which the real experiment started. We divided the kids into 3 groups, which had to answer questions on the same Scratch program (a Pong game) But, here is the catch, we made one program as nice as possible, in the other two we purposely put code clones (“duplication smell”) and in the other we made a very long script (“long method smell”) We then measured how well the kids did one three types of tasks: explaining short pieces of code, explaining the system as a whole and adapting the code.
Most of them had no prior experience to programming (14 did Scratch before, 2 did Mindstorms). To be fair we put the experienced kids in different groups equally.
Turns out: kids do worse on smelly programs, but in different ways. We found that long method hurts kids abilities to understand the code, but that code clones especially harm performance when kids have to maintain. Clones can even be helpful when they need to explain the code. This might be explained by the fact that some pieces of information can be found in multiple places, so it is easier to find it. For example in our study we asked kids what the maximum number of points was and this info could be found in all sprites in the “duplication” version.
I want to know even more!
Awesome, you can read the whole paper (preprint).
I am a teacher of Dutch speaking children between 8 and 14, or a parent of one and I would love to help you do more research like this!
More awesome!! Could you fill out this form and I will get back to you.
Cite this paper as follows:
Do Code Smells Hamper Novice Programming? Felienne Hermans, Efthimia Aivaloglou. In Proceedings of the International Conference on Program Comprehension, 2016. To appear.