Presentation is loading. Please wait.

Presentation is loading. Please wait.

OOPSLA ’04 Educator’s Symposium

Similar presentations


Presentation on theme: "OOPSLA ’04 Educator’s Symposium"— Presentation transcript:

1 OOPSLA ’04 Educator’s Symposium
Nifty Assignment: The Shape Calculator Fix the link; fix code to close the window w/o AFrame Demo (3) Make the font bigger Big buttons Triangle factory w/ 3 points – write code, compile at runtime, load Get students’ solutions (for each part) from last semester Explain the assignment Must have demo in binary with some shapes for student to work with Makes clear of the functionality requirements Break into 4 parts and 4 directories; grade one piece at a time Why is it so nifty? Eric Cheng, Dung Zung Nguyen, Mathias Ricken, Stephen Wong Rice University

2 Niftiness Swing GUI application with the MVC pattern.
Closures via anonymous inner class Callback architecture Extensibility and security via factories Dynamic nature of OO programs Abstraction! Rice University

3 What is a shape? Rice University

4 What is a shape? Knows how to compute its area
Knows how to present itself visually Rice University

5 How do we make a shape? Constructor for a rectangle:
public Rect(double width, double height) Constructor for a circle: public Circle(double radius) How to call a constructor if its parameters are unknown? Rice University

6 Factory design pattern
Factories know how. Can specify a clear definition of a factory: we know how to make factories. Rice University

7 Behavioral definitions
IShapeFactory JPanel getPropertyPanel() IShape makeShape() IShape double getArea() void paint(Graphics g, int x, int y) Move IShape next to “what’s a shape?” Pop up UML or code of the IShape interfrace Move IShapeFactory as well. Rice University

8 Behavioral definitions
Interfaces define behaviors. A factory is a factory if it satisfies the protocols; a shape is a shape if it complies to our definition. No need to have explicit class definitions. Closures Can have not only area, but also colors! Dynamically load code at runtime Delete this. Rice University

9 Philosophical / Design Question
Should the shape know about, or even have the factory? Rice University

10 GUI builders for IDEs Rely on zero-ary public constructors for components. Breaks encapsulation. Violates definition of the component (is a shape a factory?) Can possibly break the system by creating an “immature”, but perfectly legal shape. Rice University

11 Our goal The clear distinction and separation of responsibilities
Each piece of component does what it is meant to do, and expose the appropriate amount of information Rice University

12 Questions? Rice University


Download ppt "OOPSLA ’04 Educator’s Symposium"

Similar presentations


Ads by Google