Seu SlideShare está sendo baixado. ×

My favorite slides

Anúncio
Anúncio
Anúncio
Anúncio
Anúncio
Anúncio
Anúncio
Anúncio
Anúncio
Anúncio
Anúncio
Próximos SlideShares
Matlab plotting
Carregando em…3
×

1 de 11 Anúncio

My favorite slides

Anúncio
Anúncio

Anúncio

Anúncio

My favorite slides

1. 1. Some of my favorite slides for Online Working Group September 13, 2012
2. 2. The Design Recipe The Design Recipe 1. Information Analysis and Data Design 2. Contract and Purpose Statement 3. Examples 4. Design Strategy 5. Function Definition 6. Tests common graphic elements emphasize unities (e.g. all "recipes" look like this)
3. 3. Create 2 new arguments for the 2 differences. (define (foldr fcn val lon) (cond [(empty? lon) val] [else (fcn (first lon) (foldr fcn val (rest lon)))])) ;; strategy: higher-order function composition (define (sum lon) (foldr + 0 lon)) (define (product lon) (foldr * 1 lon)) We could call this "foldr" (don't ask why) This is predefined in ISL, so you don't need to write out this definition Colors show analogous elements boxes provide labels and commentary
4. 4. World = Heli * Bombs * ..other stuff.. ----- world-after-tick : World -> World world-after-mouse-event : World Number Number MouseEvent -> World world-to-scene : World Scene -> Scene Heli = Posn * ..other stuff.. ----- heli-after-tick : Heli -> Heli heli-after-mouse-event : Heli Number Number MouseEvent -> Heli heli-to-scene : Heli Scene -> Scene Bombs = ListOf<Bomb> ----- bombs-after-tick : Bombs -> Bombs bombs-after-mouse-event : Bombs Number Number MouseEvent -> Bombs bombs-to-scene : Bombs Scene -> Scene Bomb = Posn * Radius ----- bomb-after-tick : Bomb -> Bomb bomb-after-mouse-event : Bomb Number Number MouseEvent -> Bomb bomb-to-scene : Bomb Scene -> Scene Observe Redundancies all functions for world have name world- and take World as first arg all functions for Heli have name heli- and take Heli as first arg all functions for Bomb have name bomb- and take Bomb as first arg all functions for Bombs have name bombs- and take Bombs as first arg but result types can be different layered introductions lead reader to draw conclusions
5. 5. Ball% = (class* object% () (field x y radius selected?) (define/public (on-tick) ...) (define/public (on-mouse ...) ...) (define/public (add-to-scene s) ...) ...) FlashingBall% = (class* Ball% () (inherit-field x y radius selected?) (field time-left ...) (define/public (on-tick) ...) (define/public (on-mouse ...) ...) (define/override (add-to-scene s) (if (zero? time-left) ...) (place-image ... x y s)) ...) x = ... y = ... radius = ... selected = ... time-left = ... (define b1 (new FlashingBall% ...)) (send b1 add-to-scene s) (send b1 on-tick) (send b1 launch-missiles) b1 Every object knows its own methods motion paths show information or control flow
6. 6. Circle% = (class* DraggableObj% (inherit-field x y) (define radius ...) (define/public (add-to-scene s) ...) (define/public (inside-this? mx my) ...) (define/public (would-hit-left-edge?) ...) ) DraggableObj% = (class* object% (field x y) (define/public (on-mouse mx my mev) ...(send this inside-this? mx my)...)) (define/public (on-tick) ...(send this would-hit-left-edge?)...) ) x = 20 y = 30 radius = 5 this = circle1 (send circle1 add-to-scene s) (send circle1 on-mouse mx my) (send this inside-this? mx my) Every object knows its own methods Here are a few of my favorite examples of motion paths