1 of 31

Cognitive Dimensions of Notation

CS294-184: Building User-Centered Programming Tools UC Berkeley Sarah E. Chasins 9/15/20

2 of 31

Types of Activities

  • incrementation: adding a new card to a cardfile; adding a formula to a spreadsheet
  • transcription: copying book details to an index card; converting a formula into spreadsheet terms
  • modification: changing the index terms in a library catalogue; changing the layout of a spreadsheet; modifying the spreadsheet to compute a different problem
  • exploratory design: typographic design; sketching; programming on the fly (‘hacking’)
  • searching: hunting for a known target, such as where a function is called
  • exploratory understanding: discovering structure or algorithm, or discovering the basis of classification

3 of 31

Explanation of following slides

Examples in the following slides (except on the dimension introduction/heading slides) were generated in class by the students in the Fall 2020 edition of Building User-Centered Programming Tools!

4 of 31

This is taken directly from Cognitive Dimensions of Information Artefacts: a tutorial, Thomas Green and Alan Blackwell https://www.cl.cam.ac.uk/~afb21/CognitiveDimensions/CDtutorial.pdf

Follow the link for even more explanation.

We’ve come so far!

5 of 31

(Team 1) Viscosity: C/C++

Transcription, modification: Changing the declaration of a function

The language requires consistency of method signatures between header and implementation files. This creates repetition viscosity when modifications are required. There were different ways we thought about how this might affect error-proneness: On one hand, the strict checks of C/C++ ensures there are less run-time errors. On the other hand incorrectly matched header/implementation files can create additional errors to deal with.

Credit: https://stackoverflow.com/questions/28646883/which-one-is-right-use-of-header-file-in-c/28660436

6 of 31

(Room 3) #2 Viscosity: command line

Modification: Correcting a typo/error in the command you’ve written

When you make an error writing a command and you need to go back it can be much slower than if you were using e.g. a text editor, especially if it’s a long command and the error is at the beginning. In the example above there are multiple lines, which makes it even more annoying!

We think there must be a good reason for this (i.e. benefits for another dimension) but we’re not sure what it is.

7 of 31

Team 5.2 Viscosity: C++ (and many others), many editors

modification: changing the interface for an API in an incompatible way to its previous use; tightening the input constraints or changing the semantics

For most interfaces there is a relationship between the snippet that uses it and the snippet that declares and/or defines it (sometimes even a hidden dependency). Incompatible changes to the API, break the usually distant code that uses it, making it very hard to make any significant changes. However, it might avoid the over abstraction of the underlying text (code) and/or the premature commitment of forcing you to change everything before the function is defined.

// from

bool authenticate(user) {

// check password file

}

// to

bool authenticate(user, conn) {

// use server connection

}

8 of 31

This is taken directly from Cognitive Dimensions of Information Artefacts: a tutorial, Thomas Green and Alan Blackwell https://www.cl.cam.ac.uk/~afb21/CognitiveDimensions/CDtutorial.pdf

Follow the link for even more explanation.

9 of 31

Team 6: Hidden Dependencies: Jupyter Notebooks

Exploratory Design

Jupyter notebook is designed for and programming on the fly. However, new users can sometimes be confused by the hidden dependencies that occur between the various cells, especially cell execution order. A new user might have trouble recognizing that cells can be executed out of order and also might have difficulty understanding how the out of order cells can depend on one another.

This can be seen as a consequence of trying to provide added flexibility to users, but can sometimes confound new users.

10 of 31

Hidden Dependency : &* notation in C++

Transcription: copying the address from rhs to lhs

The pointer operators are context specific. The type of the variable being addressed or dereferenced is not locally visible, so the semantics of the program depend on non-local context. This is a hidden dependency.

Also, dereferencing a null pointer is fun.

11 of 31

This is taken directly from Cognitive Dimensions of Information Artefacts: a tutorial, Thomas Green and Alan Blackwell https://www.cl.cam.ac.uk/~afb21/CognitiveDimensions/CDtutorial.pdf

Follow the link for even more explanation.

Y’all ever watch John Mulaney?

12 of 31

Team 6: Premature Commitment : C / C++

Modification

C family languages allow for memory management, but cause users to prematurely commit to the amount of memory they plan to allocate before knowing the true size of data. This makes modifications difficult to do as you often need to also go back and change how memory is allocated when the size of data changes (for example, if data accumulates over time).

13 of 31

This is taken directly from Cognitive Dimensions of Information Artefacts: a tutorial, Thomas Green and Alan Blackwell https://www.cl.cam.ac.uk/~afb21/CognitiveDimensions/CDtutorial.pdf

