Recitation 7 - PowerPoint PPT Presentation

About This Presentation
Title:

Recitation 7

Description:

Like Chess but the winning objective is to lose all your pieces. Involves: chess board design, AI player, referee. Algorithmically intensive ... – PowerPoint PPT presentation

Number of Views:26
Avg rating:3.0/5.0
Slides: 18
Provided by: alle4
Learn more at: http://nms.lcs.mit.edu
Category:
Tags: recitation

less

Transcript and Presenter's Notes

Title: Recitation 7


1
Recitation 7
  • Godfrey Tan
  • March 21, 2002

2
Administrivia
  • PS6 due Tuesday right after break
  • Final Project descriptions will be handed out
    Monday after break
  • Each group must agree on the common project
  • If you are not satisfied with your group
    assignment, you should complain to me by the end
    of recitation.

3
Final Project
  • Choice of two projects Gizmoball, Anti-chess
  • Equal difficulty/amount of work
  • Each TA will provide help on one of two projects
  • A spec amendment will be introduced halfway
    through your project

4
Gizmoball
  • Ball bounced around by gizmos (demo)
  • Physics package will be provided
  • can be extended (e.g. magnetic field, relativity)
  • Open-ended goal
  • pin-ball, visual effect, physics simulation, etc.
  • GUI/graphics intensive
  • Competition?

5
Antichess
  • Like Chess but the winning objective is to lose
    all your pieces
  • Involves chess board design, AI player, referee
  • Algorithmically intensive
  • Anti-chess tournament

6
Choosing Your Project
  • Preliminary descriptions will be posted on April
    1
  • People without a group should indicate their
    preference by this afternoon to help us assign
    groups
  • Email will be sent to the class soon

7
True Subtyping
  • Substitution priniciple
  • Subtypes must be substitutable for supertypes
  • The rep invariants and specification constraints
    of the supertypes must not be violated by the
    subtypes
  • Subtypes may have more methods and properties so
    long as they abide by the substitution principle.

8
Subclassing in Java
  • Pure implementation inheritance
  • Does not worry about the behavioral constraints

9
Problems with subclassing
  • Break encapsulation
  • May lead to abuse sub-classing things that are
    not subtypes (e.g. Stack extends Vector)
  • Should only be used when a true sub-type
    relationship exists

10
Example
  • class IHashSet extends HashSet
  • private int addCount
  • public void add(Object o)
  • addCount
  • super.add(o)
  • public void addAll(Collection c)
  • addCount c.size()
  • super.addAll(c)

11
Example
  • class IHashSet extends HashSet
  • private int addCount
  • // _at_modifies addCount
  • public void add(Object o)
  • addCount
  • super.add(o)

12
Composition and Forwarding
  • Composition A class that contains another class
    (a wrapper)
  • Forwarding A class that calls methods of the
    other class that it contains
  • No longer a subtype rather, it is a different
    implementation of the same interface
  • IHashSet extends Set vs IHashSet implements Set
  • Gives programmer more control with method
    dispatching (vs Javas default)
  • Drawback more code less efficient (added level
    of indirection)

13
Example
  • class IHashSet implements Set
  • private HashSet s
  • private int addCount
  • public void add(Object o)
  • addCount
  • s.add(o)
  • public void addAll(Collection c)
  • addCount c.size()
  • s.addAll(c)

14
pset 6
  • Design, implement GUI and then integrate it with
    your backend
  • Testing GUI
  • Use state machine to model GUI events
  • Decouple GUI testing from backend testing
  • Insert println statements before and after you
    call backend API method
  • or, create a dumb backend stub

15
State Machine
  • Directed graph nodes represent a state and arcs
    represent a transition (action) caused by an
    input (event)

Portfolio Name Input
Add PortfolioButton Pressed
Initial
16
Testing
  • Excite all transitions with all boundary inputs
    (e.g., adding a Portfolio with new name, with an
    existing name, etc.)
  • GUI should handle exceptional inputs (e.g.
    entering alphabets instead of numbers for number
    of stocks to purchase)

17
Integration Testing
  • Repeat your GUI test (using the same input values
    from your backend tests if possible), and check
    if your program still works!
  • Hopefully, you will have repChk() in your backend
    to catch your bugs.
Write a Comment
User Comments (0)
About PowerShow.com