Comment soup with a pinch of types, served in a leaky...

41
Comment soup with a pinch of types, served in a leaky bowl Pooja Rani Manuel Leuenberger Software Composition Group Bern, Switzerland

Transcript of Comment soup with a pinch of types, served in a leaky...

Page 1: Comment soup with a pinch of types, served in a leaky bowlfiles.pharo.org/conferences/2019PharoDays/12 Comment soup with … · Comment soup with a pinch of types, served in a leaky

Comment soup with a pinch of types, served in a leaky bowl

Pooja Rani Manuel Leuenberger

Software Composition Group Bern, Switzerland

Page 2: Comment soup with a pinch of types, served in a leaky bowlfiles.pharo.org/conferences/2019PharoDays/12 Comment soup with … · Comment soup with a pinch of types, served in a leaky

!2

A Pinch of Types

The Leaky Bowl

How gradual types can be useful for migration

A startling encounter in the VM world

The Comment Soup

How do comments evolve?

How do developers write comments?

Page 3: Comment soup with a pinch of types, served in a leaky bowlfiles.pharo.org/conferences/2019PharoDays/12 Comment soup with … · Comment soup with a pinch of types, served in a leaky

How do developers write comments?

How do class comments evolve over time?

What is the impact of template on the comments?

What information is present in class comments?

What is the writing style of developers?

!3

Page 4: Comment soup with a pinch of types, served in a leaky bowlfiles.pharo.org/conferences/2019PharoDays/12 Comment soup with … · Comment soup with a pinch of types, served in a leaky

!4

Playground to play with code

Developers express their code

Page 5: Comment soup with a pinch of types, served in a leaky bowlfiles.pharo.org/conferences/2019PharoDays/12 Comment soup with … · Comment soup with a pinch of types, served in a leaky

!5

Playground to play with words

Developers express themselves

Page 6: Comment soup with a pinch of types, served in a leaky bowlfiles.pharo.org/conferences/2019PharoDays/12 Comment soup with … · Comment soup with a pinch of types, served in a leaky

!6

Note that to encode a String as Base64, you first have to encode the characters as bytes using a character encoder.

See also http://en.wikipedia.org/wiki/Base64

Part of Zinc HTTP Components.

Warning

Link

Dependency

Page 7: Comment soup with a pinch of types, served in a leaky bowlfiles.pharo.org/conferences/2019PharoDays/12 Comment soup with … · Comment soup with a pinch of types, served in a leaky

!7

Wow! I am the biezer shape 4 4 control points.

Maybe we need roassal3 now with a better system for bezier lines

Excitement, Future discussion

Page 8: Comment soup with a pinch of types, served in a leaky bowlfiles.pharo.org/conferences/2019PharoDays/12 Comment soup with … · Comment soup with a pinch of types, served in a leaky

!8

/** * Options for connecting through a proxy * * Note that not all types may be supported, depending on * the platform and compilation options. */

Missing Java documentation

Page 9: Comment soup with a pinch of types, served in a leaky bowlfiles.pharo.org/conferences/2019PharoDays/12 Comment soup with … · Comment soup with a pinch of types, served in a leaky

!9

asdasd For the sake of commenting

Page 10: Comment soup with a pinch of types, served in a leaky bowlfiles.pharo.org/conferences/2019PharoDays/12 Comment soup with … · Comment soup with a pinch of types, served in a leaky

Warning

Link

Dependency

Random information

Excitement, Future

discussion Word of advice

Coding guideline

Page 11: Comment soup with a pinch of types, served in a leaky bowlfiles.pharo.org/conferences/2019PharoDays/12 Comment soup with … · Comment soup with a pinch of types, served in a leaky

Warning

Link

Dependency

Random information

Excitement, Future

discussion Word of advice

Coding guideline

Page 12: Comment soup with a pinch of types, served in a leaky bowlfiles.pharo.org/conferences/2019PharoDays/12 Comment soup with … · Comment soup with a pinch of types, served in a leaky

!12

15% comments

85% code

Page 13: Comment soup with a pinch of types, served in a leaky bowlfiles.pharo.org/conferences/2019PharoDays/12 Comment soup with … · Comment soup with a pinch of types, served in a leaky

How do developers write comments?

How do class comments evolve over time?

What is the impact of template on the comments?

What information is present in class comments?

What is the writing style of developers?

!13

Page 14: Comment soup with a pinch of types, served in a leaky bowlfiles.pharo.org/conferences/2019PharoDays/12 Comment soup with … · Comment soup with a pinch of types, served in a leaky

!14

0

2000

4000

6000

8000

1 2 3 4 5 6 7

Pharo versions

#C

lass

es

Without comments

With comments

Evolution of Class Comments

