<!DOCTYPE article PUBLIC "-//NLM//DTD JATS (Z39.96) Journal Archiving and Interchange DTD v1.0 20120330//EN" "JATS-archivearticle1.dtd">
<article xmlns:xlink="http://www.w3.org/1999/xlink">
  <front>
    <journal-meta />
    <article-meta>
      <title-group>
        <article-title>Bad Smells in Scratch Pro jects: A Preliminary Analysis</article-title>
      </title-group>
      <contrib-group>
        <contrib contrib-type="author">
          <string-name>Angela Vargas-Alba</string-name>
          <xref ref-type="aff" rid="aff1">1</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Giovanni Maria Troiano</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Quinyu Chen</string-name>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Casper Harteveld</string-name>
          <email>c.harteveldg@northeastern.edu</email>
          <xref ref-type="aff" rid="aff0">0</xref>
        </contrib>
        <contrib contrib-type="author">
          <string-name>Gregorio Robles</string-name>
          <xref ref-type="aff" rid="aff1">1</xref>
        </contrib>
        <aff id="aff0">
          <label>0</label>
          <institution>Northeastern University</institution>
          ,
          <addr-line>Boston, MA</addr-line>
          ,
          <country country="US">USA</country>
        </aff>
        <aff id="aff1">
          <label>1</label>
          <institution>Universidad Rey Juan Carlos</institution>
          ,
          <addr-line>Madrid</addr-line>
          ,
          <country country="ES">Spain</country>
        </aff>
      </contrib-group>
      <abstract>
        <p>Computational Thinking (CT) is an area of great relevance today. Although its skills may be developed in various ways, one of the most common tools to learn it, train it and develop it, is through programming. From software engineering, we know that problems solved through programming may have not been solved in the most appropriate way. These symptoms are known as \bad smells". This article aims to analyze the presence of several bad smells in Scratch projects and how they relate to the development of CT skills. Therefore, we make use of a dataset of several hundreds of Scratch projects with the aim of creating a game on climate change. Our results show that bad smells can be found in all types of Scratch projects, independently of the development of CT skills they require. We discuss why the learning community should address bad smells appropriately, as they may hinder the development of abstraction, reuse and other relevant skills.</p>
      </abstract>
    </article-meta>
  </front>
  <body>
    <sec id="sec-1">
      <title>-</title>
      <p>
        Bad (code) smells are symptoms that the problem to
be solved is not developed in the most appropriate way.
In other words, the program may run and may even
solve the problem, but it contains elements that make
it di cult to understand, to modify and to reuse [
        <xref ref-type="bibr" rid="ref9">9</xref>
        ].
      </p>
      <p>
        Martin de nes code smells as follows [
        <xref ref-type="bibr" rid="ref3">3</xref>
        ]: \Code smells
are usually not bugs; they are not technically
incorrect and do not prevent the program from
functioning. Instead, they indicate weaknesses in design that
may slow down development or increase the risk of
bugs or failures in the future." Despite the negative
e ect they produce, code smells have been little
investigated and analyzed in Computational Thinking
(CT) research. As Hermans and Aivaloglou have found
in an experiment with Scratch learners [
        <xref ref-type="bibr" rid="ref1">1</xref>
        ], we argue
that bad smells hinder the proper development of CT
skills in learners. Their identi cation should be a rst
step towards guiding learners towards good practices
that o er them the possibility to develop themselves
to their full potential.
      </p>
      <p>
        For this reason, the main motivation of this research
is to analyze to what extent bad smells are present in
Scratch projects, a block-based language that is widely
used around the globe to develop CT skills. Our
research is similar to a previous one done on LEGO
MINDSTORMS EV3 and Microsoft's Kodu [
        <xref ref-type="bibr" rid="ref2">2</xref>
        ],
expanding it with information on the complexity of the
projects. Therefore, we use Dr. Scratch, a tool that
evaluates the richness of elements used in the
programs, for evaluating the Scratch projects. Thanks
to Dr. Scratch it is possible to detect di erent types
of bad smells that are present in the code.
      </p>
      <p>The remainder of this paper is structured as follows:
