CSC151.02 2016S, Class 13: Testing Your Procedures, Revisited
=============================================================

_Overview_

* Preliminaries.
    * Admin.
    * Upcoming Work.
    * Extra Credit.
    * Quiz Overview.
    * Exam Overview.
    * Questions.
* Pair programming.
* Key ideas in testing.
* Lab (as time permits).

Preliminaries
-------------

### Admin

* Continue partners!  
* Continue lab.
* Quiz 3 returned.
* Your graders noted when you didn't give documentation, but did not
  really take off.
* Lots of talking today.

### Reminders

* Office hours: MTWF 10-11, Tu 1-2.
    * Sign up at <http://rebelsky.youcanbook.me>.
    * Also feel free to stop by when my door is open.
    * Or to email me for an appointment.
* Tutor hours
    * Sunday, 3-5 p.m.
    * Sunday-Thursday, 7-10 p.m.
* Weekly review sessions:
    * Wednesday at 8pm in the CS Commons with Excellent Evan
    * Thursday at 10am in this room with Sarcastic SamR!
    * Thursday at 8pm in the CS Commons with Krazy Kumar

### Upcoming Work:

* Reading for Tuesday:
    * [Drawings as Values](../readings/drawings-late-reading.html)
* [Exam 1](../assignments/exam.01.html) 
    * Exam due Tuesday at 10:30 p.m.
    * [Epilogue](http://bit.ly/151-2016S-exam1epi) due Tuesday at 11:00 p.m.
    * Cover sheet due Wednesday at the start of class.
* Quiz Friday: Identify your classmates!
* Lab Writeup: Exercise _____
    * Send email titled __CSC 151 Lab Writeup 13 (Your Names)__
    * Do not include the underscores.
    * Send to <CSC151-02-grader@grinnell.edu>
    * Due before class on Wednesday.

### Extra Credit

* Send your reports to <rebelsky@grinnell.edu> with subject 
  "CSC 151 Extra Credit".
* Send opportunities to me before class with subject
  "CSC 151 EXTRA CREDIT OPPORTUNITY!"

#### Academic

* Convocation: Hilary Mason '00 on Data Science and Social Good.
  (11 a.m., Thursday, JRC 101)
* CS Extras: Hilary Mason on Fast Forward Labs.
  (4:30 p.m., Thursday, Science 3821)

#### Peer

* Swim Meet, Friday, Saturday, and Sunday, Osgood Pool.  (30 min.)
* Work the swim meet.  Contact JD for more info.

#### Regular Peer

* Social Dance Workshop Tuesdays 7:00-8:00 in Bucksbaum Dance Studio
* Pun club Saturdays at 4pm in Younker (max 2)
* Electronic Potpourri on KDIC Fridays at Five (TONIGHT)
* Space Odyssey KDIC Fridays at Six

### No Extra Credit, But Still Good

### Quiz 3

    (define f (section + <> 1)) ; add a value and 1
    (define g (section - 2 <>)) ; 2 minus input number; subtract from 2
    (define h (section remainder <> 4)) ; divides input by 4 and takes remainder

    ; Show your steps
    > (h (h 15))
    ; (h 15) is (remainder 15 4) is 3
    ; (h 3) is (remainder 3 4)

    ;;; Procedure:
    ;;;   irgb-only-green
    ;;; Parameters:
    ;;;   color, an integer-encoded RGB color
    ;;; Purpose:
    ;;;   Computes a new color with the same green component and
    ;;;   0's for the other components.
    ;;; Produces:
    ;;;   only-green, an integer-encoded RGB color
    ;;; Preconditions:
    ;;;   [No additional]
    ;;; Postconditions:
    ;;;   (irgb-green only-green) = (irgb-green color)
    ;;;   (irgb-red only-green) = 0
    ;;;   (irgb-blue only-green) = 0
    (define irgb-only-green
      (lambda (color)
        (irgb 0
              (irgb-green color)
              0)))

I did not want

    (define irgb-only-green
      (lambda (color)
        (irgb (* 0 (irgb-red color))
              (irgb-green color)
              (* 0 (irgb-blue color)))))

    (define irgb-only-green
      (lambda (color)
        (irgb (- (irgb-red color) 255)
              (irgb-green color)
              (- (irgb-blue color) 255))))

    (define irgb-only-green
      (lambda (color)
        (irgb (min 0 (irgb-red color))
              (irgb-green color)
              (min 0 (irgb-blue color)))))

    (define irgb-only-green
      (lambda (color)
        (irgb (- (irgb-red color) (irgb-red color))
              (irgb-green color)
              (- (irgb-blue color) (irgb-blue color)))))

These alternate solutions have more text and may be harder to read/understand.

They are also inefficient, they require the computer to do unnecessary work.

    (hsv->irgb (hsv (+ 360 (irgb->hue color))
                    (irgb->saturation color)
                    (irgb->value color)))

is a really long way to say `color`.

### Help on Exam 1

#### Problem 2

You may find that this *approximates* the result, and you can say so.

#### Problem 3

On HW 3, you probably wrote an expression that gave you 0 if the
red component was the smallest and 1 if the red component was not
the smallest.  You can use a similar idea here.

#### Problem 4a

We've done a lot of bounding.  Look back at it.  (E.g., look at problem
1 on the procedures lab.)

