Automatic Assessment of Architectural
Anti-patterns and Code
Smells in Student Software Projects
Marco De Luca, Sergio Di Meglio, Anna Rita Fasolino, Luigi
Libero Lucio Starace, Porfirio Tramontana,
University of Naples “Federico II”
2nd Workshop on evaLuation and assEssment in softwARe
eNgineers’ Education and tRaining
LEARNER 2024 @ EASE 2024
Salerno, Italy, June 21st, 2024.
Motivations
 A project-based approach for teaching object-oriented
programming has many advantages:
 Provides an early introduction to software design
concepts
 Encourages students to work in groups, share
information, understand the first concept of teamworking
 Integrates multidisciplinary knowledge, e.g. Software
Engineering, Programming and Database
 Allows students to observe and appreciate the concrete
result of their work
 In our experience as teachers, the project-oriented
approach also positively affects students' performance
compared to an analytical approach
LEARNER 2024, Salerno, June 21st, 2024
Problem
LEARNER 2024, Salerno, June 21st, 2024
Students focus on
the result to be
achieved in
functional terms
The quality of the
project is often
poor
Typical Quality Issues in Student’s projects
 Architectural Issues
 Architectural patterns maintain higher the
project quality
but are often neglected by students in favour of
easier programming solutions
 Code Issues
 Clean Code recommendations are often
neglected
many code smells can be found in student’s code
LEARNER 2024, Salerno, June 21st, 2024
Our contribution:
general idea
 We have started a long-
term experimentation
aiming at:
 Measuring the
occurrence of quality
issues in student’s
projects
 Improving the teaching
by early introducing
quality concepts
 Measuring the
improvement in quality
LEARNER 2024, Salerno, June 21st, 2024
Current
Contribution
In this paper we will present
a first pilot study aiming at
measuring the occurrence of
some common architectural
and code issues in the
projects realized by all the
students of a Bachelor
Degree programming course
LEARNER 2024, Salerno, June 21st,
2024
Research questions
RQ1: How common
are architectural
pattern violations in
student projects?
RQ2: How common
are code quality
issues in student
projects?
LEARNER 2024, Salerno, June 21st, 2024
Context
 Object Oriented Programming
course
 2nd Year of Bachelor Degree in
Computer Science @ University
of Naples Federico II
 Students previously had a
first programming course at
1st year
 The course is taken in
parallel with a Database
course
 48 lecture hours (6 ECTS)
 Java language
LEARNER 2024, Salerno, June
21st, 2024
Assessment
LEARNER 2024, Salerno, June
21st, 2024
Students are divided in teams of 2 or 3
Different projects were assigned to each group
Students has to upload and present
their project after the end of the course
Only after project presentation, the students can
sustain an individual written exam, followed by
an oral exam
The completeness and correctness of
the project were mainly considered
Also the project quality influenced the teacher’s
judgement
Architectural
Issues
 During the course the
teacher presented a
specific architectural
pattern explaining its
benefits and drawbacks
 The students never
had previous
teaching about
design patterns
LEARNER 2024, Salerno, June 21st,
2024
The proposed Architectural
Pattern
 Similar to a Boundary –
Controller – Entity, with the
introduction of a DAO pattern
 4 allowed interactions
GC
CD
CM
 8 unallowed interactions
GD
GM
DC
MC
DM
LEARNER 2024, Salerno, June 21st, 2024
Measuring Architectural Pattern Violations
 ArchUnit is an open source project able to define
architectural pattern violations in form of JUnit Test
Cases
 Two of the authors implemented ArchTest cases by
substituting the name of the packages used by students in a
set of predefined test cases
LEARNER 2024, Salerno, June 21st, 2024
Code Quality Assessment
 The most popular tool for measuring code
quality issues is SonarQube
 677 Java rules
 Issues are categorized:
 By type (Bug, Vulnerability and Code Smell)
 By severity (Critical, Major, Minor, Info)