Page 15: Comment soup with a pinch of types, served in a leaky bowlfiles.pharo.org/conferences/2019PharoDays/12 Comment soup with … · Comment soup with a pinch of types, served in a leaky

Evolution of Class Comments

!15

Pharo versions

#C

lass

es

1 2 3 4 5 6 7

Without comments

With comments

Page 16: Comment soup with a pinch of types, served in a leaky bowlfiles.pharo.org/conferences/2019PharoDays/12 Comment soup with … · Comment soup with a pinch of types, served in a leaky

How do developers write comments?

How do class comments evolve over time?

What is the impact of template on the comments?

What information is present in class comments?

What is the writing style of developers?

!16

Page 17: Comment soup with a pinch of types, served in a leaky bowlfiles.pharo.org/conferences/2019PharoDays/12 Comment soup with … · Comment soup with a pinch of types, served in a leaky

Developers are guided by a default template

!17

Page 18: Comment soup with a pinch of types, served in a leaky bowlfiles.pharo.org/conferences/2019PharoDays/12 Comment soup with … · Comment soup with a pinch of types, served in a leaky

!18

Please comment me using the following template inspired by Class Responsibility Collaborator (CRC) design:

For the Class part: State a one line summary. For example, "I represent a paragraph of text".

For the Responsibility part: Three sentences about my main responsibilities - what I do, what I know.

For the Collaborators Part: State my main collaborators and one line about how I interact with them.

Public API and Key Messages

- message one - message two - (for bonus points) how to create instances.

One simple example is simply gorgeous. Internal Representation and Key Implementation Points.

Implementation Points

Comment markup?

Page 19: Comment soup with a pinch of types, served in a leaky bowlfiles.pharo.org/conferences/2019PharoDays/12 Comment soup with … · Comment soup with a pinch of types, served in a leaky

!19

I am an abstract class to define an Item use by a tree data source of Fast table.

Description ------------------------------------------------- I define the basics methods needed by a FTTreeDataSource. I use FTTreeItem to manage my elements and I am use by a FTFastTable.

Public API and Key Messages ------------------------------------------------- - #data. anObject from: aFTTreeDataSource This is my constructor that is use by FTTreeDataSource and myself Example ------------------------------------------------ Should not be instanciate. Internal Representation and Key Implementation Points. ------------------------------------------------- Instance Variables dataSource: I am the dataSource that holds this Item. children: I am a collection of Items calculate by the item. I contains the chldren of the Item.

Comment markup!

Key Messages

Intent

Page 20: Comment soup with a pinch of types, served in a leaky bowlfiles.pharo.org/conferences/2019PharoDays/12 Comment soup with … · Comment soup with a pinch of types, served in a leaky

!20

Num

ber

of c

lass

es

0

750

1'500

2'250

3'000

Intent

Responsibility

Collaborators

Public API

Example

Internal Details Instance Variable

Template sections found in classes

Template sections6000 classesPharo 7

Page 21: Comment soup with a pinch of types, served in a leaky bowlfiles.pharo.org/conferences/2019PharoDays/12 Comment soup with … · Comment soup with a pinch of types, served in a leaky

!21

Num

ber o

f cla

sses

0

35

69

104

138

Intent

Responsibility

Collaborators

Public API

Example

Internal Details Instance Variable

Template sections found- Manual analysis

Template sections138 random classesPharo 7

Page 22: Comment soup with a pinch of types, served in a leaky bowlfiles.pharo.org/conferences/2019PharoDays/12 Comment soup with … · Comment soup with a pinch of types, served in a leaky

!22

Class ReferencesWarnings

LinksSteps

PreconditionObservations

LicenseSuggestionsDependency

Reference to external docsClarification

ExtensionDiscourse

Coding guideline

Number of classes

0 10 20 30 40

Extra Information - Manual analysis

Extra categories 100 random classesPharo 7

Page 23: Comment soup with a pinch of types, served in a leaky bowlfiles.pharo.org/conferences/2019PharoDays/12 Comment soup with … · Comment soup with a pinch of types, served in a leaky

How do developers write comments?

How do class comments evolve over time?

What is the impact of template on the comments?

What information is present in class comments?

What is the writing style of developers?

!23

Page 24: Comment soup with a pinch of types, served in a leaky bowlfiles.pharo.org/conferences/2019PharoDays/12 Comment soup with … · Comment soup with a pinch of types, served in a leaky

What information is present in class comments?

!24

Intent

Responsibility Collaborators Public API

Example Internal Details Instance Variable

Dependency Reference to external docs

ClarificationExtension Discourse

Coding guideline

Class References

Warnings LinksSteps

PreconditionLicense

Suggestions

Observations

Comment Soup

Page 25: Comment soup with a pinch of types, served in a leaky bowlfiles.pharo.org/conferences/2019PharoDays/12 Comment soup with … · Comment soup with a pinch of types, served in a leaky

