On this page:
Readings
Supplemental Materials
Pre-lecture
Goals
In-class
Homework

Module 13

Last updated: Mon, 20 Apr 2015 16:40:05 -0400

Readings
Supplemental Materials
Pre-lecture
  1. Read the Readings and Supplemental Materials.

Goals
In-class

The following big-bang program displays a ball bouncing inside a box (start with (run)).
The box may be resized by clicking and dragging on its right edge. However, the ball does not change behavior when the box is resized because the sharing of the Box% object is lost when the World% creates a new Box% but does not update the Ball%.
Fix this program by using mutation. Use either the "push" or "pull" style, as described in the course notes. If you go with the "push" approach, define explicit Subscriber<%> and Publisher<%> interfaces. Be ready to justify your design choice.
Make sure your code follows the Effectful Methods style guide.
Here are some Racket functions and forms that may be useful in effectful programs:
Also, some Racket forms have an implicit begin in their bodies:
This means that the following f and g functions are the same.
> (define Y 100)
> (define Z 200)
> (define (f x)
    (begin
      (set! Y (+ Y x))
      (set! Z (+ Z x))
      (+ Y Z x)))
> (define (g x)
    (set! Y (+ Y x))
    (set! Z (+ Z x))
    (+ Y Z x))
> (f 10)

330

> Y

110

> Z

210

> (g 10)

350

> Y

120

> Z

220

Solution 1 (pull):
Solution 2 (push):

Homework

Problem Set 13