LEARNER 2024, Salerno, June 21st, 2024
Case
study
LEARNER
2024,
Salerno,
June
21st,
2024
Object Oriented
Programming
course taken in
2021/22
50 students
concluded 26
projects
Three different
projects were
proposed
Average
complexity of
the projects:
41 classes and
4647 NCLOCs
Results : RQ1
Number and percentage of projects presenting at
least one disallowed interaction
LEARNER 2024, Salerno, June 21st, 2024
Results : RQ1
Number and percentage of projects presenting at
least one disallowed interaction
LEARNER 2024, Salerno, June 21st, 2024
The direct access to model classes was a shortcut
for students but implies inestricable coupling for
the project
Results : RQ1
Number and percentage of projects presenting at
least one disallowed interaction
LEARNER 2024, Salerno, June 21st, 2024
GUI and Data Access Objects should remain
independent between them
Results : RQ2
More common code issues found by SonarQube
(number and percentage presenting at least one
occurrence of the issue)
LEARNER 2024, Salerno, June 21st, 2024
Results : RQ2
LEARNER 2024, Salerno, June 21st, 2024
 Open resources can cause performance problems
Results : RQ2
LEARNER 2024, Salerno, June 21st, 2024
 Duplicated string literals can cause incoherences during code
maintenance
 They should have been substituted by constant resources, also to ease
localization
 High Cognitive complexity makes maintenance more difficult
Results : RQ2
LEARNER 2024, Salerno, June 21st, 2024
 Log messages should be redirected to log files with an appropriate
formatting
 Unused assignments and imports and equal branches are symptoms
of code smells due to lack of code review
Results : RQ2
LEARNER 2024, Salerno, June 21st, 2024
 Naming conventions are useful to improve code understandability
Conclusions
LEARNER
2024,
Salerno,
June
21st,
2024
This first pilot experiment has
shown which types of
architectural patterns and code
issues are most common in
student projects
These preliminary results can
provide useful indications to
teachers who want to teach
concepts related to the quality of
projects regarding which are the
most common errors and the
topics to be treated with greater
insistence
Future Works
LEARNER 2024, Salerno, June
21st, 2024
To extend the experimentation to different
courses and different editions of the same
course
To measure whether more teaching about
code and architecture quality can reduce the
occurrence of issues

