SlideShare a Scribd company logo
1 of 18
Do Comments follow commenting
conventions? A case study in Java and
Python
Pooja Rani, Suada Abukar, Nataliia Stulova, 

Alexandre Bergel, Oscar Nierstrasz
University of Bern, Switzerland
2
/** Event fired when a spacer element is hidden or shown in Escalator

*
 

* @author Vaadin Lt
d

* @since 7.7.13
 

*
/

public class SpacerVisibili
{

System.out.println(..)
;

}
3
// This class fires an Event when a spacer element is hidden or shown in
the Escalator. I am the author of this class
.

// It is present in the project since the version 7.7.13 and might
delete in the next versions.
 

public class SpacerVisibili
{

System.out.println(..)
;

}
No strict convention for their style & syntax
4
E.g., Oracle comment guidelines


Coding Style guidelines
First sentence should summarise the class


Use phrases instead of complete sentences


Use third person instead of second person
/** Event fired when a spacer element is hidden or shown in Escalator

*
 

* @author Vaadin Lt
d

* @since 7.7.13
 

*/
5
Does this comment
follow the guidelines?
Does it not?
First sentence should summarise the class


Use phrases instead of complete sentences


Use third person instead of second person
Do developers follow these guidelines?
/** Event fired when a spacer element is hidden or shown in Escalator

*
 

* @author Vaadin Lt
d

* @since 7.7.13
 

*/
6
Does this comment
follow the guidelines?
Does it not?
First sentence should summarise the class


Use phrases instead of complete sentences


Use third person instead of second person
7
Analyzed Smalltalk class comments against the
style guidelines but what about other
languages? Java, Python
Analyzed Java and Python class comments
but not against the style guidelines.
Methodology Dataset
Do developers follow commenting guidelines for Java
and Python comments?
Previous works by Rani et.al.,
8
Apache Hadoop
Apache Spark
Eclipse.cdt
Google Guava
Google Guice
Django
iPython
Mailpile
Pandas
Pipenv
PyTorch
Requests
Dataset
9
Extracting
guidelines
Identifying


rules
Validate comments
Create
taxonomy
Class
comments
Projects
1
2 3 4 5
Methodology
10
Apache Hadoop
Apache Spark
Eclipse.cdt
Google Guava
Google Guice
Django
Pipenv
Mailpile
Request
iPython
Pandas
PyTorch
Oracle
Google
PEP8/257
Numpy
Google
1 Extracting guidelines
11
●PEP 257 -- Docstring Conventions | Python.org
2 Identifying rules
12
●PEP 257 -- Docstring Conventions | Python.org
3
Content Formatting Content
Formatting
Formatting
Formatting
Create taxonomy
13
Content rules are more prevalent in style guidelines
but hard to locate
RQ1: Types of comment conventions?
14
Developers do not always adopt comment conventions
(Not applicable rules)
49%
16%
47%
11%
54%
49%
38%
27%
32%
25%
24%
63%
53%
7%
2%
10%
3%
6%
10%
12%
3%
3%
2%
2%
3%
2%
44%
83%
43%
86%
40%
42%
50%
70%
65%
73%
74%
35%
45%
Django
iPython
Mailpile
Pandas
Pipenv
Pytorch
Requests
Eclipse
Vaadin
Spark
Hadoop
Guava
Guice
Python
Java
Followed rules Not followed rules Not applicable rules
RQ2: Do developers follow conventions?
15
/** @author Vaadin Ltd 

*
 

* @since 7.7.13
 

*/
First sentence should summarise the class


Use phrases instead of complete sentences


Use third person instead of second person
RQ2: Do developers follow conventions?
27%
32%
25%
24%
63%
53%
3%
3%
2%
2%
3%
2%
70%
65%
73%
74%
35%
45%
se
in
rk
op
va
ce
Followed rules Not followed rules Not applicable rules
63%
53%
3%
3%
2%
2%
3%
2%
70%
65%
73%
74%
35%
45%
ules Not followed rules Not applicable rules
49%
16%
47%
11%
54%
49%
38%
27%
32%
25%
24%
63%
53%
7%
2%
10%
3%
6%
10%
12%
3%
3%
2%
2%
3%
2%
44%
83%
43%
86%
40%
42%
50%
70%
65%
73%
74%
35%
45%
Django
iPython
Mailpile
Pandas
Pipenv
Pytorch
Requests
Eclipse
Vaadin
Spark
Hadoop
Guava
Guice
Python
Java
Followed rules Not followed rules Not applicable rules
16
Comments often follow writing style and content
rules than other rule types
RQ2: Do developers follow conventions?
17
Verify other types of comments (Method, inline comments)


Verify comments of other languages (C++, JavaScript)


Develop tools to validate comments against the guidelines


Improve comment quality assessment
Future work
Preprint on Arxiv

https://arxiv.org/pdf/2108.10766v2

Video on YouTube

https://youtu.be/mX_9XxQTSxQ

Replication Package on Zenodo

https://doi.org/10.5281/zenodo.5296443

