Nifty Assignment: Abstract Factories and the Shape Calculator

OOPSLA 2004 Educators Symposium

The Shape Calculator is an assignment targeted at CS1 students in an objects-first curriculum.  It can serve as a powerful yet entertaining example of the advantages of object-orientation.

I've Read This
  • 69 Views
Abstract Factories and the Shape Calculator
    Eric Cheng, Dung “Zung” Nguyen, Mathias Ricken, Stephen Wong
    Dept. of Computer Science Rice University Houston, TX 77005 +1 713-348-3835
    
    ericc@rice.edu, dxnguyen@rice.edu, mgricken@rice.edu, swong@rice.edu
    
    ABSTRACT
    The Shape Calculator is an assignment targeted at CS1 students in an objects-first curriculum. It can serve as a powerful yet entertaining example of the advantages of object-orientation.
    
    encapsulation, inheritance and polymorphism.
    
    3. WHAT MAKES IT SO NIFTY?
    This assignment is interesting and useful for several reasons: • The assignment mixes fun with theory--motivates the students to learn important concepts and techniques. With straightforward code, the assignment demonstrates powerful OO capabilities that are very difficult to replicate using procedural techniques. The exercise covers a broad spectrum of skills and concepts without being overwhelming (see the list of skills list in section 5). The assignment focuses on the thought processes involved with the design of OO systems. It is orchestrated step-by-step process that gradually gives more rein to the students. Students create a fully functional, complete, non-trivial GUI program from scratch, not just a "toy" function in a pre-built system.
    
    Categories and Subject Descriptors
    D.1.5 [Programming Programming Techniques]: Object-oriented
    
    •
    
    General Terms
    Design.
    
    •
    
    Keywords
    CS1/CS2, objects-first, design patterns, abstract coupling, loose coupling, pedagogy, assignments, software quality.
    
    • • •
    
    1. INTRODUCTION
    In our submission, we describe the Shape Calculator, an assignment that has been used in our institution’s COMP 201 objects-first introductory course. It is sufficiently complex yet entertaining for the students, which makes it suitable as a compelling example for the benefits of object-oriented design and programming. The Shape Calculator is a GUI application that can compute the area of an arbitrary shape. The class representing this shape can be compiled at a later time and loaded into the program at runtime.
    
    4. TARGET AUDIENCE
    The target audience for this assignment is CS1 students in an objects-first curriculum. The Rice students working with this assignment are nine weeks into CS1 and have already seen polymorphism, several elementary design patterns (see prerequisites in section 7), lists and recursion.
    
    5. IDEAS AND SKILLS INVOLVED 2. ASSIGNMENT DESCRIPTION
    Create a GUI application that computes the area of an arbitrary shape that can be dynamically loaded at run time. The shape can have an arbitrary set of configuration properties (e.g. width, height, color, etc.). This assignment is designed as an introduction to GUI programming in Java, where the GUI programming, which besides being a valuable skill unto itself, is used to emphasize and illustrate compelling usage of When working on this exercise, students gain understanding in the following areas: • • • • •
    Copyright is held by the author/owner(s). OOPSLA’04, Oct. 24–28, 2004, Vancouver, British Columbia, Canada. ACM 1-58113-833-4/04/0010.
    
    • •
    
    How to create a simple window frame and populate it with panels, buttons, labels and text fields. Using anonymous inner classes as event listeners in GUIs. Using abstract factories to manufacture products whose concrete type is immaterial to the client. Using anonymous inner classes to define concrete instantiations, especially in the context of factories. Using the closure properties of anonymous inner classes to directly access both instance and final local variables. Using graphics calls to paint a simple shape onto a component. Understanding the service nature of a component in a
    
    •
    
    • •
    
    framework, e.g. painting service of a GUI component. Numerous demonstrations of polymorphic behavior, especially those that cannot be replicated with conditional statements. Using an incremental process to build a complex software system by gradually adding components and capabilities. Using simple exception handling.
    
    • • •
    
    Factory design pattern Composite design pattern Syntax for anonymous inner classes
    
    8. DIFFICULTIES TO WATCH FOR
    Instructors using this assignment should be aware of the following difficulties: • Understanding the service-oriented aspect of screen painting. Students often struggle with the inverted control aspects of a component in the GUI framework. Understanding the communications aspects of closures in anonymous inner classes. o Why local variables are required to be final. o Utilizing direct access to variables that are outside the anonymous inner class but within its closure.
    
    6. LENGTH OF ASSIGNMENT
    At our institution, the assignment is a laboratory exercise (1.5 hrs) that extends into a week-long homework assignment (3-6 hrs). •
    
    7. PREREQUISITE MATERIAL
    The students should be familiar with and had some programming experience with: • • • • Polymorphism and inheritance Abstract structure and behavior Singleton design pattern Delegation model programming
    
    9. INSTRUCTION MATERIALS
    The assignment, a demo, the solution, and supporting lectures have been submitted to the Educator’s Symposium. The actual assignment at our institution can be found at http://www.owlnet.rice.edu/~comp201/04-spring/labs/lab09/ .
    
    They need only be acquainted with and not necessarily adept at:

