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

PorfirioTramontana 447 views 24 slides Jul 20, 2024
Slide 1
Slide 1 of 24
Slide 1
1
Slide 2
2
Slide 3
3
Slide 4
4
Slide 5
5
Slide 6
6
Slide 7
7
Slide 8
8
Slide 9
9
Slide 10
10
Slide 11
11
Slide 12
12
Slide 13
13
Slide 14
14
Slide 15
15
Slide 16
16
Slide 17
17
Slide 18
18
Slide 19
19
Slide 20
20
Slide 21
21
Slide 22
22
Slide 23
23
Slide 24
24

About This Presentation

When teaching Programming and Software Engineering in Bachelor’s
Degree programs, the emphasis on creating functional software
projects often overshadows the focus on software quality, a
trend consistent with ACM curricula recommendations. Dedicated
Software Engineering courses take typically plac...


Slide Content

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” 2 nd Workshop on evaLuation and assEssment in softwARe eNgineers’ Education and tRaining LEARNER 2024 @ EASE 2024 Salerno, Italy, June 21 st , 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

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 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

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

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