#### Problem 4b

You can use 191 instead of 192 as the upper bound.

You probably need a different technique for 4b than you used for 4a.

The key transforms: `irgb-add`, `irgb-subtract`, `irgb-average`,
`irgb-darker`, `irgb-lighter`, `irgb-redder`, `irgb-greener`,
`irgb-bluer`, and `irgb-complement`.

We've seen some instances in which we combine color transforms and
suddenly find that some values are no longer available.  For example,
are there a sequence of transforms that ensure that any component
below 16 becomes 16?

#### Problem 5

You should have seen a similar problem on a homework.

And I probably gave you too much of a hint above in telling you what
not to do.

Your examples should be things like

; > (image-show (color-palette (color-name->irgb "steelblue")))
; > 3
; ; Yup, looks right!

You do not have to cite the "Yup, looks right!"

#### Problem 6

The names are awful.  Think about the context in which they are used.

### Questions

_How do we turn in the exam?_

> Save the racket file as `000000.rkt`

> Email it to Sam as an attachment with a title of "CSC 151 Exam 1 (Your Name)"

> Take a blank sheet of paper.  Write your name, your number, and the
  academic honesty statements.  Sign and date whichever academic honesty
  statements you feel comfortable signing.  (And the There's More To Life
  Clause, if appropriate)

_Do we need to cite these hints or code from the exam?_

> No!

_Do we need to cite last Thursday's mentor session when Alex gave away
 inappropriate hints on the exam?_

> Yes!

_Will DrRacket crash and completely destroy the exam of at least one
 student in this class?_

> Yes.  I recommend that you mail yourself a copy regularly.

_If we are typing English and we go beyond 70 or so columns, should
 we hit the Return key and another semicolon?_

> Yes.

_What's a Carriage Return?_

> Go on to the next line.

_What is `#`_

> Octothorpe

_What's your philosophy on carriage returns?_

> They should clarify nesting.

> Not

        (+ 23
           (* 24 12) 12)

_How long will it take you to fix all the problems?_

> Heat death of the universe.

> If you notice that I've fixed something and you relied on a previous
  definition, just note so in your exam.


Pair programming
----------------

What are three key points from the reading?

* Two heads are better than one.  (In fact, evidence suggests that they
  are more than twice as good as one.)
* We typically have two roles in pair programming, a driver and a navigator.
    * The driver is at the keyboard, and often takes the lead in writing
      the program.
    * The navigator watches the driver and indicates when they may be
      going in a bad direction, or helps look at documentation, or asks
      questions or ...
    * The two talk a lot!
* Evidence also suggests that talking out loud to something about a problem
  you are having helps you solve the problem.  ("Tell it to the potted
  plant.")
* New partners help you learn new things!
* It's useful to talk to people who understand the topic (or who may have
  a better understanding) (or you think have a better understanding)
* You will start to learn expertise and can draw upon different
  expertises.
* Having responsibility to others is useful.
* Working with others can help you get an idea of how good you are.

Lab
---

Don't worry about it!