In Section 2, we introduce and motivate the research
goal and research questions that we address in this
paper. A more detailed description about the de nition
of bad smells is summarized in Section 3. Section 4
and Section 5 describe the data set used in the study,
as well as the functionality and design of Dr. Scratch
in more detail. Section 6 shows the results obtained
after the analysis and in Section 7 a discussion is
proposed based on it. Limitations and problems found
are described in Section 7.1. Finally, Section 8
contains the main conclusions and future work that we
envision.</p>
    </sec>
    <sec id="sec-2">
      <title>Research Goal and Questions</title>
      <p>The main objective of this paper is to analyze the
presence of bad smells in a large set of Scratch
projects.</p>
      <p>For this, the research questions that we want to
address are as follows:</p>
      <p>RQ1. To what extent are bad habits present
in Scratch projects?</p>
      <p>In particular, we answer this question by o ering
the percentage of projects that have at least one type
of bad smell. This question allows to see how frequent
projects show a bad smell, hinting to the relevance of
the topic. We expect a signi cant number of projects
to contain bad smells.</p>
      <p>RQ2. Does the development of CT skills
relate to the presence of bad smells?</p>
      <p>We would like to nd out if the presence of bad
smells correlates with the complexity of the projects.
Our hypothesis is that projects that have higher
degrees of CT development will have less bad smells, as
these may hinder the development of CT skills.</p>
      <p>RQ3. Do projects with more blocks have a
higher number of bad smells?</p>
      <p>More complex projects usually have more blocks.
Thus having a single bad smell in a small, simple
project may have less impact than in a project with
hundreds of blocks. In the former case, the impact
could be big, while in the latter it could be seen as an
exception, with little impact.</p>
      <p>To answer this question, for projects of the same
level of CT development we calculate the ratio of the
number of bad smells detected to the total number of
blocks. We expect that this ratio decreases with an
increase in the development of CT skills required to
create the Scratch projects.</p>
      <p>RQ4. Can we nd a relation among speci c
bad smells?</p>
      <p>As by now, we have considered all type of bad smells
together. In this question, we dig into each of them
separately. It may be possible that some bad smells
appear more frequently in projects of lower complexity,
while others appear in more complex projects.</p>
      <p>RQ5. To which extent can bad smells
be identi ed in each of the CT development
phases?</p>
      <p>Related to the previous question, we analyze how
the di erent bad smell types appear in projects in the
di erent stages of CT development. Therefore, we
consider projects with a low complexity (basic), medium
complexity (developing) and major complexity (pro
ciency) and compute how often they contain a speci c
type of bad smell.</p>
      <p>We expect that several types of bad smells appear in
the early phases (basic), while others are more
prominent in more complex projects (pro ciency). We
assume therefore that learners that achieve higher levels
of complexity have overcome certain bad smells due
to having developed certain CT skills, while other bad
smells appear in those more complex projects.
3</p>
    </sec>
    <sec id="sec-3">
      <title>Bad smells in Scratch</title>
      <p>
        Scratch is a visual programming language formed by
di erent blocks, designed for children and beginner
programmers, which contains di erent bad smells
related to the use of these blocks [
        <xref ref-type="bibr" rid="ref6">6</xref>
        ].
      </p>
      <p>
        In our research, we have identi ed four di erent
types of bad smells that can be present in Scratch
projects: copy and pasted code (duplicate scripts) [
        <xref ref-type="bibr" rid="ref7">7</xref>
        ],
the use of default names for sprites (default names),
code that is never being executed (dead code), and
variables that are not correctly initialized (attribute
initialization). Their characteristics and impact are
summarized in Table 1.
4
      </p>
    </sec>
    <sec id="sec-4">
      <title>Research Context</title>
      <p>
        In order to analyze the presence of bad smells, as well