Contact us

18
https://twitter.com/poojaruhal http://scg.unibe.ch/staff
Do Comments follow Commenting Conventions?
A Case Study in Java and Python

More Related Content

Recently uploaded

Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
panagenda
 
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc
 
Harnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptx
Harnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptxHarnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptx
Harnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptx
FIDO Alliance
 

Recently uploaded (20)

Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
Easier, Faster, and More Powerful – Alles Neu macht der Mai -Wir durchleuchte...
 
Portal Kombat : extension du réseau de propagande russe
Portal Kombat : extension du réseau de propagande russePortal Kombat : extension du réseau de propagande russe
Portal Kombat : extension du réseau de propagande russe
 
WebRTC and SIP not just audio and video @ OpenSIPS 2024
WebRTC and SIP not just audio and video @ OpenSIPS 2024WebRTC and SIP not just audio and video @ OpenSIPS 2024
WebRTC and SIP not just audio and video @ OpenSIPS 2024
 
Generative AI Use Cases and Applications.pdf
Generative AI Use Cases and Applications.pdfGenerative AI Use Cases and Applications.pdf
Generative AI Use Cases and Applications.pdf
 
TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...
TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...
TEST BANK For, Information Technology Project Management 9th Edition Kathy Sc...
 
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
TrustArc Webinar - Unified Trust Center for Privacy, Security, Compliance, an...
 
Design Guidelines for Passkeys 2024.pptx
Design Guidelines for Passkeys 2024.pptxDesign Guidelines for Passkeys 2024.pptx
Design Guidelines for Passkeys 2024.pptx
 
Easier, Faster, and More Powerful – Notes Document Properties Reimagined
Easier, Faster, and More Powerful – Notes Document Properties ReimaginedEasier, Faster, and More Powerful – Notes Document Properties Reimagined
Easier, Faster, and More Powerful – Notes Document Properties Reimagined
 
Event-Driven Architecture Masterclass: Engineering a Robust, High-performance...
Event-Driven Architecture Masterclass: Engineering a Robust, High-performance...Event-Driven Architecture Masterclass: Engineering a Robust, High-performance...
Event-Driven Architecture Masterclass: Engineering a Robust, High-performance...
 
Continuing Bonds Through AI: A Hermeneutic Reflection on Thanabots
Continuing Bonds Through AI: A Hermeneutic Reflection on ThanabotsContinuing Bonds Through AI: A Hermeneutic Reflection on Thanabots
Continuing Bonds Through AI: A Hermeneutic Reflection on Thanabots
 
Design and Development of a Provenance Capture Platform for Data Science
Design and Development of a Provenance Capture Platform for Data ScienceDesign and Development of a Provenance Capture Platform for Data Science
Design and Development of a Provenance Capture Platform for Data Science
 
Human Expert Website Manual WCAG 2.0 2.1 2.2 Audit - Digital Accessibility Au...
Human Expert Website Manual WCAG 2.0 2.1 2.2 Audit - Digital Accessibility Au...Human Expert Website Manual WCAG 2.0 2.1 2.2 Audit - Digital Accessibility Au...
Human Expert Website Manual WCAG 2.0 2.1 2.2 Audit - Digital Accessibility Au...
 
Top 10 CodeIgniter Development Companies
Top 10 CodeIgniter Development CompaniesTop 10 CodeIgniter Development Companies
Top 10 CodeIgniter Development Companies
 
Overview of Hyperledger Foundation
Overview of Hyperledger FoundationOverview of Hyperledger Foundation
Overview of Hyperledger Foundation
 
2024 May Patch Tuesday
2024 May Patch Tuesday2024 May Patch Tuesday
2024 May Patch Tuesday
 
Event-Driven Architecture Masterclass: Integrating Distributed Data Stores Ac...
Event-Driven Architecture Masterclass: Integrating Distributed Data Stores Ac...Event-Driven Architecture Masterclass: Integrating Distributed Data Stores Ac...
Event-Driven Architecture Masterclass: Integrating Distributed Data Stores Ac...
 
How we scaled to 80K users by doing nothing!.pdf
How we scaled to 80K users by doing nothing!.pdfHow we scaled to 80K users by doing nothing!.pdf
How we scaled to 80K users by doing nothing!.pdf
 
WebAssembly is Key to Better LLM Performance
WebAssembly is Key to Better LLM PerformanceWebAssembly is Key to Better LLM Performance
WebAssembly is Key to Better LLM Performance
 
Harnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptx
Harnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptxHarnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptx
Harnessing Passkeys in the Battle Against AI-Powered Cyber Threats.pptx
 
How to Check GPS Location with a Live Tracker in Pakistan
How to Check GPS Location with a Live Tracker in PakistanHow to Check GPS Location with a Live Tracker in Pakistan
How to Check GPS Location with a Live Tracker in Pakistan
 

Featured

How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
ThinkNow
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
Kurio // The Social Media Age(ncy)
 

Featured (20)

2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot2024 State of Marketing Report – by Hubspot
2024 State of Marketing Report – by Hubspot
 
