UsingMemoryDiagramsWhenTeachingaJava-BasedCS1

上传人:t****d 文档编号:243040152 上传时间:2024-09-14 格式:PPT 页数:53 大小:266KB
返回 下载 相关 举报
UsingMemoryDiagramsWhenTeachingaJava-BasedCS1_第1页
第1页 / 共53页
UsingMemoryDiagramsWhenTeachingaJava-BasedCS1_第2页
第2页 / 共53页
UsingMemoryDiagramsWhenTeachingaJava-BasedCS1_第3页
第3页 / 共53页
点击查看更多>>
资源描述
Click to edit Master title style,Click to edit Master text styles,Second level,Third level,Fourth level,Fifth level,9/30/2003,*,Using Memory Diagrams When Teaching a Java-Based CS1,Mark A. Holliday,David R. Luginbuhl,Dept of Mathematics and Computer Science,Western Carolina University,Department of Computer Science,Univ. of North Carolina - Asheville,September 30, 2003,Asheville, NC,1,Overview,Motivation and Introduction,Diagramming as a teaching tool,Classes, objects, variables, and references,Method invocation, cascading, and composition,Primitive types, fields, visibility, and parameter passing,Static fields and methods,Arrays,Diagramming as an assessment tool,Conclusion,Motivation,Problem:,How to introduce and reinforce object-oriented concepts in an introductory CS course,How to help CS1 students visualize the state of the computer as the Java program executes,Solution:,Develop a visual representation of the effects of executing a sequence of Java statements,The visual representation accesses an alternative and supplemental mode of thinking,Relationship to Psychology,In other application domains psychologists have studied the effect on text comprehension by supplementing with visual representations,P. Goolkasian,Picture-Word Differences in a Sentence Verification Task, Memory and Cognition, 1996.,B. Henderson, personal communication. 2003.,Goals of Visual Representation,What goals should this visual representation have?,Be a precise but simple visual language that a student can use to “write” visually the effect of each step during the execution of a Java code fragment,That language should just represent the most important concepts involved in the effects of each Java statement.,Thus the language should represent an abstraction but what should be in the abstraction?,object-oriented features,state of the memory of the computer (abstractly) during the use of these object-oriented features,Object-Oriented Features,Example object-oriented features we want to include in the abstraction,Be able to distinguish between,Classes: objects: references: variables,Reference types variables: primitive type variables,Private: public (for fields and methods),Static: instance (for fields and methods),Object-Oriented Features (cont.),Method invocation, object and reference construction, return of a reference,Method composition and method concatenation,Arrays versus other objects,Local variables, parameters, and fields are all variables,Visibility (scope) rules,Parameter passing,Language Design Principles,Be a form of diagrams (call them,Memory Diagrams,),diagrams are sufficiently detailed since we want to represent the Java features abstractly,is “low-tech” so easy for students to write themselves during in-class groupwork and during written tests.,Language Design Principles,Be a sequence of diagrams. One for each change in the state of memory. Thus, a Java statement may involve several diagrams.,foo = 2 * foo;,“How can something be equal to twice itself?”,read “=“ as “gets” instead of as “equals”,In English we read left-to-read, but here you need to read right-to-left.,The diagram for the right-hand side of an assignment is before the diagram for the left-hand side and the assignment.,Language Design Principles,Use shape to reinforce when concepts are the same,Use shape to reinforce when concepts differ,Use position to reinforce concepts,Relationship to Other Work,Unlike UML since UML is not primarily focused on state of memory,Diagrams used in many textbooks, but without much emphasis,WU2001 is the closest but less developed,Objects, Variables, and References,String acolor, favColor; / a),acolor = “blue”; / rhs is b),/ lhs is c),favColor = aColor; / d),aColor,favColor,Features:,Labels on variables,Variables are rectangles,Rectangle is empty (null value not shown!),Figure a),Objects, Variables, and References,String acolor, favColor; / a),acolor = “blue”; / rhs is b),/ lhs is c),favColor = aColor; / d),String,“blue”,aColor,favColor,Features:,Labels on objects,Objects are circles,Reference exists but is floating (not in variable!),Figure b),Objects, Variables, and References,String acolor, favColor; / a),acolor = “blue”; / rhs is b),/ lhs is c),favColor = aColor; / d),String,“blue”,aColor,favColor,Features:,Only now is the reference in the variable,Reference starts inside the variable (so it occupies the variable),Figure c),Objects, Variables, and References,String acolor, favColor; / a),acolor = “blue”; / rhs is b),/ lhs is c),favColor = aColor; / d),Features:,Assignment means copying the reference, not moving it,Figure d),Method Invocation,otherColor = “red”;,aColor = “blue”; / a),aColor = aColor.concat(otherColor);,/ rhs call is b),/ rhs return is c),/ lhs is d),Features:,Method indicated by line on object,Indicates each object has method,Method is public,Figure a),Method Invocation,otherColor = “red”;,aColor = “blue”; / a),aColor = aColor.concat(otherColor);,/ rhs call is b),/ rhs return is c),/ lhs is d),Features:,Squiggly line indicates invocation,Argument is a copy of the reference inside variable otherColor,Figure b),Method Invocation,otherColor = “red”;,aColor = “blue”; / a),aColor = aColor.concat(otherColor);,/ rhs call is b),/ rhs return is c),/ lhs is d),Features:,New object and reference created,New reference is floating and is what is returned,Figure c),Method Invocation,otherColor = “red”;,aColor = “blue”; / a),aColor = aColor.concat(otherColor);,/ rhs call is b),/ rhs return is c),/ lhs is d),Features:,New reference replaces old content of variable aColor,“blue” object will be garbage-collected,Figure d),Primitive Types, Fields, Multiple Instances,Primitive type variables have numeric value,As opposed to ref types,Private fields represented inside object,Using rectangles indicates fields are just variables associated with objects,Different Student objects have same fields with (possibly) different values,Student,first,second,Student,87,score,85,score,name,name,String,“Sue”,String,“Bob”,Static fields and methods,john.punchIn();,Employee.advance(8);,john.punchOut();,/ figure shown at this point,Features:,Static fields and methods are with the class itself (displayed as a diamond and existing before any object, i.e. circle),Employee,8 16,clock,Employee,john,8,start,16,end,advance,(8),Static fields and methods,System.out.println(“some string”);,/ figure shown at this point,Features:,An example of a static public field that is widely used,Parameter Passing and “this”,Car windstar = new Car();,Car outback = new Car();,windstar.drive(500);,outback.drive(1000);,if (windstar.driveMoreThan( outback) ,/ figure shown at this point,public boolean driveMoreThan(Car other) ,return this.odometer other.odometer;, / rectangle for variable other is,/ actually shown next to,/ the parameter declaration,/ in the method header,Pass By Value Parameter Passing,int num = 5;,Car aCar = new Car(1000);,this.doSomething(num, aCar),public void doSomething(int value, Car theCar) ,value+;,theCar = new Car(500);, / rectangles for parameters,/ are actually shown next to,/ the parameter declaration,/ in the method header,Pass By Value Parameter Passing,int num = 5;,Car aCar = new Car(1000);,this.doSomething(num, aCar),public void doSomething(int value, Car theCar) ,value+;,theCar.drive(500);, / rectangles for parameters,/ are actually shown next to,/ the parameter declaration,/ in the method header,Method Cascading,String first = “Blue”;,String second = “Green”;,String third = “Red”:,String last;,last = first.concat(second).concat( third);,/ last is “BlueGreenRed”,Method Cascading,Method Composition,String first = “Blue”;,String second = “Green”;,String third = “Red”:,String last;,last = third.concat(first.concat( second);,/ last is “RedBlueGreen”,/ do,/ last = first.concat(,/ second.concat(third);,/ to get “BlueGreenRed”,Method Composition,Two-Dimensional Array (Primitive Base Type),Ragged Two-Dimensional Array (Primitive Base Type),Language Design Principles,Use shape to reinforce when concepts are the same,all kinds of variables (local variables, parameters, and fields) are rectangles,all objects are circles,all classes are diamonds,all references are straight arrows,all method calls are wiggly arrows with parentheses (for the arguments),Language Design Principles,Use shape to reinforce when concepts differ,variables, objects, classes all have different shapes (rectangles, circles, and diamonds),references and method calls have different shapes (straight arrows and wiggly arrows),Language Design Principles,Use position to reinforce concepts,public fields and methods are on the border of the corresponding object (if instance fields and methods) or class (if static fields and methods); border implies accessible from both inside and outside,private fields and methods are inside the corresponding object or class,static fields and methods are with the class (the diamond) while instance fields and methods are with particular objects of that class (one of the circles),each object of a class has copies of all the instance fields and methods of that class and those copies are independent,the reference inside a reference variable starts inside the variable, not on the border. This indicates that the reference is what the variable holds and that the variable can only hold one reference at a time.,Student Exposure to Diagrams,We introduce these diagrams to students on the first day of CS1 class,We ask students to produce diagrams of their own,In weekly closed labs,On quizzes and tests,In in-class groupwork,Student Exposure to Diagrams,In in-class groupwork,all groups at blackboards so that everyone can see the diagrams and multiple group members can be drawing simultaneously,everyone must be able to explain during the demonstration,no chalk for the strongest group member,at least a third of “lecture” time is spent doing this (with an upperclass student helper assisting),Student Exposure to Diagrams,How do we have the time for all the groupwork and diagramming?,Ours is a minimalist CS1:,no exception handling,no inheritance, abstract classes, or interfaces,no recursion,no inner classes or event-driven code,no graphics,but we do real console I/O (not hidden),Bottom line: reinforcement of concepts in a number of contexts,But not just for learning,Student Assessment,By having students use diagrams themselves, we have them demonstrate their comprehension of object-oriented concepts,We believe these diagrams have potential for measuring programming comprehension,Example Use in Assessment,Test Problem From Last Fall:,Diagram the program fragment below,Dog spot;,/ fig a),spot = new Dog(spot);,/ right hand side is fig b),/ left hand side and equal sign is fig c),System.out.println(spot.toString();,/ fig d),Note last line particularly,Static,public,variable (System.out),Method composition,PrintStream object,Dog object,Creation of a String object,Results(13 students),Figure a,11 correct,2 labeled rectanglewith name of class,Figure b,4 correct,2 put “spot” inside var rectangle,4 didnt show name field,3 had more serious errors,Figure c all but 1 student correct,Dog spot;,/ fig a),spot = new Dog(spot);,/ right hand side is fig b),/ left hand side and equal sign is fig c),System.out.println(spot.toString();,/ fig d),Results(13 students),Figure d,All but 3 students showed call to toString() correctly,Of those 10,2 students failed only to show System.out correctly,1 showed nothing else correctly,5 missed the creation of a String object from toString(),They got the println() call right,2 showed the String object,But they missed the println() call,Dog spot;,/ fig a),spot = new Dog(spot);,/ right hand side is fig b),/ left hand side and equal sign is fig c),System.out.println(spot.toString();,/ fig d),Evaluation of Effectiveness for Assessment,Above example illustrates how the diagrams are used qualitatively to assess student comprehension,to pinpoint problems and provide proper reinforcement of specific concepts,Can we also use them for quantitative assessment?,Can we also evaluate how effective they are in assessment?,Evaluation of Effectiveness for Assessment,Completed Study: Correlation of score on memory diagram question with rest of test and with course score,Three test questions from two CS1 classes,Two studies (correlation with rest of test and correlation with course score) for each of the three questions (three experiments),Evaluation of Effectiveness for Assessment,An example qualitative comparison using the third test question (experiment three),Histogram is sorted by memory diagram question score,The three series of scores appear to track each other,Mean score of the memory diagram question is significantly lower,not surprising since a correct memory diagram requires a deeper understanding of the effect of a program fragment,Evaluation of Effectiveness for Assessment,In the first study there were three statistical tests, one for each experiment. For those statistical tests the null hypothesis was:,H0: A student doing well on the memory diagram question does not have a positive correlation with that student doing well on the rest of the test.,The alternative hypothesis is:,Ha: A student doing well on the memory diagram question does have a positive correlation with that student doing well on the rest of the test.,Evaluation of Effectiveness for Assessment,For both studies the statistical test for each experiment used the Pearson product moment correlation coefficient as the test statistic.,The value of the Pearson coefficient ranges from -1.0 to 1.0 and reflects the extent of a linear relationship between two data sets.,The closer the value is to 1.0 the more a positive correlation exists.,Evaluation of Effectiveness for Assessment,Given that the alternative hypothesis is for a positive correlation, an upper-tail rejection region, RR = z z, was used.,The value is the probability of a Type I error and is called the significance level.,A Type I error is made if the null hypothesis is rejected when in fact the null hypothesis is true.,Evaluation of Effectiveness for Assessment,We report what is called the p-value or the attained significance level.,The p-value is the smallest level of significance, , for which the observed data indicates that the null hypothesis should be rejected.,Evaluation of Effectiveness for Assessment,Evaluation of Effectiveness for Assessment,These p-values clearly indicate that the null hypothesis should be rejected in all six experiments.,In all the experiments the p-value is less than the common guideline of 0.05. In fact for three of the cases, the p-value is even less than 0.005.,Thus, the alternative hypothesis that a positive correlation exists is accepted.,Evaluation of Effectiveness for Assessment,Current Study:,On a test give the student an English description and have the student write the Java program fragment and the sequence of memory diagrams,Determine the correlation between the two scores,Conclusion Memory Diagrams,A relatively low-tech approach for teaching OO concepts,Well-suited for classroom, labs, exams,Importance of shape and placement for reinforcing concepts,Having students make their own diagrams adds to this reinforcement,Promise of diagrams for measuring comprehension,If students can diagram what is happening in memory, they are probably understanding the deeper meaning of the program,Measured assessment effectiveness relative to rest of test and course score,Currently measuring assessment effectiveness compared to corresponding Java program fragment,Conclusion Memory Diagrams,To learn more,Mark A. Holliday and David Luginbuhl, “Using Memory Diagrams When Teaching a Java-Based CS1”,Proc. of the 41st ACM Southeast Conference, Savannah, GA, March 2003.,Mark A. Holliday and David Luginbuhl, “CS1 Assessment Using Memory Diagrams”, submitted for publication,Mark A. Holliday, “Introducing Java Using Memory Diagrams”, unpublished manuscript (CS150 lecture notes);,Presentation slides:,
展开阅读全文
相关资源
正为您匹配相似的精品文档
相关搜索

最新文档


当前位置:首页 > 图纸专区 > 大学资料


copyright@ 2023-2025  zhuangpeitu.com 装配图网版权所有   联系电话:18123376007

备案号:ICP2024067431-1 川公网安备51140202000466号


本站为文档C2C交易模式,即用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。装配图网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知装配图网,我们立即给予删除!