as their relationship with the level that users have in
CT development, a large set of projects is necessary.
The data set used in this article is the same which was
used for another, previous research [
        <xref ref-type="bibr" rid="ref8">8</xref>
        ]. A group of
438 students designed games for STEM using Scratch
2.0. During this process, we obtained snapshots of the
process, in di erent periods of time, in order to show
a temporary evolution1. The total number of projects
without taking into account the replicas over time, is
711. As a result, the complete data set is comprised
of 62,074 projects formed by the snapshots. With the
total data set, we wanted to analyze the same 711
projects in di erent points of time.
      </p>
      <p>
        All these snapshots were analyzed with Dr. Scratch,
of which 2,158 were erroneous in the analysis for
different reasons: the project was saved incorrectly, the
code contained special characters, etc. The nal set
of projects analyzed was 59,916 (further details can be
found in [
        <xref ref-type="bibr" rid="ref8">8</xref>
        ]).
5
      </p>
    </sec>
    <sec id="sec-5">
      <title>Methodology</title>
      <p>
        We have taken all snapshots of the Scratch projects
and have analyzed them with Dr. Scratch. Dr.
Scratch is a web-based tool that analyzes di erent
categories related to computational thinking based on the
blocks of the Scratch projects [
        <xref ref-type="bibr" rid="ref4">4</xref>
        ] (a screenshot of their
main web page can be seen in Figure 1). It analyzes
the code and, depending of the diversity of blocks used,
the application gives a score to the project.
      </p>
      <p>1https://drive.google.com/drive/u/0/folders/
1tDI6nx2f6344xJAKeUeWBeTg0YzxE3bO</p>
      <sec id="sec-5-1">
        <title>Bad Smell Type Duplicate scripts</title>
      </sec>
      <sec id="sec-5-2">
        <title>Default names</title>
      </sec>
      <sec id="sec-5-3">
        <title>Dead code</title>
      </sec>
      <sec id="sec-5-4">
        <title>Attribute initialization</title>
        <p>The outcome is a numeric punctuation based on
seven categories of computational thinking:
parallelism, logical thinking, ow control, user interactivity,
data representation, abstraction and synchronization.
For each of these abilities a project can obtain a
punctuation from 0 to 3 points, according to the di erent
blocks used in the Scratch project. In this way, the
nal punctuation can be from 0 to 21 total points.</p>
        <p>Based on that, there are three di erent pro les of
leaner: between 0 and 7 points, Basic, between 8 and
15, Developing and between 16 and 21, Pro ciency.</p>
        <p>Once the project is analyzed, the application will
show di erent dashboards with these results, as it is
possible to see in the Figure 2.</p>
        <p>In addition to the former, Dr. Scratch identi es the
four types of bad smells that we study in this work.
6</p>
      </sec>
    </sec>
    <sec id="sec-6">
      <title>Results</title>
      <p>In this Section we describe the results obtained from
addressing our research questions using the previously</p>
      <p>We expected a high share of projects having bad
smells, but this result is a surprise for us, as the
presence of bad smells is not only more frequent than
expected, but almost general.
6.2</p>
      <p>Does the development of CT skills relate
to a minor presence of bad smells?
they share a ratio of around 0.5 up to 21 points, where
the ratio is over 1).</p>
      <p>We have analyzed in more detail those projects that
have and do not bad smells. In particular, we want
to see how the complexity of the projects is related
to having a bad smell. We use the mastery required
to create a project, as measured by Dr. Scratch, as a
proxy for the complexity of the project.</p>
      <p>In Figure 3 we can observe the distribution of each
set of projects. We can observe that more than 50% of
those projects with not bad smells have a total mastery
of 0. In other words, these are skeleton projects
without any content. The amount of projects with content
and without any bad smell is therefore even lower than
calculated in the previous research question. In
addition, we see that projects with no bad smells are in the
lower part of the complexity ladder.</p>
      <p>In summary, bad smells in Scratch can be found in
