28/06/2015Dr Andy Brooks1 MSc Software Maintenance MS Viðhald hugbúnaðar Fyrirlestrar 13 & 14 Do Visualizations Improve Program Comprehensibility?

Slides:



Advertisements
Similar presentations
Procedural programming in Java
Advertisements

Computer and Programming
Chapter 7 User-Defined Methods. Chapter Objectives  Understand how methods are used in Java programming  Learn about standard (predefined) methods and.
08/05/2015Dr Andy Brooks1 MSc Software Maintenance MS Viðhald hugbúnaðar Fyrirlestrar 15 & 16 Programmers Use Slices When Debugging.
CSE 1301 Lecture 6B More Repetition Figures from Lewis, “C# Software Solutions”, Addison Wesley Briana B. Morrison.
Introduction to working with Loops  2000 Prentice Hall, Inc. All rights reserved. Modified for use with this course. Introduction to Computers and Programming.
 2002 Prentice Hall. All rights reserved. 1 Outline 4.1 Introduction 4.2 Algorithms 4.3 Pseudocode 4.4 Control Structures 4.5 The if Selection Structure.
Introduction to Computers and Programming Lecture 4: Mathematical Operators New York University.
Loops Repeat after me …. Loops A loop is a control structure in which a statement or set of statements execute repeatedly How many times the statements.
GRASP – Overview of Program Comprehension Studies - Slide 1 Auburn University Computer Science and Software Engineering The GRASP Research Project An Overview.
CS102--Object Oriented Programming Lecture 6: – The Arrays class – Multi-dimensional arrays Copyright © 2008 Xiaoyan Li.
28/06/2015Dr Andy Brooks1 MSc Software Maintenance MS Viðhald hugbúnaðar Fyrirlestrar 25 & 26 The Importance of Typographic Style “Hence, the book format.
About the Presentations The presentations cover the objectives found in the opening of each chapter. All chapter objectives are listed in the beginning.
1 Interactive Applications (CLI) and Math Interactive Applications Command Line Interfaces The Math Class Example: Solving Quadratic Equations Example:
Chapter 5 Conditionals and Loops. © 2004 Pearson Addison-Wesley. All rights reserved2/33 Conditionals and Loops Now we will examine programming statements.
JAVA Control Structures: Repetition. Objectives Be able to use a loop to implement a repetitive algorithm Practice, Practice, Practice... Reinforce the.
Lecture for Week Spring.  Numbers can be represented in many ways. We are familiar with the decimal system since it is most widely used in everyday.
CSC 1051 M.A. Papalaskari, Villanova University Repetition CSC 1051 – Data Structures and Algorithms I Dr. Mary-Angela Papalaskari Department of Computing.
Chapter 5 Loops Liang, Introduction to Java Programming, Tenth Edition, (c) 2015 Pearson Education, Inc. All rights reserved.
Chapter 1: A First Program Using C#. Programming Computer program – A set of instructions that tells a computer what to do – Also called software Software.
© The McGraw-Hill Companies, 2006 Chapter 4 Implementing methods.
By the end of this session you should be able to...
Chapter 5 Loops.
Copyright © 2012 Pearson Education, Inc. Chapter 6 More Conditionals and Loops Java Software Solutions Foundations of Program Design Seventh Edition John.
CSci 111 – computer Science I Fall 2014 Cynthia Zickos WRITING A SIMPLE PROGRAM IN JAVA.
1 Outline 4.1 Introduction 4.2 Algorithms 4.3 Pseudocode 4.4 Control Structures 4.5 The if Selection Structure 4.6 The if / else Selection Structure 4.7.
Procedural programming in Java Methods, parameters and return values.
A First Book of ANSI C, Fourth Edition1 Functions for Modularity 04/24/15.
CSC 1051 – Data Structures and Algorithms I Dr. Mary-Angela Papalaskari Department of Computing Sciences Villanova University Course website:
Loops (cont.). Loop Statements  while statement  do statement  for statement while ( condition ) statement; do { statement list; } while ( condition.
COMP 6710 Course NotesSlide 7-0 Auburn University Computer Science and Software Engineering Course Notes Set 7: Review of Graphs Computer Science and Software.
Chapter 6. else-if & switch Copyright © 2012 Pearson Education, Inc.
CSC 1051 – Data Structures and Algorithms I Dr. Mary-Angela Papalaskari Department of Computing Sciences Villanova University Course website:
CSC 1051 – Data Structures and Algorithms I Dr. Mary-Angela Papalaskari Department of Computing Sciences Villanova University Course website:
Chapter 5 Conditionals and Loops. © 2004 Pearson Addison-Wesley. All rights reserved5-2 The switch Statement The switch statement provides another way.
Topics Logical Operators (Chapter 5) Comparing Data (Chapter 5) The conditional operator The switch Statement The for loop Nested Loops.
CSC 1051 – Data Structures and Algorithms I Dr. Mary-Angela Papalaskari Department of Computing Sciences Villanova University Course website:
Java iteration statements ● Iteration statements are statements which appear in the source code only once, but it execute many times. ● Such kind of statements.
CSC 1051 M.A. Papalaskari, Villanova University Algorithms Dr. Mary-Angela Papalaskari Department of Computing Sciences Villanova University Course website:
CSC 1051 – Data Structures and Algorithms I Dr. Mary-Angela Papalaskari Department of Computing Sciences Villanova University Course website:
Introduction to Computers and Programming Lecture 7:
Loops Copyright © 2012 Pearson Education, Inc.. Conditionals and Loops (Chapter 5) So far, we’ve looked at: –making decisions with if –how to compare.
1 Flow of Control Chapter 5. 2 Objectives You will be able to: Use the Java "if" statement to control flow of control within your program.  Use the Java.
CS 116 Object Oriented Programming II Lecture 13 Acknowledgement: Contains materials provided by George Koutsogiannakis and Matt Bauer.
CSC 1051 – Data Structures and Algorithms I Dr. Mary-Angela Papalaskari Department of Computing Sciences Villanova University Course website:
Testing and Debugging UCT Department of Computer Science Computer Science 1015F Hussein Suleman March 2009.
CSC111 Quick Revision.
3.1 Fundamentals of algorithms
Chapter 7 User-Defined Methods.
Suppose we want to print out the word MISSISSIPPI in big letters.
CSC1401 Input and Output (and we’ll do a bit more on class creation)
CSC 1051 – Data Structures and Algorithms I
Chapter 6 More Conditionals and Loops
The switch Statement The switch statement provides another way to decide which statement to execute next The switch statement evaluates an expression,
Repetition Chapter 6 12/06/16 & 12/07/16 1 1
Chapter 6 More Conditionals and Loops
MSIS 655 Advanced Business Applications Programming
Outline Boolean Expressions The if Statement Comparing Data
Module 4 Loops and Repetition 2/1/2019 CSE 1321 Module 4.
Building Java Programs
Building Java Programs
Module 4 Loops and Repetition 4/7/2019 CSE 1321 Module 4.
Java Programming: Chapter 9: Recursion Second Edition
Building Java Programs
Repetition Statements
Outline Software Development Activities
Outline Boolean Expressions The if Statement Comparing Data
Conditionals and Loops
Review Lab assignments Homework #3
Repetition CSC 1051 – Data Structures and Algorithms I Course website:
Presentation transcript:

28/06/2015Dr Andy Brooks1 MSc Software Maintenance MS Viðhald hugbúnaðar Fyrirlestrar 13 & 14 Do Visualizations Improve Program Comprehensibility?

28/06/2015Dr Andy Brooks2 Case Study Dæmisaga Reference Do Visualizations Improve Program Comprehensibility? Experiments with Control Structure Diagrams for Java, T D Hendrix et al., SIGCSE 2000 (© ACM), pp , 2000.

28/06/2015Dr Andy Brooks3 Why visualizations? A picture paints a thousand words. Graphical representations are used in the everyday world to good effective. “... the effectiveness of software visualization is still an open question and is certainly not universally accepted.”

28/06/2015Dr Andy Brooks4 The Control Structure Diagram (CSD) A graphical representation of the control structure and module-level organization of source code. The graphical representation supplements the source code without disrupting the normal layout of the source code.

28/06/2015Dr Andy Brooks5 public class CoinFlip { // Creates a Coin object, // flips it, and prints the results. public static void main (String[] args) { Coin myCoin = new Coin(); myCoin.flip(); System.out.println (myCoin); if (myCoin.isHeads()) System.out.println ("You win."); else System.out.println ("Better luck next time."); } } Some Java code.

28/06/2015Dr Andy Brooks6 ÏÕÖ× public class CoinFlip Ïϧ { Ïϧ // Creates a Coin object, Ïϧ // flips it, and prints the results. Ïϧ ÏϧÏÞßà public static void main (String[] args) ÏϧÏϧ { ÏϧÏϨ¹íÏ Coin myCoin = new Coin(); ÏϧÏϧ ÏϧÏϨ¹¹Ï myCoin.flip(); ÏϧÏϧ ÏϧÏϨ¹¹Ï System.out.println (myCoin); ÏϧÏϧ ÏϧÏϨ¹³´ if (myCoin.isHeads()) ÏϧÏϧÏ6¾¹¹Ï System.out.println ("You win."); ÏϧÏϧÏö´ else ÏϧÏϧÏȾ¹¹Ï System.out.println ("Better luck next time."); ÏϧÏÏ© } ÏÏ© } Some Java code with CSD.

28/06/2015Dr Andy Brooks7 public class ReverseNumber { // Reverses the digits of an integer mathematically. public static void main (String[] args) { int number, lastDigit, reverse = 0; Scanner scan = new Scanner (System.in); System.out.print ("Enter a positive integer: "); number = scan.nextInt(); do { lastDigit = number % 10; reverse = (reverse * 10) + lastDigit; number = number / 10; } while (number > 0); System.out.println (“Number reversed is " + reverse); } } Some Java code.

28/06/2015Dr Andy Brooks8 ÏÕÖ× public class ReverseNumber Ïϧ { Ïϧ // Reverses the digits of an integer mathematically. Ïϧ ÏϧÏÞßà public static void main (String[] args) ÏϧÏϧ { ÏϧÏϨ¹íÏ int number, lastDigit, reverse = 0; ÏϧÏϨ¹íÏ Scanner scan = new Scanner (System.in); ÏϧÏϨ¹¹Ï System.out.print ("Enter a positive integer: "); ÏϧÏϨ¹¹Ï number = scan.nextInt(); ÏϧÏϨ¹¹® do ÏϧÏϧÏÏ5 { ÏϧÏϧÏÏ7¹¹Ï lastDigit = number % 10; ÏϧÏϧÏÏ7¹¹Ï reverse = (reverse * 10) + lastDigit; ÏϧÏϧÏÏ7¹¹Ï number = number / 10; ÏϧÏϧÏÏ5 } ÏϧÏϧÏÏò while (number > 0); ÏϧÏϨ¹¹Ï System.out.println (“Number reversed is " + reverse); ÏϧÏÏ© } ÏÏ© } Some Java code with CSD.

28/06/2015Dr Andy Brooks9 // Computes and returns the greatest common divisor of // the two positive parameters. Uses Euclid's algorithm. private int gcd (int num1, int num2) { while (num1 != num2) if (num1 > num2) num1 = num1 - num2; else num2 = num2 - num1; return num1; } } Some Java code.

28/06/2015Dr Andy Brooks10 Ïϧ // Computes and returns the greatest common divisor of Ïϧ // the two positive parameters. Uses Euclid's algorithm. ÏϧÏÞßà private int gcd (int num1, int num2) ÏϧÏϧ { ÏϧÏϨ¹¹± while (num1 != num2) ÏϧÏϧÏÏ7¹³´ if (num1 > num2) ÏϧÏϧÏÏ5Ï6¾¹¹Ï num1 = num1 - num2; ÏϧÏϧÏÏ5Ïö´ else ÏϧÏϧÏÏ°ÏȾ¹¹Ï num2 = num2 - num1; ÏϧÏϧ Ïϧ¹Ĺ¹Ï return num1; ÏϧÏÏ© } ÏÏ© } Some Java code with CSD. CSD produced using the jGRASP IDE.

28/06/2015Dr Andy Brooks11 The Experiment Subjects were divided into two equal groups and provided with the same source code. Subjects were required to answer 12 questions about the code. The control group had plain source code while the intervention group had source code with CSD. control group - samanburðarhópur

28/06/2015Dr Andy Brooks12 Hypotheses H o : The CSD will not have a positive effect on program comprehensibility. H 1 : The CSD will have a positive effect on program comprehensibility. Andy says: Experimental researchers hope to be able to reject the null hypothesis (H o ) in favour of the alternative hypothesis (H 1 ).

28/06/2015Dr Andy Brooks13 Variables Independent variable ( óháð breyta ): code presentation (plain or CSD) Dependent variables: response time and response correctness

28/06/2015Dr Andy Brooks14 Experimental process All subjects received a 10 minute orientation to explain the task they were to perform. –Example short program, example questions, and how the questions were to be answered. Subjects were advised the task was similar to elements of a software inspection or debugging activity. The CSD subjects had an additional 5-10 minutes to explain the symbols of the CSD. Without sacrificing accuracy, subjects were asked to answer each question as quickly as possible.

28/06/2015Dr Andy Brooks15 Participants Participants were senior or graduate students taking an intensive programming course. –Developing and debugging non-trivial Java. Volunteers received extra credit points. Groups were balanced with respect to students´ ability on almost complete grade information. þátttakendur

28/06/2015Dr Andy Brooks16 Figure 4 Balance of groups prior to experiment. X indicates a non-letter grade graduate student. ©ACM

28/06/2015Dr Andy Brooks17 Participant loss 44 students volunteered. But some students were absent when the experiment started. For example, the CSD group had 4 A students compared to 2 A students in the control. Some data was eliminated from the analysis to ensure a proper balance. –So only data for 39 subjects were analysed.

28/06/2015Dr Andy Brooks18 The code The code was taken from a public domain graphics package written in Java. 183 source lines with several levels of control. A small number of control constructs were added for experimental purposes. Both groups were told they were inspecting real code. Both groups received the code in printed form to avoid any bias regarding familiarity with a program editor.

28/06/2015Dr Andy Brooks19 Question presentation Questions were presented as a sequence of web pages. Scripts recorded the subjects´ responses as well as response times. Response time was calculated from the time the question was displayed until the submit button was pressed.

28/06/2015Dr Andy Brooks20 Question design “The questions should be relevant to completing real comprehension tasks such as those found in inspection, testing, maintenance, and debugging activities.” “The questions should be universal, or as generally applicable, as possible.” “The questions should have single, objective answers.” –Answers were in terms of line numbers.

28/06/2015Dr Andy Brooks21 Representative questions 1.Where does the loop that begins on line 91 end? 2.How many variables and object instances are declared? 3.How many ways are there to exit the loop that begins on line 91? 4.To what line would control be transferred immediately after executing line 144? 5.How many syntactic levels deep is the most deeply nested statement? 6.How many conditions must be evaluted in order for line 152 to be excuted?

28/06/2015Dr Andy Brooks22 All experimental materials must be available to allow other researchers to replicate (or improve) the experiment. In this report, the authors choose to list 6 ‘representative’ questions rather than list all 12 questions actually used. Also, the authors will need to be contacted to obtain the code used.

28/06/2015Dr Andy Brooks23 Results Figure 5 Average time taken to respond per question A significant difference between overall response times was found with a p value of 0.06, but the actual statistical test used is not named. Only on question 12 does the control group perform better than the CSD group. ©ACM

28/06/2015Dr Andy Brooks24 Results Figure 6 Average time taken to respond correctly per question A significant difference between overall response times was found with a p value of , but the actual statistical test used is not named. The control group never performs better than the CSD group and there were no correct control group answers for questions 6, 7, and 12. ©ACM

28/06/2015Dr Andy Brooks25 Results Number of correct responses per question 45% of the CSD group´s responses were correct but only 26% of the control group´s responses were correct. The above figure is taken from another publication as Figure 7 of the case study does not show clearly the differences between the groups. ©IEEE

28/06/2015Dr Andy Brooks26 jGRASP Demonstrating the usefulness of visualization is one thing. To be practically useful, visualization must be incorporated in program editing tools. The jGRASP tool is a Java IDE that supports the CSD. Users can turn the CSD on or off at the click of a button.

28/06/2015Dr Andy Brooks27 Summary “The results of a controlled experiment indicate that the CSD can have a highly significant positive effect on human performance in program comprehension tasks.”

28/06/2015Dr Andy Brooks28 More than half the time, questions were answered incorrectly, even though subjects were told not to sacrifice accuracy. Why? If visualization is so useful, why were only 45% of the CSD group´s responses correct? The time/accuracy trade-off tells us that accuracy improves the longer you take performing a task. The data could have been analyzed for time/accuracy trade-offs.

28/06/2015Dr Andy Brooks29 Figure 6 suggest two trends are present: –the responses to questions 1-6 and, –the responses to questions What could have caused this? No real differences here? ©ACM

28/06/2015Dr Andy Brooks30 More control group subjects answered question 4 correctly. Why? Why could no control group subject provide a correct answer to questions 6, 7, and 12? ©IEEE