Everything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPTEverything You Need To Know About ChatGPT
Everything You Need To Know About ChatGPT
 
Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 

Do comments follow commenting conventions?

  • 1. Do Comments follow commenting conventions? A case study in Java and Python Pooja Rani, Suada Abukar, Nataliia Stulova, Alexandre Bergel, Oscar Nierstrasz University of Bern, Switzerland
  • 2. 2 /** Event fired when a spacer element is hidden or shown in Escalator
 * * @author Vaadin Lt d * @since 7.7.13 * / public class SpacerVisibili { System.out.println(..) ; }
  • 3. 3 // This class fires an Event when a spacer element is hidden or shown in the Escalator. I am the author of this class . // It is present in the project since the version 7.7.13 and might delete in the next versions. public class SpacerVisibili { System.out.println(..) ; } No strict convention for their style & syntax
  • 4. 4 E.g., Oracle comment guidelines Coding Style guidelines First sentence should summarise the class Use phrases instead of complete sentences Use third person instead of second person
  • 5. /** Event fired when a spacer element is hidden or shown in Escalator
 * * @author Vaadin Lt d * @since 7.7.13 */ 5 Does this comment follow the guidelines? Does it not? First sentence should summarise the class Use phrases instead of complete sentences Use third person instead of second person Do developers follow these guidelines?
  • 6. /** Event fired when a spacer element is hidden or shown in Escalator
 * * @author Vaadin Lt d * @since 7.7.13 */ 6 Does this comment follow the guidelines? Does it not? First sentence should summarise the class Use phrases instead of complete sentences Use third person instead of second person
  • 7. 7 Analyzed Smalltalk class comments against the style guidelines but what about other languages? Java, Python Analyzed Java and Python class comments but not against the style guidelines. Methodology Dataset Do developers follow commenting guidelines for Java and Python comments? Previous works by Rani et.al.,
  • 8. 8 Apache Hadoop Apache Spark Eclipse.cdt Google Guava Google Guice Django iPython Mailpile Pandas Pipenv PyTorch Requests Dataset
  • 10. 10 Apache Hadoop Apache Spark Eclipse.cdt Google Guava Google Guice Django Pipenv Mailpile Request iPython Pandas PyTorch Oracle Google PEP8/257 Numpy Google 1 Extracting guidelines
  • 11. 11 ●PEP 257 -- Docstring Conventions | Python.org 2 Identifying rules
  • 12. 12 ●PEP 257 -- Docstring Conventions | Python.org 3 Content Formatting Content Formatting Formatting Formatting Create taxonomy
  • 13. 13 Content rules are more prevalent in style guidelines but hard to locate RQ1: Types of comment conventions?
  • 14. 14 Developers do not always adopt comment conventions (Not applicable rules) 49% 16% 47% 11% 54% 49% 38% 27% 32% 25% 24% 63% 53% 7% 2% 10% 3% 6% 10% 12% 3% 3% 2% 2% 3% 2% 44% 83% 43% 86% 40% 42% 50% 70% 65% 73% 74% 35% 45% Django iPython Mailpile Pandas Pipenv Pytorch Requests Eclipse Vaadin Spark Hadoop Guava Guice Python Java Followed rules Not followed rules Not applicable rules RQ2: Do developers follow conventions?
  • 15. 15 /** @author Vaadin Ltd 
 * * @since 7.7.13 */ First sentence should summarise the class Use phrases instead of complete sentences Use third person instead of second person RQ2: Do developers follow conventions? 27% 32% 25% 24% 63% 53% 3% 3% 2% 2% 3% 2% 70% 65% 73% 74% 35% 45% se in rk op va ce Followed rules Not followed rules Not applicable rules 63% 53% 3% 3% 2% 2% 3% 2% 70% 65% 73% 74% 35% 45% ules Not followed rules Not applicable rules 49% 16% 47% 11% 54% 49% 38% 27% 32% 25% 24% 63% 53% 7% 2% 10% 3% 6% 10% 12% 3% 3% 2% 2% 3% 2% 44% 83% 43% 86% 40% 42% 50% 70% 65% 73% 74% 35% 45% Django iPython Mailpile Pandas Pipenv Pytorch Requests Eclipse Vaadin Spark Hadoop Guava Guice Python Java Followed rules Not followed rules Not applicable rules
  • 16. 16 Comments often follow writing style and content rules than other rule types RQ2: Do developers follow conventions?
  • 17. 17 Verify other types of comments (Method, inline comments) Verify comments of other languages (C++, JavaScript) Develop tools to validate comments against the guidelines Improve comment quality assessment Future work
  • 18. Preprint on Arxiv https://arxiv.org/pdf/2108.10766v2 Video on YouTube https://youtu.be/mX_9XxQTSxQ Replication Package on Zenodo https://doi.org/10.5281/zenodo.5296443 Contact us 18 https://twitter.com/poojaruhal http://scg.unibe.ch/staff Do Comments follow Commenting Conventions? A Case Study in Java and Python