Teaching Object-Oriented Concepts Through GUI Programming Jesse M. Heines Martin J. Schedlbauer Dept. of Computer Science Univ. of Massachusetts Lowell.

Slides:



Advertisements
Similar presentations
1 Chapter 6: Extending classes and Inheritance. 2 Basics of Inheritance One of the basic objectives of Inheritance is code reuse If you want to extend.
Advertisements

OBJECT ORIENTED PROGRAMMING M Taimoor Khan
CS 211 Inheritance AAA.
Classes & Objects Computer Science I Last updated 9/30/10.
1 CSC 421: Algorithm Design & Analysis Spring 2013 See online syllabus: (also on BlueLine2) Course.
Inheritance and Class Hierarchies Chapter 3. Chapter 3: Inheritance and Class Hierarchies2 Chapter Objectives To understand inheritance and how it facilitates.
Fall 2007CS 2251 Inheritance and Class Hierarchies Chapter 3.
Issues Involved in Studio-Based Learning for a GUI Programming Class Jesse M. Heines Dept. of Computer Science University of Massachusetts Lowell
Object Oriented System Development with VB .NET
Dept. of Computer Engineering, Amirkabir University of Tech. 1 Design Patterns Dr. Noorhosseini Introduction.
Fall 2007CS 2251 Inheritance and Class Hierarchies Chapter 3.
Swing CS-328 Dick Steflik John Margulies. Swing vs AWT AWT is Java’s original set of classes for building GUIs Uses peer components of the OS; heavyweight.
1 Event Driven Programming with Graphical User Interfaces (GUIs) A Crash Course © Rick Mercer.
Advanced Object-Oriented Programming Features
Aalborg Media Lab 23-Jun-15 Inheritance Lecture 10 Chapter 8.
Satzinger, Jackson, and Burd Object-Orieneted Analysis & Design
Teaching Object-Oriented Concepts Through GUI Programming Jesse M. Heines Martin J. Schedlbauer Dept. of Computer Science Univ. of Massachusetts Lowell.
1 Object-Oriented Design. 2 Objectives F To become familiar with the process of program development. F To the relationship types: association, aggregation,
Object-Oriented Analysis and Design
Chapter 13: Object-Oriented Programming
Design Patterns academy.zariba.com 1. Lecture Content 1.What are Design Patterns? 2.Creational 3.Structural 4.Behavioral 5.Architectural 6.Design Patterns.
1 An introduction to design patterns Based on material produced by John Vlissides and Douglas C. Schmidt.
1 PH Chapter 1 (pp. 1-10) GoF Composite Pattern (pp ) PH Ch 2 through Fundamentals (pp ) Presentation by Julie Betlach 5/28/2009.
OOP Languages: Java vs C++
Lecture 7: Objects and Interaction 1  Principles of Interactive Graphics  CMSCD2012  Dr David England, Room 718,  ex 2271 
Starting Chapter 4 Starting. 1 Course Outline* Covered in first half until Dr. Li takes over. JAVA and OO: Review what is Object Oriented Programming.
COMP 6471 Software Design Methodologies Winter 2006 Dr Greg Butler
Introduction to Object-oriented Programming CSIS 3701: Advanced Object Oriented Programming.
Liang, Introduction to Java Programming, Seventh Edition, (c) 2009 Pearson Education, Inc. All rights reserved Chapter 12 Object-Oriented Design.
Introduction to Object-oriented programming and software development Lecture 1.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved Chapter 12 Object-Oriented.
1 CSC 427: Data Structures and Algorithm Analysis Fall 2011 See online syllabus (also available through BlueLine): Course goals:
An Object-Oriented Approach to Programming Logic and Design
Object Oriented Design and Programming Alan Goude Room: Sheaf 9323.
An analysis of exam results in the Object-Oriented Programming course at „Politehnica” University of Timisoara Ioan Jurca.
1 Java Inheritance. 2 Inheritance On the surface, inheritance is a code re-use issue. –we can extend code that is already written in a manageable manner.
CSC 211 Introduction to Design Patterns. Intro to the course Syllabus About the textbook – Read the introduction and Chapter 1 Good attendance is the.
3461A Readings from the Swing Tutorial. 3461A Overview  The follow is the Table of Contents from the trail “Creating a GUI with JFC/Swing” in the “The.
Java Programming: Advanced Topics 1 Common Elements of Graphical User Interfaces Chapter 6.
1 CSC 222: Computer Programming II Spring 2004 See online syllabus at: Course goals:
Chapter 9: Visual Programming Basics Object-Oriented Program Development Using Java: A Class-Centered Approach.
SWING IF YOU GET LOST - IMPORTANT LINKS  Swing articles:
Object-Oriented Design Simple Program Design Third Edition A Step-by-Step Approach 11.
Design Patterns CS 124 Reference: Gamma et al (“Gang-of-4”), Design Patterns.
SWING 101. IF YOU GET LOST - IMPORTANT LINKS  Swing articles:
Design Patterns CSIS 3701: Advanced Object Oriented Programming.
Object-Oriented Program Development Using Java: A Class-Centered Approach, Enhanced Edition.
CS324e - Elements of Graphics and Visualization Java GUIs - Event Handling.
SWE 316: Software Design and Architecture – Dr. Khalid Aljasser Objectives Lecture 13 Creational Design Pattern SWE 316: Software Design and Architecture.
1 CSC 427: Data Structures and Algorithm Analysis Fall 2006 See online syllabus (also available through Blackboard): Course goals:
Software Design Patterns Curtsy: Fahad Hassan (TxLabs)
CS 151: Object-Oriented Design October 15 Class Meeting Department of Computer Science San Jose State University Fall 2013 Instructor: Ron Mak
Design Patterns SE464 Derek Rayside images from NetObjectives.com & Wikipedia.
1 Copyright © 2004, Oracle. All rights reserved. Oracle Application Development Framework.
OO in Context Lecture 13: Dolores Zage. Confused about OO Not alone, there is much confusion about OO many programs are claimed to be OO but are not really.
Inheritance and Class Hierarchies Chapter 3. Chapter 3: Inheritance and Class Hierarchies2 Chapter Objectives To understand inheritance and how it facilitates.
Inheritance and Class Hierarchies Chapter 3. Chapter Objectives  To understand inheritance and how it facilitates code reuse  To understand how Java.
Banaras Hindu University. A Course on Software Reuse by Design Patterns and Frameworks.
Object Oriented Programming. OOP  The fundamental idea behind object-oriented programming is:  The real world consists of objects. Computer programs.
Object Oriented Programming in Java Habib Rostami Lecture 10.
Introduction to Object-oriented Programming CSIS 3701: Advanced Object Oriented Programming.
1 Event Driven Programming with Graphical User Interfaces (GUIs) A Crash Course © Rick Mercer.
Design Patterns CSCE 315 – Programming Studio Spring 2013.
CSC 222: Computer Programming II
INF230 Basics in C# Programming
MPCS – Advanced java Programming
PRG 421 GUIDE Lessons in Excellence -- prg421guide.com.
Advanced Programming Behnam Hatami Fall 2017.
Basic OOP Concepts and Terms
Object Oriented Design & Analysis
Presentation transcript:

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