What information is present in class comments?

!25

Intent

Responsibility Collaborators Public API

Example Internal Details Instance Variable

Dependency Reference to external docs

ClarificationExtension Discourse

Coding guideline

Class References

Warnings LinksSteps

PreconditionLicense

Suggestions

Observations

Template Inspired

Extra but frequent

Extra but rare

Page 26: Comment soup with a pinch of types, served in a leaky bowlfiles.pharo.org/conferences/2019PharoDays/12 Comment soup with … · Comment soup with a pinch of types, served in a leaky

How do developers write comments?

How do class comments evolve over time?

What is the impact of template on the comments?

What information is present in class comments?

What is the writing style of developers?

!26

Page 27: Comment soup with a pinch of types, served in a leaky bowlfiles.pharo.org/conferences/2019PharoDays/12 Comment soup with … · Comment soup with a pinch of types, served in a leaky

!27

Comments of length 2-5 lines, have lengthy sentences

Use first person pronouns

Writing style

Different warning words

No formatting standards followed

Inconsistent parentheses

Page 28: Comment soup with a pinch of types, served in a leaky bowlfiles.pharo.org/conferences/2019PharoDays/12 Comment soup with … · Comment soup with a pinch of types, served in a leaky

– Penelope J. Corfield

“All people are living histories – which is why History matters”

Page 29: Comment soup with a pinch of types, served in a leaky bowlfiles.pharo.org/conferences/2019PharoDays/12 Comment soup with … · Comment soup with a pinch of types, served in a leaky

!1

And now for something completely different

Page 30: Comment soup with a pinch of types, served in a leaky bowlfiles.pharo.org/conferences/2019PharoDays/12 Comment soup with … · Comment soup with a pinch of types, served in a leaky

Gardening the Ecosystem

!2

Page 31: Comment soup with a pinch of types, served in a leaky bowlfiles.pharo.org/conferences/2019PharoDays/12 Comment soup with … · Comment soup with a pinch of types, served in a leaky

The EMF is dead, long live the EMF!

!3

Page 32: Comment soup with a pinch of types, served in a leaky bowlfiles.pharo.org/conferences/2019PharoDays/12 Comment soup with … · Comment soup with a pinch of types, served in a leaky

!4

And now for something completely different

Page 33: Comment soup with a pinch of types, served in a leaky bowlfiles.pharo.org/conferences/2019PharoDays/12 Comment soup with … · Comment soup with a pinch of types, served in a leaky

I am lazy

!5

Page 34: Comment soup with a pinch of types, served in a leaky bowlfiles.pharo.org/conferences/2019PharoDays/12 Comment soup with … · Comment soup with a pinch of types, served in a leaky

I am lazy

very, very lazy

!6

Page 35: Comment soup with a pinch of types, served in a leaky bowlfiles.pharo.org/conferences/2019PharoDays/12 Comment soup with … · Comment soup with a pinch of types, served in a leaky

Swapping dependencies

!7

Page 36: Comment soup with a pinch of types, served in a leaky bowlfiles.pharo.org/conferences/2019PharoDays/12 Comment soup with … · Comment soup with a pinch of types, served in a leaky

A Pinch of Types

How gradual types can be useful for migration

!8

Page 37: Comment soup with a pinch of types, served in a leaky bowlfiles.pharo.org/conferences/2019PharoDays/12 Comment soup with … · Comment soup with a pinch of types, served in a leaky

!9

And

now

for

some

thin

g co

mple

tely

dif

fere

nt

Page 38: Comment soup with a pinch of types, served in a leaky bowlfiles.pharo.org/conferences/2019PharoDays/12 Comment soup with … · Comment soup with a pinch of types, served in a leaky

The Leaky Bowl

A startling encounter in the VM world

!10

Page 39: Comment soup with a pinch of types, served in a leaky bowlfiles.pharo.org/conferences/2019PharoDays/12 Comment soup with … · Comment soup with a pinch of types, served in a leaky

How to write two lines of code in two months

!11

Page 40: Comment soup with a pinch of types, served in a leaky bowlfiles.pharo.org/conferences/2019PharoDays/12 Comment soup with … · Comment soup with a pinch of types, served in a leaky

How to write two lines of code in two months

- (void) pumpRunLoopEventSendA

ndSignal:(BOOL)signal {

@autoreleasepool {

... } }

!12

Page 41: Comment soup with a pinch of types, served in a leaky bowlfiles.pharo.org/conferences/2019PharoDays/12 Comment soup with … · Comment soup with a pinch of types, served in a leaky

The Bern Experience

• People put effort in commenting classes, not only for new, but also old classes

• Comment template impacts developers, structure helps

• The ecosystem needs love

• Dynamically typed does not mean no types

• Deeper integration of code transformation tools

!13