This document discusses the past, present, and future of program comprehension research. In the past, research focused on measuring how well programmers understood code through tasks like filling in blanks. Currently, research uses tools like neuroimaging to study programmers' cognitive processes like working memory load. For the future, the document suggests continuing this work and applying it to topics like the best ways to teach programming.
5. Return Value of b
5
It should compute the
median
Case for the odd array
That‘s the list of numbers…
b should be 4.5
Case for the even array
public static void main(String [] args) {
int [] data = {1, 2, 4, 5, 6, 10};
computeMedian(data);
}
public int computeMedian(int[] data) {
int[] data = data;
sort(data);
float b;
if (data.length % 2 == 1)
b = data[data.length / 2];
else
b = ((float) data[data.length / 2 - 1] +
(float) data[data.length / 2]) / 2;
return (b);
}
Janet Siegmund Program Comprehension
6. Bottom-up comprehension
6
public static void main(String [] args) {
int [] data = {1, 2, 4, 5, 6, 10};
(data);
}
public int (int[] data) {
int[] data = data;
sort(data);
float b;
if (data.length % 2 == 1)
b = data[data.length / 2];
else
b = ((float) data[data.length / 2 - 1] +
(float) data[data.length / 2]) / 2;
return (b);
}
Weird variable naming
Check for odd array length…
does not apply here
Even array… get entries at
half the length… 4 and 5…
sum and divde by 2… 4.5
it‘s the median
elephant
elephant
Janet Siegmund Program Comprehension
7. • How does this help us to
understand the
programmer of today?
• A little:
– Useful variable names
– Code layout
– Tool support
public int enterprise (int[] kirk) {
int[] data = kirk;
sort(data);
float picard;
if (data.length % 2 == 1)
picard = data[data.length / 2];
else
picard = ((float) data[data.length / 2 - 1] +
(float) data[data.length / 2]) / 2;
return (picard);
}
Present
7Janet Siegmund Program Comprehension
8. Why Did Research on
Program Comprehension Stop?
What is more productive to use, a statically or
dynamically typed language?
8Janet Siegmund Program Comprehension
9. In the wild (realistic) In the lab (controlled)
Maximize
internal validity
Reliably explains
the causes of effects
Hard to generalize
Maximize
external validity
Reveals generally
occurring effects
Causes of effects unclear
A fundamental
tradeoff!
9Janet Siegmund Program Comprehension
16. Result
16
Posterior cingulate
cortex (BA31post)
Posterior cingulate
cortex (BA31ant)
Prefrontal midline
area (BA32)
Neuro-imaging
methods provide
interesting new
insights into
developer‘s heads
Janet Siegmund Program Comprehension
Never found it so hard to perpare a presentation. The paper is intended more as an overview to get a first impression on program comprehension, something to look up. So I hope I won‘t be too boring now
So, what was programming in the past like?
A few of you may have learned programming with these punched cards, or a few years later, with 0‘s and 1‘s
I can hardly imagine how program-comprehension research took place, e.g., with think-aloud protocols: „I hope I don‘t drop this stack…“ „1000 1111“…. could not have been very informative to a researcher…
But it got better
Higher-level programming languages were developed, and which such languages, research on program comprehension started.
Here is source code from an experiment. What is it doing?
Here is another piece. What is it doing? Who says it does the same? Who says it computes the minimum?
Expert programmers are as slow and as incorrect as novice programmers, if conventions are violated, For example, that variables should be named according to their purpose
Several ways to measure program comprehension:
I can let people think aloud, so they say what they are thinking. Gives a good impression of the thought processes, but may be biased. Also a lot of effort, because data has to be recorded, transcribed, and analyzed.
Give programmers a task (e.g., what is this source code doing) and record time and correctness:
Correctness: Programmers must understand it to determine what source code is doing. No data on how they reached an understanding
Time: the faster programmers understood it, the easier it was to comprehend, or the better they are at comprehension, or they have seen this source code before? or they just wanted to finish the experiment and did not try to understand it -> Most of the times in conjunction with correctness
Often, correctness and time in conjunction, also as efficiency measures, but it is unclear what they mean.
Fill-in-the-blank: Omit parts of the program and ask to complete missing information
Recall: Ask participants to recall the program. Who wants to try? Made more sense back then, because programs were not that prone to change. Shneiderman, musician and programmer
I like you to take a few moments to determine what the return value of this method is
Those of you who know what the median is used top-down comprehension: You stated the hypothesis that the method computeMedian returns the median, and then went through the source code to find proof for that hypothesis
In this case, computeMedian was a beacon; it gave you a hint about the source code.
However, when you are not familiar with the media, computeMedian is not helpful; you have to go through source code statement by statement.
So, program comprehension is a complex process, and it depends on many factors, such as knowledge, programming experience, programming language
To completely understand program comprehension, we need to measure it somehow;How can we measure program comprehension?
I like you to take a few moments to determine what the return value of this method is
Those of you who know what the median is used top-down comprehension: You stated the hypothesis that the method computeMedian returns the median, and then went through the source code to find proof for that hypothesis
In this case, computeMedian was a beacon; it gave you a hint about the source code.
However, when you are not familiar with the media, computeMedian is not helpful; you have to go through source code statement by statement.
So, program comprehension is a complex process, and it depends on many factors, such as knowledge, programming experience, programming language
To completely understand program comprehension, we need to measure it somehow;How can we measure program comprehension?
We know that we need to have useful variable names. We can name variables like we please, but that‘s slows us down. And first-year programming students like to argue about that…
Between 1995 and 2005, there was almost no research on program comprehension (and more general, the human factor in software engineering)
To answer this question, I have a question for you. You want to evaluate whether … How would you proceed?
There already are such experiments, maybe some of you know these.
Many factors were controlled, e.g., own programming language and IDE, clearly defined task… Everything was exactly controlled for, only the type system was changed.
I guess this part of the room would like the study. The remaining part would ask what we could do with these results.
What you could imagine rather is a study in the wild, in the real world, companies, existing programming languages and projct sizes -> generalizability of results. However, the cause of an observed effect is unclear.
You can also control everything (as best as you can) and exclude all confounding factors. Like the experiment that I described earlier. The pure effect of type systems, but in artificial conditions -> practical value?
EEG: Measures activity of your neurons
Typical responses, e.g., P300 -> positive peak after 300ms linked to attention, N100, negative peak after 100ms, indicating surprise
different frequency ranges, e.g., alpha range 7.5–12.5 Hz; wakeful relaxation with closed eyes. Like some of you when I’m boring you…
However, from one source-code snippets, we cannot learn much -> so we need different, but similar source-code snippets
Man könnte jetzt fragen: Haben die Probanden sich überhaupt auf die Aufgabe konzentriert?
Wie kann man Konzentration an dem Aktivierungsmuster sehen? Vielleicht ist Ihnen schon mal aufgefallen, dass sie regelmäßig Tagträume haben, in denen sie sich vorstellen, wie sie gemütlich am Strand liegen und ein gutes Buch lesen oder mit ihren Kindern spielen.
Solche Tagträume wurden auch mittels fMRT untersucht. Da hat sich eher zufällig gezeigt, dass wenn Probanden nichts zu tun hatten, dieses Netzwerk von Gebieten eine hohe Aktivierung zeigt. Als man die Probanden hinterher befragt hat, woran sie denn gedacht hätten, hatten sie gesagt, dass sie über sich selbst nachgedacht haben oder Tagträume hatten. Sobald eine konkrete Aufgabe ist, wird das Default Network deaktiviert, damit die Tagträumerei nicht mit der Aufgabe interagiert. Je komplexer die Aufgabe ist, desto stärker ist die Deaktivierung.
D.h., man kann an der Deaktivierung des Default networks erkennen, wie sehr sich die Probanden konzentriert haben.
Hier das Ergebnis: Blau bedeutet eine Deaktivierung. Und diese Gebiete zeigen signifikant geringere Aktivität, und die sind zentrale Bestandteile des Default Netzwerks; Probanden haben sich also wirklich konzentriert
Bezug zu Softwaremaße: Stärke der Deaktivierung korreliert mit Werten für Softwaremaße pro Quelltext, aber nur für DepDegree. Deutet darauf hin, dass Datenfluss, wie es bei DepDegree operationalisiert ist, ein Maß für die notwendige Konzentration zum Verstehen von Quelltext darstellt.
Arguments that people think in terms of objects
Others say that functional programming is way better for programming
Man kann nicht nur den Prozess des Verstehens genauer untersuchen, man kann sich auch andere Zusammenhänge anschauen.
I give you some time to read
So, this guy does not want to be disturbed. Not only because disturbance causes time, but also returning to the task takes time.
-> You would want such a sign also when you are in the zone, but you do not know before whether you might get into the zone, but if you‘re in the zone and stop hanging up that sign, you are not in the zone anymore… Such a dilemma This might change in the future.