2 The OOP Teaching Field The Starting Line Introducing OO concepts Working OO examples CS 1 and CS 2

3 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

4 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

5 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”

6 OOP in Class vs. at Work Small programs Large programs 100s of lines 1000s of lines Standalone Hierarchies built programsusing previous code Single files Linked modules Coded solo Coded in teams Code is never Documentation is documented absolutely required Never reused Reused repeatedly By self or others By self and others

7 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

8 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

9 Lecture: Building Bridges Problem: Set the text of the root node of an existing JTree control Subproblem: There is no method of the JTree object to set a node’s text Solution: Build a bridge from the control’s model This requires understanding relationships between objects

10 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 );

11 Lecture: Building Bridges Note that this is a very practical problem with code generators For example, NetBeans always calls the default JTree constructor 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

12 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

13 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

14 Additional Information Course websites Lecture notes, assignments, and examples teaching.cs.uml.edu/~heines See courses and on the Teaching page Contact us Our websites

15 Jesse M. Heines, Ed.D. Martin J. Schedlbauer, Sc.D. Dept. of Computer Science Univ. of Massachusetts Lowell Thank You

16 Exam: FocusTraversalPolicy Human Factors Issues  Why is it important to worry about what happens when the user presses the Tab key? Because an application in which pressing the Tab key causes focus to jump all over the place is confusing to the user and looks unprofessional.

17 Exam: FocusTraversalPolicy Use of the API  One way to set focus to a component is call the grabFocus() method. What class is grabFocus() a member of? JComponent

18 Exam: FocusTraversalPolicy Deprecated Code  The documentation says that “client code” should not use method grabFocus(). What method does the API recommend using instead of grabFocus() ? requestFocusInWindow()

19 Exam: FocusTraversalPolicy Class Relationships  A better way to implement your own focus traversal policy is to create a class that extends the built-in FocusTraversalPolicy class. Why must this be a separate class from your application’s main class, which typically extends JFrame ? Because a class can only extend one other class.

20 Exam: FocusTraversalPolicy Class Relationships  We have seen three ways to create an instance of a class that you might use for your own focus traversal policy. Name two that you might use to create a FocusTraversalPolicy class for use in your application. Create an anonymous class. Create a named inner class. Create a separate external class.

21 Exam: FocusTraversalPolicy Class Relationships and Use of API  Look up FocusTraversalPolicy and its methods in the Java API. You will see that five of the six methods are abstract. What implication does this have for the class that you create that is derived from the built-in FocusTraversalPolicy class? You must implement each of the abstract methods or you will not be able to instantiate your class.

22 Exam: FocusTraversalPolicy Application of the Concept  Once you have defined a focus traversal policy, you must associate it with your JFrame. What method performs this function, and what class is that method a member of? setFocusTraversalPolicy in class java.awt.Container