---
title: Eboard 08  Testing your procedures
number: 8
section: eboards
held: 2017-09-11
---
CSC 151.03, Class 08:  Testing your procedures
==============================================

_Overview_

* Preliminaries
    * Notes and news
    * Upcoming work
    * Extra credit
    * Notes on the quiz
    * Questions
* Lab
* Debrief

### News / Etc.

* New places/partners!
* Quizzes returned.
* Homework returned, too (at least for some of you).
* And even some labs.
* I'm still working on catching up.  Sorry.  "The best laid schemes"
  and all that.

### Upcoming Work

* [Writeup for class 7](../writeups/writeup07) due TONIGHT at 10:30 p.m.
    * Document `take`
    * To: <csc151-03-grader@grinnell.edu>
    * Subject: CSC 151.03 Writeup 7 (YOUR NAMES)
* [Assignment 3](../assignments/assignment03) due Tuesday.
* [Writeup for class 8](../writeups/writeup08) due Wednesday at 10:30 p.m.
    * Exercises 3d and 6.
    * To: <csc151-03-grader@grinnell.edu>
    * Subject: CSC 151.03 Writeup 8 (YOUR NAMES)
* Read: [Heterogeneous lists](../readings/heterogeneous-lists) for Wednesdays's class. 
* Read: [Representing tables](../readings/tables) for Wednesdays's class. 

### Extra credit (Academic)

* CS Table, Tuesday, noon: Machine Ethics.  (Info on Friday's eboard.)
* CS Extras, Thursday at 4:15 p.m. in 3821.  A UI for Chemical Reaction
  Networks.

### Extra credit (Peer)

* ???

### Extra Credit (Misc)

* Time Management Workshop, Tuesday, 11am, JRC 226.
* Host a prospie (future)

### Other Good Things

* Men's Soccer vs. Buena Vista, Sept. 17 at 2:00 p.m.

### Quiz 2

* Wide distribution of scores, not correlated with prior experience.
* Some struggling with syntax.  Some struglling with so many things
  at so many different levels.

Notes on definitions from part 1

```
; cat is a procedure that doubles its parameter
(define cat (section * <> 2))
; mouse is a procedure that increments then doubles 
(define mouse (o cat increment))
; The section adds 5
; So moose adds 5 and then computes the square root
(define moose (o sqrt (section + <> 5)))
; squirrel is 11
(define squirrel 11)
```

Interactions

```
> squirrel
11
> (mouse 5)
12
> (moose squirrel)
4
> ((section - <> 2) 5)
3
> (map (section - <> 2) (list 1 2 3 4 5))
'(-1 0 1 2 3)
> (5 (section - <> 2)) ; 5 is not a procedure
. . application: not a procedure;
 expected a procedure that can be applied to arguments
  given: 5
  arguments...:
> (map cat (iota 6)) ; (iota 6) => '(0 1 2 3 4 5), cat doubles
'(0 2 4 6 8 10)
```

Use `string-append` to define a procedure that takes one input and
generates "Hello .... How was your day?"

```
(define greet
  (lambda (name)
    (string-append "Hello " 
                   name 
                   ". How was your day?")))
```

With section


```
(define greet
  (section string-append "Hello " 
                         <>
                         ". How was your day?"))
```

### Questions

Why is there food in the back of the room?
  : I'm tasked with feeding folks in a once-per-month meeting.  I bring
    my post-meeting class leftovers.

How should we indent?
  : When you think it would be clearer to see the parameters separated
    one per line
  : When your lines are getting really long (> 80 columns)

How much should we indent?
  : Trust DrRacket.
  : Ctrl-I reindents. 

What are some Ctrl things I should know?
  : Ctrl-S - Save (it will crash; save early and often)
  : Ctrl-up-arrow - Previous (escape p)
  : Ctrl-down-arrow - Next (escape n)
  : Ctrl-R - Run (the definitions pane)
  : Ctrl-Enter - Execute current command in interactions pane, even
    if the cursor is not at the end of the command.
  : Ctrl-I - reindent

The sections are out of synch
  : Computers are sentient and malicious, even to your sentient and
    malicious instructor.

Do we have to document our procedures?
  : Of course.  4P's is often okay.

But I turned in my assignment already.
  : That's okay, you have another 33 hours or so.

Should we break longer procedures into smaller ones?
  : Yes, it tends to clarify things.

But I don't like documenting.
  : Deal.

What if I give some E's and some F's?
  : Talk to me. (or send me email)

Lab
---

I'm not quite sure what you want in 3d
  : Force reload; there's a hint.

Why did you make us write 13 (epsilon of 2) different explanations in 3d?
  : Past experience suggests that students don't think carefully enough
    about the range of things they might test.  Past experience also
    suggests that if I only ask you to talk through it, you'll think
    you get it, but won't.  This one painful exercise is intended to
    help you think more carefully.

Debrief
-------

Observation: Although Sam suggested test suites, you can put checks directly 
in your code, and that way you'll see errors when you click run.

* Yes, that works, too.

Things Sam hopes you took away from today's class.

* Writing some simple tests is not much harder than just doing experiments,
    * You can write checks even without a test suite.
* On the other hand, writing a comprehensive test suite is hard.  You need
  to think about lots of things that can go wrong.
    * I still write test suites that miss some of the strange things
      in the code of the folks I am testing.
* That thinking is often helpful, as it lets you reflect more on what the
  procedure is supposed to do independent of the code you've written.
    * Consider writing tests before code.
    * You do so mentally, anyway.  "What should my procedure output on
      an input of 3?"

