Lumaktaw sa pangunahing content

EP:20 - Domain Analysis

Part 20. Domain Analysis

For interactive programs such as these, we will use the How to Design Worlds recipe. This is our guide for developing most interactive programs, in big-bang, these are called world programs.

There are 2 parts when designing interactive programs, first is that we use pen and paper for the concept and then we then code the whole thing from our analysis.

We are going to design the walking cat program using the recipe. The cat would start at the left edge of the display and walks across the screen. When it reaches the right side, it should just continue walking off screen

The interactive part is that we can use the spacebar key to bring the cat back to the left side.

There are 4 steps in domain analysis

  1. Sketch program scenarios
  2. Identify constant information
  3. Identify Changing information
  4. Identify big-bang options
First we sketch program scenarios, we would need pen and paper for this one.

These 2 or 3 images shows the states of the program. From this information we should look for the interesting parts. Depending on the complexity of the interface, we many need more than 3 images.

The second step is to look for constant information. This is the information that does not change throughout the progression of the program.

The constants in the program are the width and height on the screen, the cat's y coordinate is not changing and sits at the center. The background image is also not changing. The image of the cat is not changing.

There will be some times that you will forget to include items, just go back and add them to the appropriate list.

The only changing thing across the scenes is the x coordinate of the cat image.

Finally, we can select some functions that would fulfill the constraints passed on the scenes. In Dr. Racket, we need to select the functions of the big-bang primitive that would fulfill the requirements specified.


Mga Komento

Mga sikat na post sa blog na ito

Problem Solving using HtDF method

Problem Solving In this problem, we will use the HtDF method to create a function. Problem:  Design a function that pluralizes a given word. (Pluralize means to convert the word to its plural form.) For simplicity you may assume that just adding s is enough to pluralize a word. Here is the problem that we need to convert into a function. We need to do it systematically using the HtDF method. First we need the signature, recall that the signature will tell us what is the input and expected output. A word is the input and output of the function, and we can represent words, which is just a sequence of characters if you think about it, like a String. So the signature of the function is ;;String -> String Then we will need to know what is the function's purpose, we can look at the specifications to know the purpose. It says that the word is pluralized in the process "assumption that adding s at the end is the pluralized form of the word". Ther...

EP: 18 - HtDF with Itemization

Part 18. HtDF with Itemization From the Countdown Display definition that we have made earlier, we are going to make a function out of it. We have to output an image depending on the state of the countdown.  Here is the Signature, Purpose and Stub. It is recommended to run the code often, the earlier we detect bugs, the better. We need some examples. For tests on itemizations, we need to have as many tests as there are cases. Also, if we have an interval, we have to test points of variance. For the Interval, there is not much variance in the seconds before midnight so it is okay to have only one test for that. There is a primitive called text which converts text to an image, we can also use number->string to convert a number into a string datatype. Note that when we are devising tests, we are already working out the behavior of the function before we start coding. Now we get the template and start creating the function body.  ...

EP: 9 - What not to do when designing functions

Part 9. Errors when designing functions. Mistakes can be made when designing functions. Here are common mistakes when using the HtDF method. 1. Do not repeat the Signature when making the purpose. The signature only shows us the Input and Output of a function, it does not say anything about its purpose. The purpose asks the question on what we do with the parameters and how can it generate the output. 2. Make sure the test is consistent with the purpose, should the test comes up wrong, either check the test itself with the purpose, signature or check the function body. Tests can also fail, take a deep hard look on what is causing that problem, there is a chance that the test is wrong so check it also.