Code comments support developers in understanding and maintaining codebases. Specifically in the Pharo environment, code comments serve as the main form of code documentation and usually convey information ranging from high-level design descriptions to low-level implementation details. Nevertheless, numerous important classes in Pharo still lack comments as developers find writing comments to be a tedious and effort-intensive task. Previous works in Java have recommended generating comments automatically to reduce commenting effort and save developers time. There exist several approaches to achieve this goal. One such popular approach is based on identifying stereotypes, i.e., a generalized set of characteristics supposed to represent an entity (object, class). However, this approach has not been tested for other programming languages. In this paper, we adopt the stereotype-based approach to automatically generate class comments in the Pharo programming environment.
Can We Automatically Generate Class Comments in Pharo?
1. Can We Automatically Generate Class
Comments in Pharo?
Pooja Rani, Alexandre Bergel,
Lino Hess, Timo Kehrer, Oscar Nierstrasz
University of Bern, Switzerland
International Workshop on Smalltalk Technologies,
Novi Sad, Serbia, 2022
5. 5
To support developers in writing comments,
communities suggest coding guidelines
Apache
Oracle
Google Pharo
PEP8/257
6. 6
To support developers in writing comments,
communities suggest coding guidelines
Apache
Oracle
Google Pharo
PEP8/257
7. 7
To support developers in writing comments,
communities suggest coding guidelines
Apache
Oracle
Google Pharo
PEP8/257
8. 8
To support developers in writing comments,
communities suggest coding guidelines
Apache
Oracle
Google Pharo
PEP8/257
9. 9
- Rani et al., Empirical Software Engineering, 2021
Developers follow template inspired information types more often
To support developers in writing comments,
communities suggest coding guidelines
Apache
Oracle
Google Pharo
PEP8/257
10. 10
Color scale according to number of comments falling into a category
0 25 52
0 26 52
1 (52)
2 (52)
3 (52)
4 (52)
5 (52)
6 (52)
7 (52)
O
t
h
e
r
L
i
c
e
n
s
e
D
e
p
e
n
d
e
n
c
i
e
s
C
o
n
t
r
a
c
t
s
O
b
s
e
r
v
a
t
i
o
n
s
R
e
c
o
m
m
e
n
d
a
t
i
o
n
s
E
x
t
e
n
s
i
o
s
L
i
n
k
s
D
i
s
c
o
u
r
s
e
W
a
r
n
i
n
g
s
C
o
d
i
n
g
G
u
i
d
e
l
i
n
e
s
N
a
m
i
n
g
C
o
n
v
e
n
t
i
o
n
s
T
o
d
o
c
o
m
m
e
n
t
s
C
l
a
s
s
R
e
f
e
r
e
n
c
e
s
S
u
b
c
l
a
s
s
e
s
E
x
p
l
a
n
a
t
i
o
n
R
e
f
e
r
e
n
c
e
O
t
h
e
r
R
e
s
o
u
r
c
e
s
I
m
p
l
e
m
e
n
t
a
t
i
o
n
P
o
i
n
t
s
E
x
a
m
p
l
e
s
K
e
y
M
e
s
s
a
g
e
s
I
n
s
t
a
n
c
e
V
a
r
i
a
b
l
e
s
C
o
l
l
a
b
a
r
t
o
r
s
R
e
s
p
o
n
s
i
b
i
l
i
t
y
I
n
t
e
n
t
Categories
Pharo
versions
(total
classes)
Developers follow template inspired information types more often
- Rani et al., Empirical Software Engineering, 2021
11. 11
Can we automatically generate these information types?
Color scale according to number of comments falling into a category
0 25 52
0 26 52
1 (52)
2 (52)
3 (52)
4 (52)
5 (52)
6 (52)
7 (52)
O
t
h
e
r
L
i
c
e
n
s
e
D
e
p
e
n
d
e
n
c
i
e
s
C
o
n
t
r
a
c
t
s
O
b
s
e
r
v
a
t
i
o
n
s
R
e
c
o
m
m
e
n
d
a
t
i
o
n
s
E
x
t
e
n
s
i
o
s
L
i
n
k
s
D
i
s
c
o
u
r
s
e
W
a
r
n
i
n
g
s
C
o
d
i
n
g
G
u
i
d
e
l
i
n
e
s
N
a
m
i
n
g
C
o
n
v
e
n
t
i
o
n
s
T
o
d
o
c
o
m
m
e
n
t
s
C
l
a
s
s
R
e
f
e
r
e
n
c
e
s
S
u
b
c
l
a
s
s
e
s
E
x
p
l
a
n
a
t
i
o
n
R
e
f
e
r
e
n
c
e
O
t
h
e
r
R
e
s
o
u
r
c
e
s
I
m
p
l
e
m
e
n
t
a
t
i
o
n
P
o
i
n
t
s
E
x
a
m
p
l
e
s
K
e
y
M
e
s
s
a
g
e
s
I
n
s
t
a
n
c
e
V
a
r
i
a
b
l
e
s
C
o
l
l
a
b
a
r
t
o
r
s
R
e
s
p
o
n
s
i
b
i
l
i
t
y
I
n
t
e
n
t
Categories
Pharo
versions
(total
classes)
12. 12
Objects are responsible members of an
object community
Rebecca Wirfs-Brock
Object role stereotypes in 1992 in a Smalltalk Report article
13. 13
Objects are responsible members of an
object community
Rebecca Wirfs-Brock
Object role stereotypes in 1992 in a Smalltalk Report article
28. 28
• External used methods
• Internally used methods
Method Information
3
• Class name
• Class stereotype description
• Classes used by the class
• Dependent classes
• Relevant keywords
Class Information
4
Small
Controller
Pure Controller
Large
Lazy
Degenerate
Data
otypes
reational
ollaborator
egnerate
ontroller
eotypes
29. 29
• External used methods
• Internally used methods
Method Information
3
• Class name
• Class stereotype description
• Classes used by the class
• Dependent classes
• Relevant keywords
Class Information
4
Small
Controller
Pure Controller
Large
Lazy
Degenerate
Data
otypes
reational
ollaborator
egnerate
ontroller
eotypes
30. 30
• External used methods
• Internally used methods
Method Information
3
• Class name
• Class stereotype description
• Classes used by the class
• Dependent classes
• Relevant keywords
Class Information
4
Small
Controller
Pure Controller
Large
Lazy
Degenerate
Data
otypes
reational
ollaborator
egnerate
ontroller
eotypes
31. 31
24 class comments (auto generated)
3 developers: each comment evaluated by three
42 evaluations: 7 developers completed it
3 metrics: Adequacy, Conciseness, Comprehensibility
Evaluation
33. 33
Conciseness- 54% participants said the comment contains a lot of
unnecessary information
Evaluation
Adequacy: 44% participants said the comment is missing some important information