almost all projects. Only a small set of projects with
low complexity do not have them.
6.3</p>
      <p>Do projects with more blocks have a
higher number of bad smells?
One could argue that projects with more complexity
(those with higher values of CT score in Dr. Scratch)
usually have more blocks, and that the impact of a
code smell there is lower than in less complex projects.
In other words, even if more complex projects have
bad smells, their presence is mitigated by the fact that
these are large projects. This would imply that
achieving high values of CT development means to have less
bad smells.</p>
      <p>Figure 4 visually shows the number of blocks for
all projects for a given CT score (blue line) and the
number of bad smells in those projects. Both curves
have been normalized to their maximum values. We
can observe how the two curves run almost in parallel
(up to 8 points they share the same ratio, and then</p>
      <p>nd a relation among speci c bad
From Figure 5 (again, this graph is normalized), we
can observe that the four di erent types of bad smells
that we have studied have a similar distribution
below the pro ciency level. The presence of bad smells
has a similar behavior for projects up to 17 points of
mastery. Then, when the mastery is above 17 points,
the behavior of each of them is di erent: While
duplicated scripts and bad attribute initialization continue
to slightly grow, the number of dead code blocks grows
more abrupt way. However, and the number of default
names decreases considerably. This last trend may be
because in projects with a high number of blocks and
objects it is more di cult to program with the default
names (Sprite 1, Sprite 2, etc) instead of personalizing
them.
6.5</p>
      <p>To which extent can bad smells be
identi ed in each of the CT development
phases?
As already seen wit RQ3, the number of bad smells
is higher when the total mastery increases. In Figure
6, we have represented the percentage of projects that
have at least a speci c type of bad smell for each level
of CT pro ciency. The percentage of projects from
users with the basic level that have bad smells is much
smaller than the percentage of projects that require
a pro ciency level. This result indicates that all bad
smells have an incremental evolution with the increase
of CT e ciency. So, it seems that bad smells appear
in early phases and instead of disappearing with the
We have observed that bad smells are very common in
Scratch projects. The results indicate as well that bad
smells do not limit the development of a project,
because it is possible to create projects at the pro ciency
level even with a large amount of bad smells.</p>
      <p>We argue that researchers, educators and learners
should devote more e ort in avoiding the presence of
bad smells in learning projects. The very nature of bad
smells makes them di cult to identify. They are not
errors and a program could run perfectly having many
of them. However, their e ects are very well known in
Software Engineering research. These e ects are in the
long term, when maintainability of a software system
is considered. In such a situation, the software has to
be understood and changed, and in that situation is
where these bad smells become more prominent. The
large presence of bad smells indicates that
understanding and changing code is not among the priorities of
the projects under study, although \good code" has
always been considered as that one that is easy to
understand and to change. That is why we think that
with the current presence of bad smells learners do not
achieve their full potential of CT development skills.
In our opinion, further research and tools should be
envisioned and created to address this issue.
7.1</p>
      <p>Limitations
As any research, our work comes with a number of
limitations that can be seen as threats to its validity.</p>
      <p>
        The rst one is related to our methodology, and in
particular to the limited set of bad smells that we can
identify. We are sure that many other types of bad
smells could be thought of in Scratch. On the other
hand, we use as complexity metrics the CT scores
provided by Dr. Scratch. While there have been some
research that has studied how Dr. Scratch correlates
with other complexity metrics [
        <xref ref-type="bibr" rid="ref5">5</xref>
        ], this is always a
correlation and not causation.
      </p>
      <p>We have studied projects from a speci c
environment, which may not be representative for all Scratch
projects, so the generalization of results is a threat to
validity. However, it should be noted that this is a case
study, with the aim to raise attention on this matter.
We should analyze a wider data set which includes
di erent sectors of programming with Scratch, such as
stories, music, animations, among others. We do not
know if the behavior of bad smells could be di erent
in other areas of programming.
8</p>
    </sec>
    <sec id="sec-7">
      <title>Conclusions</title>
      <p>Bad smells are common in Scratch projects, from basic
to pro cient. As the complexity increases, bad smells
do not disappear, so learners can create projects that
demand a high development of CT skills having bad
smells in them.</p>
      <p>We ask for further research on this topic.</p>
    </sec>
    <sec id="sec-8">
      <title>Acknowledgments</title>
      <p>This work has been co-funded by the Madrid
Regional Government, through the project
e-MadridCM (P2018/TCS-4307). The e-Madrid-CM project
is also co- nanced by the Structural Funds (FSE and
FEDER).</p>
    </sec>
  </body>
  <back>
    <ref-list>
      <ref id="ref1">
        <mixed-citation>
          [1]
          <string-name>
            <given-names>F.</given-names>
            <surname>Hermans</surname>
          </string-name>
          and
          <string-name>
            <surname>E. Aivaloglou.</surname>
          </string-name>
          <article-title>Do code smells hamper novice programming? a controlled experiment on scratch programs</article-title>
          .
          <source>In 2016 IEEE 24th International Conference on Program Comprehension (ICPC)</source>
          , pages
          <fpage>1</fpage>
          <lpage>{</lpage>
          10. IEEE,
          <year>2016</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref2">
        <mixed-citation>
          [2]
          <string-name>
            <given-names>F.</given-names>
            <surname>Hermans</surname>
          </string-name>
          ,
          <string-name>
            <given-names>K. T.</given-names>
            <surname>Stolee</surname>
          </string-name>
          , and
          <string-name>
            <given-names>D.</given-names>
            <surname>Hoepelman</surname>
          </string-name>
          .
          <article-title>Smells in block-based programming languages</article-title>
          .
          <source>In 2016 IEEE Symposium on Visual Languages and Human-Centric Computing (VL/HCC)</source>
          , pages
          <fpage>68</fpage>
          {
          <fpage>72</fpage>
          . IEEE,
          <year>2016</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref3">
        <mixed-citation>
          [3]
          <string-name>
            <given-names>R. C.</given-names>
            <surname>Martin</surname>
          </string-name>
          .
          <article-title>Clean code: a handbook of agile software craftsmanship</article-title>
          .
          <source>Pearson Education</source>
          ,
          <year>2009</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref4">
        <mixed-citation>
          [4]
          <string-name>
            <given-names>J.</given-names>
            <surname>Moreno-Leon</surname>
          </string-name>
          ,
          <string-name>
            <given-names>G.</given-names>
            <surname>Robles</surname>
          </string-name>
          , et al.
          <article-title>Analyze your scratch projects with dr. scratch and assess your computational thinking skills</article-title>
          .
          <source>In Scratch conference</source>
          , pages
          <volume>12</volume>
          {
          <fpage>15</fpage>
          ,
          <year>2015</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref5">
        <mixed-citation>
          [5]
          <string-name>
            <given-names>J.</given-names>
            <surname>Moreno-Leon</surname>
          </string-name>
          ,
          <string-name>
            <given-names>G.</given-names>
            <surname>Robles</surname>
          </string-name>
          , and
          <string-name>
            <given-names>M.</given-names>
            <surname>RomanGonzalez</surname>
          </string-name>
          .
          <article-title>Comparing computational thinking development assessment scores with software complexity metrics</article-title>
          .
          <source>In 2016 IEEE global engineering education conference (EDUCON)</source>
          , pages
          <fpage>1040</fpage>
          {
          <fpage>1045</fpage>
          . IEEE,
          <year>2016</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref6">
        <mixed-citation>
          [6]
          <string-name>
            <given-names>M.</given-names>
            <surname>Resnick</surname>
          </string-name>
          ,
          <string-name>
            <given-names>J.</given-names>
            <surname>Maloney</surname>
          </string-name>
          ,
          <string-name>
            <given-names>A.</given-names>
            <surname>Monroy-Hernandez</surname>
          </string-name>
          ,
          <string-name>
            <given-names>N.</given-names>
            <surname>Rusk</surname>
          </string-name>
          ,
          <string-name>
            <given-names>E.</given-names>
            <surname>Eastmond</surname>
          </string-name>
          ,
          <string-name>
            <given-names>K.</given-names>
            <surname>Brennan</surname>
          </string-name>
          ,
          <string-name>
            <given-names>A.</given-names>
            <surname>Millner</surname>
          </string-name>
          ,
          <string-name>
            <given-names>E.</given-names>
            <surname>Rosenbaum</surname>
          </string-name>
          ,
          <string-name>
            <given-names>J. S.</given-names>
            <surname>Silver</surname>
          </string-name>
          ,
          <string-name>
            <given-names>B.</given-names>
            <surname>Silverman</surname>
          </string-name>
          , et al.
          <article-title>Scratch: Programming for all</article-title>
          .
          <source>Commun. Acm</source>
          ,
          <volume>52</volume>
          (
          <issue>11</issue>
          ):
          <volume>60</volume>
          {
          <fpage>67</fpage>
          ,
          <year>2009</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref7">
        <mixed-citation>
          [7]
          <string-name>
            <given-names>G.</given-names>
            <surname>Robles</surname>
          </string-name>
          ,
          <string-name>
            <given-names>J.</given-names>
            <surname>Moreno-Leon</surname>
          </string-name>
          ,
          <string-name>
            <given-names>E.</given-names>
            <surname>Aivaloglou</surname>
          </string-name>
          , and
          <string-name>
            <given-names>F.</given-names>
            <surname>Hermans</surname>
          </string-name>
          .
          <article-title>Software clones in scratch projects: On the presence of copy-and-paste in computational thinking learning</article-title>
          .
          <source>In 2017 IEEE 11th International Workshop on Software Clones (IWSC)</source>
          , pages
          <fpage>1</fpage>
          <article-title>{7</article-title>
          . IEEE,
          <year>2017</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref8">
        <mixed-citation>
          [8]
          <string-name>
            <given-names>G. M.</given-names>
            <surname>Troiano</surname>
          </string-name>
          ,
          <string-name>
            <given-names>S.</given-names>
            <surname>Snodgrass</surname>
          </string-name>
          , E. Arg mak, G. Robles,
          <string-name>
            <given-names>G.</given-names>
            <surname>Smith</surname>
          </string-name>
          ,
          <string-name>
            <given-names>M.</given-names>
            <surname>Cassidy</surname>
          </string-name>
          ,
          <string-name>
            <given-names>E.</given-names>
            <surname>Tucker-Raymond</surname>
          </string-name>
          ,
          <string-name>
            <given-names>G.</given-names>
            <surname>Puttick</surname>
          </string-name>
          , and
          <string-name>
            <given-names>C.</given-names>
            <surname>Harteveld</surname>
          </string-name>
          .
          <article-title>Is my game ok dr. scratch?: Exploring programming and computational thinking development via metrics in studentdesigned serious games for stem</article-title>
          .
          <source>In Proceedings of the 18th ACM International Conference on Interaction Design and Children</source>
          , pages
          <volume>208</volume>
          {
          <fpage>219</fpage>
          . ACM,
          <year>2019</year>
          .
        </mixed-citation>
      </ref>
      <ref id="ref9">
        <mixed-citation>
          [9]
          <string-name>
            <given-names>M.</given-names>
            <surname>Zhang</surname>
          </string-name>
          , T. Hall, and
          <string-name>
            <given-names>N.</given-names>
            <surname>Baddoo</surname>
          </string-name>
          .
          <article-title>Code bad smells: a review of current knowledge</article-title>
          .
          <source>Journal of Software Maintenance and Evolution: research and practice</source>
          ,
          <volume>23</volume>
          (
          <issue>3</issue>
          ):
          <volume>179</volume>
          {
          <fpage>202</fpage>
          ,
          <year>2011</year>
          .
        </mixed-citation>
      </ref>
    </ref-list>
  </back>
</article>