150 likes | 269 Views
Teaching Object-Oriented Concepts Through GUI Programming. Jesse M. Heines Martin J. Schedlbauer Dept. of Computer Science Univ. of Massachusetts Lowell. Eleventh Workshop on Pedagogies and Tools for the Teaching and Learning of Object Oriented Concepts ECOOP, Berlin, Germany, 30 July 2007.
E N D
Teaching Object-Oriented Concepts Through GUI Programming Jesse M. Heines Martin J. Schedlbauer Dept. of Computer ScienceUniv. of Massachusetts Lowell Eleventh Workshop on Pedagogies and Tools for the Teaching and Learning of Object Oriented Concepts ECOOP, Berlin, Germany, 30 July 2007
The OOP Teaching Field • The Starting Line • Introducing OO concepts • Working OO examples • CS 1 and CS 2
The OOP Teaching Field • The Starting Line • Introducing OO concepts • Working OO examples • CS 1 and CS 2 • The Finish Line • Applying OO concepts • Solving programming problems • Advanced courses
The OOP Workshop Field • 3 papers dealing with “Beginners,” “CS1&2,” and “Novice Programmers” • Schmolitzky • Späh and Schmolitzky • Ma, Ferguson, Roper, and Wood • 2 papers on “Objects First” • Ehlert and Schulte • Shümmer and Kösters • 2 papers on applying OO concepts • Hadar and Hadar • Heines and Schedlbauer
The OOP Cognitive Field • Our experience is that regardless of how and when OO concepts are introduced, students have trouble applying those concepts in project-based courses • Why? • Lack of experience with large programs • The real benefits of OO are difficult to see in the small programs typically used as examples • Consequently, OO concepts do become part of the student’s cognitive field and programming style • “I need an object” instead of “I need a routine”
OOP in Class vs. at Work • Small programsLarge programs • 100s of lines 1000s of lines • StandaloneHierarchies builtprogramsusing previous code • Single files Linked modules • Coded soloCoded in teams • Code is never Documentation is documented absolutely required • Never reusedReused repeatedly • By self or others By self and others
OOP and GUI Programming • Excellent examples of class hierarchies • Java Swing and .NET • Students learn just by browsing • Excellent tools for large programs • NetBeans, Eclipse, Visual Studio, BlueJ • Form designers and code generators • (Mostly) excellent documentation • Using the API is a critical skill • Creating an API is even more critical • Model for student-created documentation
OOP and GUI Programming • Inclusion of design patterns • Observers = MVC architecture & listeners • Strategies = layout managers • Composites = UI components & containers • Decorators = scroll panes and borders • Singletons = calendars • Factories = borders • Commands = menus
Lecture: Building Bridges • Problem:Set the text of the root node of an existingJTree control • Subproblem: There is no method of the JTreeobject to set a node’s text • Solution: Build a bridge from the control’s model • This requires understanding relationshipsbetween objects
Lecture: Building Bridges • Step 1: Create a new root node DefaultMutableTreeNode root = new DefaultMutableTreeNode ( "New Text" ); • Step 2: Get reference to the tree model TreeModel myTM = myJTree.getModel(); • Step 3: Cast the tree model reference DefaultTreeModel myDTM =(DefaultTreeModel) myTM; • Step 4: Set the tree root myDTM.setRoot( root );
Lecture: Building Bridges • Note that this is a very practical problem with code generators • For example, NetBeans always calls the default JTreeconstructor myJTree = new JTree(); • One could write “post-creation” code to set the root node text, but this is a static change, not a dynamic one • Thus, this problem forces students to use the API and think about the objects involved and their relationships
Assignment: Object Comm. • Problem:Pass data from a custom dialog box (JFrame) to its parent class • Subproblem: Default member variable access method is private • Solutions: • Change access method • Use Component.getParent()method • Pass reference to parent in overloaded constructor
Exam: FocusTraversalPolicy • Center questions around a concept that students are familiar with (focus traversal), but a class that students have not worked with • Actual questions are in Figure 5 in paper • 7 questions address 5 OOP areas • Human Factors Issues • Use of the API • Deprecated Code • Class Relationships • Application of the concept
Additional Information • Course websites • Lecture notes, assignments, and examples • teaching.cs.uml.edu/~heines • See courses 91.461 and 91.462 on the Teaching page • Contact us • heines@cs.uml.edu • mschedlb@cs.uml.edu • Our websites • http://www.cs.uml.edu/~heines • http://www.cs.uml.edu/~mschedlb
Thank You Jesse M. Heines, Ed.D. Martin J. Schedlbauer, Sc.D. Dept. of Computer Science Univ. of Massachusetts Lowell