Readers

Recent searches finding this paper
nifty Calculators via Google
design pattern assignments via Google
abstract for calculator program using java via Google
abstract for calculator program using java via Google
java shape area calculater programm code with inheritance via Google
CS1 assignment via Google
List of java assignments abstract factory pattern via Google
OOP assignment inheritance via Google
example of simple inheritance in java to find the area of give shape via Google
assignment abstract via Google
research assignment abstract via Google
java GUI non functional calculator via Google
polymorphism in GUI frame via Google
polymorphic assignment in java via Google
software area calculator paper via Google
"Advantages" + "Polymorphic Assignment" via Google
nifty calculator demo via Google
gui.java abstract dynamic pattern via Google
gui.java abstract dynamic pattern via Google
java polymorphic assignments via Google
polymorphism in GUI frame via Google
assignment abstract via Google
abstract assignment example via Google
painting ricken via Google
programming inheritance assignment via Google
java exception assignment site:.edu via Google
I have a java assignment to use shapes with inheritance via Google
assignment abstract via Google
exception handling java assignment via Google
how to make the introduction of the assignment about using of calculators via Google
simple area calculator class shape class via Google
university answers for advantages of polymorphism in oops via Google
programming assignment polymorphism via Google
programming techniques assignment 4 via Google
design pattern and shape via Google
Only Abstract for a calculator in java via Google
java assignments for inheritance via Google
polymorphic assignment via Google
java inheritance assignment via Google
research paper nifty via Google
understanding java programming assignments, solutions via Google
polymorphic assignment via Google
interesting Nifty Programming Assignments via Google
java+polymorphism+area+computation via Google
java+polymorphism+area+computation via Google
example of java inheritance assignment via Google
polymorphic assignment via Google
nifty calculation on time pattern via Google
university java assignment via Google
comp201 software engineering assignment 2 solution via Google
java inheritance assignments via Google
java exception handling university assignment via Google
nifty assignment via Google
Inheritance Assignments Java via Google
Inner assignments java via Google
java assignments university via Google
assignment on java design pattern via Google
nifty university via Google
mathias ricken via Google
example of assignment abstract via Google
Java, University assignments via Google
Abstract of research paper on nifty via Google
pattern of inheritance assignment via Google
java polymorphism assignment via Google
java polymorphic assignment via Google
java Inheritance assignment via Google
google calculator GUI via Google
shapes area program calculation using gui java via Google
find area of shapes using GUI components via Google
google assignment exercises via Google
answers to understanding shape assignment 4 feb 09 via Google
gui programming"add a comment" via Google
understanding shape assignment 4 via Google
The purpose of this assignment is to exercise the application of a pattern in your design. via Google
java inheritance assignments via Google
Assignment example for design pattern via Google
solutions for COMP201 Software Engineering I assignment 2 via Google
java inheritance assignment via Google
GUI Application Assignment via Google
assignment pattern for university via Google
oop Assignment of shape via Google
assignments for java inheritance via Google
assignment execise java univesity via Google
Shapes java design pattern inheritance via Google
design+patterns+java+assignment+exercise via Google
design+patterns+java+assignment+exercise via Google
design+patterns+java+assignment+exercise via Google
java assignments + university via Google
java inheritance polymorphism homework gui via Google
concrete shape calculator via Google
Assignment for university in the field of paintings via Google
nifty assignments abstract java via Google
java inheritance polymorphism assignments via Google
java lists and polymorphism shape toy via Google
assignment abstract via Google
inheritance polymorphism assignment via Google
inheritance polymorphism assignment via Google
text area computation in gui via Google
Polymorphism assignments via Google
java assignment university via Google
 

Academia © 2009