Back Edit Import Questions Delete

3a How to Design Worlds

In Systematic Program Design

Questions

New Question Start Quiz
What should you identify during HtDW domain analysis?
Multiple choice
What does the world-state data definition represent?
Multiple choice
Which big-bang option installs a keyboard handler?
Multiple choice
What is the standard signature for an on-tick handler?
Multiple choice
What is the standard signature for a to-draw handler?
Multiple choice
What is the normal parameter order for a key handler?
Multiple choice
Why are wish-list stubs needed before all handlers are implemented?
Multiple choice
How are an HtDF stub and an HtDW wish-list stub similar?
Multiple choice
Conceptually, what happens after on-tick produces a new world state?
Multiple choice
What is white-box testing for a KeyEvent handler?
Multiple choice
A key handler changes the world only for the space key. What is a sensible minimal branch-focused test set?
Multiple choice
If unrelated keys should do nothing, what should the handler usually return in its else branch?
Multiple choice
Why is an expectation such as (+ 3 SPEED) often better than hardcoding 6?
Multiple choice
What does traceability mean in the HtDW recipe?
Multiple choice
When adding a new key-controlled behavior to a world program, what should happen first?
Multiple choice
A world program represents a ball moving horizontally across the screen. The only changing information is the ball's x-coordinate. Define a data definition named BallWorld for the world state, include an interpretation, and write the basic template for a function that consumes a BallWorld.
Short answer
Write a big-bang expression for a world program that starts at 0 and uses tick as its on-tick handler, draw as its to-draw handler, and handle-key as its on-key handler.
Short answer
Write the signatures and stubs for three handlers: tick updates a WorldState every clock tick, draw renders a WorldState as an Image, and handle-key consumes a WorldState and KeyEvent and produces a WorldState.
Short answer
A key handler should reset the world to 0 when the space key is pressed and otherwise leave the world unchanged. Write the handler and two check-expect tests: one for the space key and one representative unrelated key.
Short answer
Explain the flow of information in a simple big-bang program after an on-tick event occurs. Describe what the tick handler receives and produces, what happens to that result, and how to-draw is involved.
Short answer
Write the signatures for these three world handlers: (1) tick consumes a WorldState and produces the next WorldState; (2) draw consumes a WorldState and produces an Image; (3) handle-key consumes a WorldState and a KeyEvent and produces a WorldState. Pay attention to the parameter order for the key handler.
Short answer
You are designing a world program but have not implemented its handlers yet. Write callable stubs for tick, draw, and handle-key with the signatures WorldState -> WorldState, WorldState -> Image, and WorldState KeyEvent -> WorldState. Do not implement the real behavior yet.
Short answer
Write a complete key handler named handle-key that resets a numeric WorldState to 0 when the space key is pressed and otherwise returns the world unchanged. Then write two check-expect tests: starting from 20 with the space key should produce 0, and starting from 20 with the key "a" should produce 20.
Short answer

Quiz Sessions

Session #20 Session #21 Session #22