Snake 3 ways: procedural, object-oriented, functional
to continue. (After that any entries made into the worksheet will be automatically saved, and you can re-load the partially-completed worksheet in future - at which point you will be asked to auto-save it again).
Enter your name:

### Preliminaries

- set the browser to Full Screen view, to give this worksheet, and your code, as much space as possible.
- Remember that if the code editor has a tinted background it does not have focus and will not respond to edits. To give it focus click within the editor. (If a program is running, you will need to stop it first.)

Preliminaries completed

### Snake - procedural

From the Demo menu, access the Snake - procedural program, and run it (briefly!) to see how it works. Explore the code to answer the following questions. You might find it helpful to switch the code to 'outline' view (using the outline button) to answer some of them.

1. How many instructions does the program have, not counting the tests (which are all at the end of the program)?
2. What is the longest method (main,procedure, or function) - measured by number of instructions (including the method signature)?
3. What is the deepest level of indentation within any method - where the first instruction within the method is deemed to be 'level 0'?
4. What is the largest number of parameters passed into any one procedure or function)?
5. What percentage of the instructions (not counting code in tests) is covered by tests? You can assume that:
   - The only code being covered by tests is in functions
   - Where a test tests a specific function, assume that all paths through that function are tested
   So this question is really just asking: what proportion of the program's instructions is represented by the functions that have a corresponding test?
6. What, if anything, stands out for you about this code - positively and/or negatively?

Step completed

### Snake - object-oriented

From the Demo menu, access the Snake - object-oriented program. Verify - if you wish to - that from the player's perspective it works identically to the previous implementation. Explore the code to answer the following questions. You might find it helpful to switch the code to 'outline' view (using the outline button) to answer some of them.

1. How many instructions does the program have in total, not counting the tests (which are all at the end of the program)?
2. List the names of all the user-defined classes:
3. Not counting any code within tests, what percentage of the total program instructions is defined in classes (include the class instructions)?
4. Which of the user-defined classes define any private members?
5. Which of the user-defined classes are 'singletons' - meaning that they are only ever instantiated once during a program run (ignore instantiation in tests)?
6. What is the longest method (main,procedure, or function) - measured by number of instructions (including the method signature)?
7. What is the deepest level of indentation within any method - where the first instruction within the method is deemed to be 'level 0'?
8. What is the largest number of parameters passed into any one procedure or function)?
9. Which function methods, on which classes, are not tested (see comments in the tests)
10. Why, in general terms, are there not tests for some function methods? (Look for comments)
11. What, if anything, stands out for you about this code - positively and/or negatively?

Step completed

### Snake - functional

From the Demo menu, access the Snake - functional program. Verify - if you wish to - that from the player's perspective it works identically to the other two implementations. Explore the code to answer the following questions. You might find it helpful to switch the code to 'outline' view (using the outline button) to answer some of them.

1. How many instructions does the program have, not counting the tests (which are all at the end of the program)?
2. What percentage of the program instructions (per above) are within functions (including the function instructions)?
3. Are any 'higher order functions' used in this program?
4. List the names of the user-defined records within the program. Note that only one is similar to a class in the object-oriented version.
5. Records in Elan do not have 'constructors' - but there is code that performs an equivalent role? Where is it?
6. What is the longest method (main, or function) - measured by number of instructions (including the method signature)?
7. What is the deepest level of indentation within any method - where the first instruction within the method is deemed to be 'level 0'?
8. What is the largest number of parameters passed into any one function)?
9. What percentage of the instructions (not counting code in tests) is covered by tests? You can assume that:
   - The only code being tested is in the functions
   - Where a test tests a function, assume that all paths through that function are tested
   So this question is really just asking: what proportion of the program's instructions is represented by the functions that have a corresponding test?
10. What, if anything, stands out for you about this code - positively and/or negatively?

Step completed

### Conclusions

What have you learned from exploring these three different implementations of the same application?

What unasnwered questions has it left you with?

This is the end of the worksheet - check the box below to finish. Step completed