Automatic Assessment of Architectural Anti-patterns and Code Smells in Student Software Projects

  • 1.
    Automatic Assessment ofArchitectural Anti-patterns and Code Smells in Student Software Projects Marco De Luca, Sergio Di Meglio, Anna Rita Fasolino, Luigi Libero Lucio Starace, Porfirio Tramontana, University of Naples “Federico II” 2nd Workshop on evaLuation and assEssment in softwARe eNgineers’ Education and tRaining LEARNER 2024 @ EASE 2024 Salerno, Italy, June 21st, 2024.
  • 2.
    Motivations  A project-basedapproach for teaching object-oriented programming has many advantages:  Provides an early introduction to software design concepts  Encourages students to work in groups, share information, understand the first concept of teamworking  Integrates multidisciplinary knowledge, e.g. Software Engineering, Programming and Database  Allows students to observe and appreciate the concrete result of their work  In our experience as teachers, the project-oriented approach also positively affects students' performance compared to an analytical approach LEARNER 2024, Salerno, June 21st, 2024
  • 3.
    Problem LEARNER 2024, Salerno,June 21st, 2024 Students focus on the result to be achieved in functional terms The quality of the project is often poor
  • 4.
    Typical Quality Issuesin Student’s projects  Architectural Issues  Architectural patterns maintain higher the project quality but are often neglected by students in favour of easier programming solutions  Code Issues  Clean Code recommendations are often neglected many code smells can be found in student’s code LEARNER 2024, Salerno, June 21st, 2024
  • 5.
    Our contribution: general idea We have started a long- term experimentation aiming at:  Measuring the occurrence of quality issues in student’s projects  Improving the teaching by early introducing quality concepts  Measuring the improvement in quality LEARNER 2024, Salerno, June 21st, 2024
  • 6.
    Current Contribution In this paperwe will present a first pilot study aiming at measuring the occurrence of some common architectural and code issues in the projects realized by all the students of a Bachelor Degree programming course LEARNER 2024, Salerno, June 21st, 2024
  • 7.
    Research questions RQ1: Howcommon are architectural pattern violations in student projects? RQ2: How common are code quality issues in student projects? LEARNER 2024, Salerno, June 21st, 2024
  • 8.
    Context  Object OrientedProgramming course  2nd Year of Bachelor Degree in Computer Science @ University of Naples Federico II  Students previously had a first programming course at 1st year  The course is taken in parallel with a Database course  48 lecture hours (6 ECTS)  Java language LEARNER 2024, Salerno, June 21st, 2024
  • 9.
    Assessment LEARNER 2024, Salerno,June 21st, 2024 Students are divided in teams of 2 or 3 Different projects were assigned to each group Students has to upload and present their project after the end of the course Only after project presentation, the students can sustain an individual written exam, followed by an oral exam The completeness and correctness of the project were mainly considered Also the project quality influenced the teacher’s judgement
  • 10.
    Architectural Issues  During thecourse the teacher presented a specific architectural pattern explaining its benefits and drawbacks  The students never had previous teaching about design patterns LEARNER 2024, Salerno, June 21st, 2024
  • 11.
    The proposed Architectural Pattern Similar to a Boundary – Controller – Entity, with the introduction of a DAO pattern  4 allowed interactions GC CD CM  8 unallowed interactions GD GM DC MC DM LEARNER 2024, Salerno, June 21st, 2024
  • 12.
    Measuring Architectural PatternViolations  ArchUnit is an open source project able to define architectural pattern violations in form of JUnit Test Cases  Two of the authors implemented ArchTest cases by substituting the name of the packages used by students in a set of predefined test cases LEARNER 2024, Salerno, June 21st, 2024
  • 13.
    Code Quality Assessment The most popular tool for measuring code quality issues is SonarQube  677 Java rules  Issues are categorized:  By type (Bug, Vulnerability and Code Smell)  By severity (Critical, Major, Minor, Info) LEARNER 2024, Salerno, June 21st, 2024
  • 14.
    Case study LEARNER 2024, Salerno, June 21st, 2024 Object Oriented Programming course takenin 2021/22 50 students concluded 26 projects Three different projects were proposed Average complexity of the projects: 41 classes and 4647 NCLOCs
  • 15.
    Results : RQ1 Numberand percentage of projects presenting at least one disallowed interaction LEARNER 2024, Salerno, June 21st, 2024
  • 16.
    Results : RQ1 Numberand percentage of projects presenting at least one disallowed interaction LEARNER 2024, Salerno, June 21st, 2024 The direct access to model classes was a shortcut for students but implies inestricable coupling for the project
  • 17.
    Results : RQ1 Numberand percentage of projects presenting at least one disallowed interaction LEARNER 2024, Salerno, June 21st, 2024 GUI and Data Access Objects should remain independent between them
  • 18.
    Results : RQ2 Morecommon code issues found by SonarQube (number and percentage presenting at least one occurrence of the issue) LEARNER 2024, Salerno, June 21st, 2024
  • 19.
    Results : RQ2 LEARNER2024, Salerno, June 21st, 2024  Open resources can cause performance problems
  • 20.
    Results : RQ2 LEARNER2024, Salerno, June 21st, 2024  Duplicated string literals can cause incoherences during code maintenance  They should have been substituted by constant resources, also to ease localization  High Cognitive complexity makes maintenance more difficult
  • 21.
    Results : RQ2 LEARNER2024, Salerno, June 21st, 2024  Log messages should be redirected to log files with an appropriate formatting  Unused assignments and imports and equal branches are symptoms of code smells due to lack of code review
  • 22.
    Results : RQ2 LEARNER2024, Salerno, June 21st, 2024  Naming conventions are useful to improve code understandability
  • 23.
    Conclusions LEARNER 2024, Salerno, June 21st, 2024 This first pilotexperiment has shown which types of architectural patterns and code issues are most common in student projects These preliminary results can provide useful indications to teachers who want to teach concepts related to the quality of projects regarding which are the most common errors and the topics to be treated with greater insistence
  • 24.
    Future Works LEARNER 2024,Salerno, June 21st, 2024 To extend the experimentation to different courses and different editions of the same course To measure whether more teaching about code and architecture quality can reduce the occurrence of issues