Top Banner
Program Comprehension 1 Program Comprehension Program Comprehension During Software Maintenance and Evolution IEEE Computer, August 1995 Von Mayrhauser, A. and Vans, A. M.
36

Program Comprehension1 Program Comprehension During Software Maintenance and Evolution IEEE Computer, August 1995 Von Mayrhauser, A. and Vans, A. M.

Dec 15, 2015

Download

Documents

Lexus Pea
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Program Comprehension1 Program Comprehension During Software Maintenance and Evolution IEEE Computer, August 1995 Von Mayrhauser, A. and Vans, A. M.

Program Comprehension 1

Program Comprehension

Program Comprehension During Software Maintenance and Evolution

IEEE Computer, August 1995Von Mayrhauser, A. and Vans, A. M.

Page 2: Program Comprehension1 Program Comprehension During Software Maintenance and Evolution IEEE Computer, August 1995 Von Mayrhauser, A. and Vans, A. M.

Program Comprehension 2

Outline

Overview Mental models Cognitive models Tools Research topics

Page 3: Program Comprehension1 Program Comprehension During Software Maintenance and Evolution IEEE Computer, August 1995 Von Mayrhauser, A. and Vans, A. M.

Program Comprehension 3

Program comprehension

Program comprehension is the study of how software engineers understand programs.

Program comprehension is needed for:• Debugging• Code inspection• Test case design• Re-documentation• Design recovery• Code revisions

Page 4: Program Comprehension1 Program Comprehension During Software Maintenance and Evolution IEEE Computer, August 1995 Von Mayrhauser, A. and Vans, A. M.

Program Comprehension 4

Program comprehension process

Involves the use of existing knowledge to acquire new knowledge about a program.

Existing knowledge:• Programming languages• Computing environment• Programming principles• Architectural models• Possible algorithms and solution approaches• Domain-specific information• Any previous knowledge about the code

New knowledge:• Code functionality• Architecture• Algorithm implementation details• Control flow• Data flow

Page 5: Program Comprehension1 Program Comprehension During Software Maintenance and Evolution IEEE Computer, August 1995 Von Mayrhauser, A. and Vans, A. M.

Program Comprehension 5

Comprehension techniques

Reading by step-wise abstraction• Determine the function of critical subroutines, work through the program

hierarchy until the function of the program is determined. Checklist-based reading

• Readers are given a checklist to focus their attention on particular issues within the document.

• Different readers were given different checklists, therefore each reader would concentrate on different aspects of the document.

Defect-based reading• Defects are categorized and characterized (e.g., data type

inconsistency, incorrect functionality, missing functionality, etc.)• A set of steps (a scenario) is then developed for each defect class to

guide the reader to find those defects. Perspective-based reading

• Similar to defect-based reading, but instead of different defect classes, readers have different roles (tester, designer and user) to guide them in reading.

Page 6: Program Comprehension1 Program Comprehension During Software Maintenance and Evolution IEEE Computer, August 1995 Von Mayrhauser, A. and Vans, A. M.

Program Comprehension 9

Sources of variation

Aside from the issue of how comprehension occurs, comprehension performance and effectiveness are affected by many factors:• Maintainer characteristics• Program characteristics• Task characteristics

Page 7: Program Comprehension1 Program Comprehension During Software Maintenance and Evolution IEEE Computer, August 1995 Von Mayrhauser, A. and Vans, A. M.

Program Comprehension 10

Maintainer characteristics

Familiarity with code base Application domain knowledge Programming language knowledge Programming expertise Tool expertise Individual differences

Page 8: Program Comprehension1 Program Comprehension During Software Maintenance and Evolution IEEE Computer, August 1995 Von Mayrhauser, A. and Vans, A. M.

Program Comprehension 11

Program characteristics

Application domain Programming domain Quality of problem to be understood Program size and complexity Availability and accuracy of documentation

Page 9: Program Comprehension1 Program Comprehension During Software Maintenance and Evolution IEEE Computer, August 1995 Von Mayrhauser, A. and Vans, A. M.

Program Comprehension 12

Task characteristics

Task type• Experimental: recall, modification• Perfective, corrective, adaptive, reuse, extension.

Task size and complexity Time constraints Environmental factors

Page 10: Program Comprehension1 Program Comprehension During Software Maintenance and Evolution IEEE Computer, August 1995 Von Mayrhauser, A. and Vans, A. M.

Program Comprehension 13

Outline

Overview Mental models Cognitive models Tools Research topics

Page 11: Program Comprehension1 Program Comprehension During Software Maintenance and Evolution IEEE Computer, August 1995 Von Mayrhauser, A. and Vans, A. M.

Program Comprehension 14

Models

Mental models• Internal working representation of the software under

consideration. Cognitive models

• Theories of the processes by which software engineers arrive at a mental model.

Program Mental Model

CognitiveModel

Page 12: Program Comprehension1 Program Comprehension During Software Maintenance and Evolution IEEE Computer, August 1995 Von Mayrhauser, A. and Vans, A. M.

