Data vs. Information Think about the problem, what information is available? ¥ Shark: what do we know about him? where is the shark how hungry is the shark ¥ Fish: where is the fish? How fast is it swimming? Did it swim out of the game area? ¥ Game area: How wide, how tall? Background color? Data vs. Information ¥ World consists of the area, the fish and the shark ¥ Shark Position - consists of the x and y coordinate Life time remaining ¥ Fish Position - consists of the x and y coordinate ... maybe the speed ¥ Game area width and height We also have to draw the shapes. Design the classes for Fish, Shark, OceanWorld. ¥ Design Recipe for Data Definition: -- can it be represented by a primitive type? - select the type -- are there several parts that represent one entity? - a class -- are there several related variants? - a union of classes -- add arrows to connect data definitions ¥ Convert information to examples of data ¥ Interpret data as information Designing the functionality Think of the tasks to do: ¥ Move the shark up and down in response to the arrow keys ¥ Move the fish left as the time goes on ¥ Replace the fish with a new one if it gets out of bounds ¥ Check if the shark ate the fish - if yes, replace the fish with a new one ¥ Starve the shark as the time goes on, check if he is dead (Think of the verbs: move, replace, starve, ate, check ...) (Think of questions: ate the fish? out of bounds? is dead? ...) Designing the program ¥ How do you eat an elephant? - one bite at a time One task --- one function/method ¥ Think systematically about each small task ¥ Make a wish list if the task is too complex Program tasks - somewhat decomposed: ¥ Move the shark up and down in response to the arrow keys ¥ Move the fish left as the time goes on ¥ Is the fish out of bounds? ¥ Replace the fish with a new one ¥ Can the shark eat the fish ¥ Shark eats the fish --> fish dies --> is replaced by a new one ¥ Is the shark dead? ¥ Starve the shark as the time goes on