Follow the link for even more explanation.

14 of 31

This is taken directly from Cognitive Dimensions of Information Artefacts: a tutorial, Thomas Green and Alan Blackwell https://www.cl.cam.ac.uk/~afb21/CognitiveDimensions/CDtutorial.pdf

Follow the link for even more explanation.

15 of 31

This is taken directly from Cognitive Dimensions of Information Artefacts: a tutorial, Thomas Green and Alan Blackwell https://www.cl.cam.ac.uk/~afb21/CognitiveDimensions/CDtutorial.pdf

Follow the link for even more explanation.

16 of 31

Breakout 4.2: Visibility and Juxtaposability: Jupyter Notebook

Incrementation: adding new Python code to the notebook

Jupyter Notebook improves visibility by clearly laying out all the used code cells. The user doesn’t need to rerun all the code cells when adding new code, but can just run the added code cell.

This also improves progress evaluation as it allows the user to easily and frequently evaluate the effectiveness of specific code cells

17 of 31

18 of 31

Team 5.1 Closeness of Mapping:PyTorch v. Tensorflow

Exploratory Design and Understanding: Writing and creating differentiable modules for scientific computing

PyTorch: “module” classes provide close mapping to vector (tensor) calculus, linear algebra, and differentiation algorithms (e.g backprop) that are intuitive to end users

However, comes at cost of abstraction -- some steps in constructing computation graph are done implicitly

TensorFlow: Contrasts to PyTorch by making (allowing?) users to construct their own CG. Less abstraction and less premature commitment (users have more fine-grained control over gradient flow), at the cost of less closeness of mapping (fewer 1:1 commands e.g forward() and backward() methods for graph flow)

🤠

😞

19 of 31

(Room 3) #1 Closeness of Mapping: Agda (proof assistant)

Transcription: have proof written out ahead of time

Exploratory design: figuring out proof as you go

Notation of Agda can map extremely closely to the mathematics that you are trying to prove

Makes reading Agda code quite intuitive from a mathematicians’ perspective

However, all the fancy symbols require editor support and that the user remember commands (e.g. \forall for ∀), which has very low visibility

Can also achieve low diffusivity (low extraneous info)

Image credits: PLFA and StackOverflow

<Screenshot, code snippet, or other illustrative image to explain the activity to others.>

20 of 31

21 of 31

Consistency: object notation in Javascript

Understanding: building a mental model of language semantics

In Javascript, obj.key and obj[“key”] have the same semantics, unlike most other languages (Python, Java, etc). With two notations for the same operation, a person will struggle to understand when each is appropriate, or to realize they are the same at all.

22 of 31

23 of 31

I promise this is in the actual text!

24 of 31

Breakout 4.1: Error-proneness: any dynamically typed language

Modification: refactoring code that you’ve written, especially when it’s been a while since the code has been written.

Lack of a static type checker makes modifications and refactoring error-prone, since it’s harder to keep code consistent because you no longer remember all the details. So you end up doing a change-test-debug-headdesk loop.

Note: may reduce viscosity and premature commitment, in that there’s less text to update and you can get to a working program without manual type annotations.

run program

stack trace 😵

debug 😠

find obvious error 🤦‍♀️

repeat, probably many times

instead of:

run static type checker

get all the type errors 😔

fix them

with some luck,

things just work 😊

25 of 31

26 of 31

27 of 31

(Team 1) Progressive Evaluation: Jupyter Notebooks

Incrementation, modification, exploratory design: Evaluating code in a Jupyter notebook while attempting to perform some programming task in Python

Jupyter Notebooks are one of the best programming tools when it comes to progressive evaluation. This is because Python can be interpreted with a small amount of code and the easy/incremental user interface of Jupyter makes it easy for the user to execute small sections.

This comes with a slight trade-off of hard mental operations because cells can be run out of order. The user must remember what the current state is.

Credit: https://stackoverflow.com/questions/42591589/display-data-in-pandas-dataframe

28 of 31

29 of 31

“Brainfudge” language

30 of 31

Template for today’s activity

Note: Once you’ve completed a slide, please move it to the correct spot in the presentation (in the section that corresponds to at least one of the dimensions covered in the slide).

31 of 31

<Dimension(s) of Notation>:<language, programming environment, or programming tool>

<activity type (see slide 2)>: <description of activity>

<Description of how the language, prog environment, or tool fares on this dimension and why. Does this make the target activity really easy? Really hard? Does this interact with another dimension of notation? (E.g., is it a consequence of trying to make another activity easy?)>

<Screenshot, code snippet, or other illustrative image to explain the activity to others.>