Program Comprehension 15

Mental models

Static elements• Text structure knowledge• Microstructure• Chunks (macrostructure)• Plans (objects)• Hypotheses

Dynamic elements• Strategies (chunking and cross-referencing)

Supporting elements• Beacons• Rules of discourse

Page 13: Program Comprehension1 Program Comprehension During Software Maintenance and Evolution IEEE Computer, August 1995 Von Mayrhauser, A. and Vans, A. M.

Program Comprehension 16

Text structure

The program text and its structure• Control structure: iterations, sequences, conditional

constructs• Variable definitions• Calling hierarchies• Parameter definitions

Microstructure – actual program statements and their relationships.

Page 14: Program Comprehension1 Program Comprehension During Software Maintenance and Evolution IEEE Computer, August 1995 Von Mayrhauser, A. and Vans, A. M.

Program Comprehension 17

Chunks

Contain various levels of text structure abstractions.

Also called macrostructure. Can be identified by a descriptive label. Can be composed into higher level chunks.

Page 15: Program Comprehension1 Program Comprehension During Software Maintenance and Evolution IEEE Computer, August 1995 Von Mayrhauser, A. and Vans, A. M.

Program Comprehension 18

Plans (objects)

Knowledge elements for developing and validating expectations, interpretations, and inferences.

Include causal knowledge about information flow and relationships between parts of a program.

Programming plans• Based on programming concepts.• Low level: iteration and conditional code segments.• Intermediate level: searching, sorting, summing algorithms;

linked lists and trees.• High level

Domain plans• All knowledge about the problem area.• Examples: problem domain objects, system environment,

domain-specific solutions and architectures.

Page 16: Program Comprehension1 Program Comprehension During Software Maintenance and Evolution IEEE Computer, August 1995 Von Mayrhauser, A. and Vans, A. M.

Program Comprehension 19

Hypotheses

Conjectures that are results of comprehension activities that can take seconds or minutes to occur.

Three types:• Why – hypothesize the purpose/rationale of a function of design choice.• How – hypothesize the method for accomplishing a certain goal.• What – hypothesize classification.

Hypotheses are drivers of cognition. They help to define the direction of further investigation.

Code cognition formulates hypotheses, checks them whether they are true or false, and revises them when necessary.

Hypotheses fail for several reasons:• Can’t find code to support a hypothesis.• Confusion due to one piece of code satisfying different hypothesis.• Code cannot be explained.

Page 17: Program Comprehension1 Program Comprehension During Software Maintenance and Evolution IEEE Computer, August 1995 Von Mayrhauser, A. and Vans, A. M.

Program Comprehension 20

Supporting elements

Beacons• Cues that index into existing knowledge.

• A swap routine can be a beacon for a sorting function.

• Experienced programmers recognize beacons much faster than novice programmers.

• Used commonly in top-down comprehension. Rules of discourse

• Rules that specify programming conventions.• Examples: coding standards, algorithm implementations,

expected use of data structures.

Page 18: Program Comprehension1 Program Comprehension During Software Maintenance and Evolution IEEE Computer, August 1995 Von Mayrhauser, A. and Vans, A. M.

Program Comprehension 21

Mental models – dynamic elements

Strategies• Sequences of actions that lead to a particular goal.

Actions• Classify programmer activities implcitly and explicitly

during a maintenance task. Episodes

• Sequences of actions. Processes

• Aggregations of episodes.

Page 19: Program Comprehension1 Program Comprehension During Software Maintenance and Evolution IEEE Computer, August 1995 Von Mayrhauser, A. and Vans, A. M.

Program Comprehension 22

Strategies

Guide the sequence of actions while following a plan to reach a goal.

Match programming plans to code.• Shallow reasoning – do not perform in-depth analysis;

stop upon recognition of familiar idioms and programming plans.

• Deep reasoning – perform detailed analysis. Mechanisms for understanding

• Chunking• Cross-referencing

Page 20: Program Comprehension1 Program Comprehension During Software Maintenance and Evolution IEEE Computer, August 1995 Von Mayrhauser, A. and Vans, A. M.

Program Comprehension 23

Chunking

Creates new, higher-level abstraction structures Labels replace the detail of the lower level

chunks.

Page 21: Program Comprehension1 Program Comprehension During Software Maintenance and Evolution IEEE Computer, August 1995 Von Mayrhauser, A. and Vans, A. M.

Program Comprehension 24

Cross-referencing

Map program parts to functional descriptions

temp = a;a = b;b = temp;

for (i=0; i<size; i++) if (array[i]==target) return true;

swap

sequential search

Page 22: Program Comprehension1 Program Comprehension During Software Maintenance and Evolution IEEE Computer, August 1995 Von Mayrhauser, A. and Vans, A. M.

Program Comprehension 25

Outline

Overview Mental models Cognitive models Tools Research topics

Page 23: Program Comprehension1 Program Comprehension During Software Maintenance and Evolution IEEE Computer, August 1995 Von Mayrhauser, A. and Vans, A. M.

Program Comprehension 26

Cognitive models

Letovsky Shneiderman and Mayer Brooks Soloway, Adelson and Ehrlich Pennington Mayrhauser and Vans (Integrated)

Page 24: Program Comprehension1 Program Comprehension During Software Maintenance and Evolution IEEE Computer, August 1995 Von Mayrhauser, A. and Vans, A. M.

Program Comprehension 27

Letovsky model

Prior knowledge

Mental model:Specification layer

Implementation layerMapping

Unresolved mappings

Opportunistic assimilation process(top-down or bottom-up, as needed)

Page 25: Program Comprehension1 Program Comprehension During Software Maintenance and Evolution IEEE Computer, August 1995 Von Mayrhauser, A. and Vans, A. M.

Program Comprehension 28

Shneiderman model

e.g., Programming

languages

e.g., Programming experience

Programs are encoded into

chunks

Chunks are collected into

a layered internal

representation

Developed for both design and comprehension activities.

Page 26: Program Comprehension1 Program Comprehension During Software Maintenance and Evolution IEEE Computer, August 1995 Von Mayrhauser, A. and Vans, A. M.

Program Comprehension 29

Brooks modelBridges the gap between

problem domain & program domain

Relate objects between different

domains & representations

Top-down process: hypotheses generated and successively refined from

knowledge (triangles).

Page 27: Program Comprehension1 Program Comprehension During Software Maintenance and Evolution IEEE Computer, August 1995 Von Mayrhauser, A. and Vans, A. M.

Program Comprehension 30

Soloway model

Also known as domain model. Developers familiar with domain can understand the code in top-down process.

Strategic plans: global strategy

used

Tactical plans: local strategies

Implementation plans: code

fragments that implement tactical

plans

Help decompose goals into plans.

Top-down decomposition of

goals into plans and into lower level

plans.

Page 28: Program Comprehension1 Program Comprehension During Software Maintenance and Evolution IEEE Computer, August 1995 Von Mayrhauser, A. and Vans, A. M.

Program Comprehension 31

Pennington model

Use beacons

Chunking

Use beacons

Page 29: Program Comprehension1 Program Comprehension During Software Maintenance and Evolution IEEE Computer, August 1995 Von Mayrhauser, A. and Vans, A. M.

Program Comprehension 32

Integrated model

Page 30: Program Comprehension1 Program Comprehension During Software Maintenance and Evolution IEEE Computer, August 1995 Von Mayrhauser, A. and Vans, A. M.

Program Comprehension 33

Distributed cognition

Traditional cognitive models deal the cognitive processes inside one person’s brain.

On real projects, software developers:• Work in teams• Can ask people questions• Can surf the web for answers

How do these affect the cognitive process?

Page 31: Program Comprehension1 Program Comprehension During Software Maintenance and Evolution IEEE Computer, August 1995 Von Mayrhauser, A. and Vans, A. M.

Program Comprehension 34

Outline

Overview Mental models Cognitive models Tools Research topics

Page 32: Program Comprehension1 Program Comprehension During Software Maintenance and Evolution IEEE Computer, August 1995 Von Mayrhauser, A. and Vans, A. M.

Program Comprehension 35

Generic tool pipeline

Page 33: Program Comprehension1 Program Comprehension During Software Maintenance and Evolution IEEE Computer, August 1995 Von Mayrhauser, A. and Vans, A. M.

Program Comprehension 36

Code browser example: SeeSoft

Page 34: Program Comprehension1 Program Comprehension During Software Maintenance and Evolution IEEE Computer, August 1995 Von Mayrhauser, A. and Vans, A. M.

Program Comprehension 37

Outline

Overview Mental models Cognitive models Tools Research topics

Page 35: Program Comprehension1 Program Comprehension During Software Maintenance and Evolution IEEE Computer, August 1995 Von Mayrhauser, A. and Vans, A. M.

Program Comprehension 38

Research topics

Empirical studies of cognitive models• Larger systems (multiple programmers)• Modern architectures• Borrow techniques from psychology

• Use of recognition and recall as dependent variables

Tool support for comprehension tasks• Information foraging• Automated suggestions for program investigation• Text mining application to code exploration• Source code analysis• Support for newer languages

Page 36: Program Comprehension1 Program Comprehension During Software Maintenance and Evolution IEEE Computer, August 1995 Von Mayrhauser, A. and Vans, A. M.

Program Comprehension 39

Additional references

Susan Elliott Sim. Research in Program Comprehension (UC Irvine lecture notes).

Jonathan Maletic. Program Comprehension & The Psychology of Programming (Kent State University lecture notes).

Richard Upchurch. Program Comprehension. From Software Process Resource Collection. UMass – Dartmouth, 1996. http://www2.umassd.edu/swpi/1docs/comprehension.html.