CSC151.02 2016S, Class 55: Recap
================================

_Overview_

* Preliminaries.
    * Admin.
    * Upcoming Work.
    * Extra Credit.
    * Questions.
* A few project coding notes.
* The subject matter(s) of the course.
* More about the subject matter(s).
* Looking beyond the course.

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

### Admin

* Sit where you'd like (within this room)
* I will continue to bring you food (or food-like substances) until the
  end of the semester.
    * Today: Cookies.
* Don't forget to show up on Friday and fill out EOCEs!
* I expect to have tentative grades to you by some time Monday so that
  you can decide whether or not to take the final.  (Folks who got
  extensions on exam 4 may not get grades until Tuesday night.)

### Reminders

* Office hours next week 
    * Ask me about times.
* Review Sessions (go over sample exam)
    * Wednesday at 8pm in CS commons with Evan
    * Thursday at 10 am with SamR
    * Thursday at 8pm in CS commons with Kumar

### Upcoming Work:

* I have posted a [sample final examination](../assignments/sample-final.html) 
  to the assignments page.

### Extra Credit

* Send your reports to <rebelsky@grinnell.edu> with subject 
  "CSC 151 Extra Credit".  (Do not include the quotation marks.)
* Send opportunities to me before class with subject
  "CSC 151 EXTRA CREDIT OPPORTUNITY!"

#### Academic / Artistic

* Finals week's *Inside Grinnell*.  Tuesday, May 17 at noon in JRC 101.
  Food served.

#### Peer

* Humans of Grinnell College on Facebook.
* May 12, 8pm, Wall Theatre, THD-117 Presents The American Family,
  Scenes from 20th Century American Stage Realism.
* May 13, NC and company at Prairie Canary.
* May 14 improv workshops 1-3pm (short form), 4-6pm (long form), 
  Show 7:15-10:15 in Gardner lounge.
* Improv study break Monday at 9pm in Burling.
* Art Show Sunday, 12-1 pm, somewhere in Bucksbaum.  More info coming
  Friday.

#### Regular Peer 

* Social Dance Workshop Tuesdays 7:00-8:00 in Bucksbaum Dance Studio
* Pun club Saturdays at 4pm in Younker 
* Electronic Potpourri on KDIC Fridays at Five 
* Space Odyssey KDIC Fridays at Six
* Effective Altruism club, 2:30-3:30 Sundays in JRC 226.

#### Misc

### Questions

_What's up with the final?_

> It replaces your lowest exam grade, provided it is higher than your lowest
  exam grade.

_When is the final?_

> Thursday morning.  You can take the other section's on Wednesday afternoon.
  Here.

_Is there a review session for the final exam?_

> See above.

A few notes on project code
---------------------------

### Example 1

Original code

    (let ([petal-color
           (cond
             [(= (modulo n 10) 0)
              (color-name->irgb "blue")]
             [(= (modulo n 10) 1)
              (color-name->irgb "fuchsia")]
             [(= (modulo n 10) 2)
              (color-name->irgb "navy")]
             [(= (modulo n 10) 3)
              (color-name->irgb "red")]
             [(= (modulo n 10) 4)
              (color-name->irgb "indianred")]
             [(= (modulo n 10) 5)
              (color-name->irgb "lime")]
             [(= (modulo n 10) 6)
              (color-name->irgb "violet")]
             [(= (modulo n 10) 7)
             (color-name->irgb "orange")]
             [(= (modulo n 10) 8)
              (color-name->irgb "orchid")]
             [(= (modulo n 10) 9)
              (color-name->irgb "steelblue")])])
      ...)

Problems

* Very repetitious.  Seems like it has the same pattern and we should
  be able to do a better.
    * Solution: put everything in a vector and then get the appropriate
      element of the list.
* Don't recompute the same value over and over again.  (Fix with `let`)




Revised code

    (let ([petal-color
           (color-name->irgb (vector-ref (vector "blue" "fuchsia" "navy" "red"
                                                 "indianred" "lime" "violet"
                                                 "orange" "orchid" "steelblue")
                                         (modulo n 10)))])
      ...)

More revised code

    (let* ([petal-colors (vector "blue" "fuchsia" "navy" "red" "indianred" 
                                 "lime" "violet" "orange" "orchid" "steelblue")]
           [num-colors (vector-length petal-colors)]
           [petal-color 
            (color-name->irgb (vector-ref petal-colors (modulo n num-colors)))])
      ...)

### Example 2

Original code

    (define choose-image
      (lambda (num)
        (cond
          [(= 0 (mod num 53))
           (image-load "/home/student/Desktop/CSC151/1charlie.jpeg")]
          [(= 1 (mod num 53))
           (image-load "/home/student/Desktop/CSC151/2sam.jpeg")]
          [(= 2 (mod num 53))
           (image-load "/home/student/Desktop/CSC151/3ritika.jpeg")]
          [(= 3 (mod num 53))
           (image-load "/home/student/Desktop/CSC151/4jessica.jpeg")]
          ...)))

Problems

* Repetitious
    * Similar cases
    * Lots of image-load
* ...

Fixing

* Probably only compute the `mod` once, either by using a `let` or by
  using it in another expression.
* Maybe use a vector again.
* Pull out the prefix from the file name.
    * `(define directory "/home/student/Desktop/CSC151/")
    * `(image-load (string-append directory "2sam.jpg"))
* Naming the directory makes it easier to add images.
* Naming the directory makes it a little easier to read.
* Naming the directory makes it easier to change the directory.
* Rename the images so that they are just a number.

Improved code

    (define choose-image
      (lambda (num)
        (image-load (string-append
                     "/home/student/Desktop/CSC151/"
                     (number->string (+ 1 (mod num 53)))
                     ".jpg"))))


### Example 3

Original code

    (pred (irgb (- 31 (* 31 (/ col left)))
                (- 95 (* 95 (/ col left)))
                (- 167 (* 167 (/ col left)))) 
          (irgb (* 31 (/ (- col left) right))
                (* 95 (/ (- col left) right))
                (* 167 (/ (- col left) right))) 
          (irgb (* 31 (/ (abs (- row top)) top))
                (* 95 (/ (abs (- row top)) top))
                (* 167 (/ (abs (- row top)) top))) 
          (irgb (* 31 (/ (abs (- row top)) top))
                (* 95 (/ (abs (- row top)) top))
                (* 167 (/ (abs (- row top)) top))))

Revised code

    (let* ([rval 31]
           [gval 95]
           [bval 95]
           [mult1 (/ col left)]
           [mult2 (/ (- col left) right)]
           [mult3 (/ (abs (- row top)) top)]
           [color1 (irgb (- rval (* rval mult1))
                         (- gval (* gval mult1))
                         (- bval (* bval mult1)))]
           [color2 (irgb (* 31 mult2)
                         (* 95 mult2)
                         (* 167 mult2))]
           [color3 (irgb (* 31 mult3)
                         (* 95 mult3)
                         (* 167 mult3))])
      (pred color1 color2 color3 color3))

The subject matter(s) of the course
-----------------------------------

_I consider it important to end the semester with an overview of the
 primary learning goals and outcomes of the course, which we often
 call "the subject matter of the course."  I think of CSC 151 as having 
 a broad range of subject matters.  Here's the high-level overview._

* Problem Solving.  CSC 151 is about techniques for thinking about how
  to take a problem and develop a solution.
* Computer Science: Algorithms and Data Structures.  We use the approach
  of computer scientists, developing algorithms that solve generalized
  problems and arranging the data in certain ways.
* Scheme.  We make these issues concrete using the Scheme programming
  language.
* Program and Software Design.  And think more broadly about how to
  represent algorithms as programs.
* General Thinking Skills.  Every Grinnell class should develop skills
  beyond disciplinary skills.  We work on a wide variety.
* And Beyond.  I try to provide some moral perspective on the world,
  too.

Additional details
------------------

_With your partner, come up with three or so issues for each category.
 I've started with an example or two of each._

### Problem Solving

* Break a big problem up into smaller components.
* Strive for comprehensive solutions.
* Try different perspectives as you work on something.
    * Sometimes it's good to look at the big picture and get away from
      the details of the parentheses.
    * Yes!
* It doesn't hurt to try ... it might just work.
* Once it works, it can be useful to refine your solution.
* Think about potential errors/difficult cases, and make sure that 
  your solution works for those cases.
* When you are stuck, talk to other people
* Be clear when explaining!
* Think about different cases

### Computer Science: Algorithms and Data Structures

* Parts of an algorithm
    * Variables/parameters
    * Repetition
    * Subroutines
    * Conditionals
    * Pay attention to the order in which operations are done.
    * Basic values and operations
* Recursion.
    * Over lists
    * Over files
    * ...
* Break things up and use helper procedures.
* Pairs and pair structures (lists); a way to represent info.
* A lot of it is just logic that comes from normal problem solving.
* The simplest answer is often the best one.
* Sorting and searching

### Scheme

* `define`
* Numeric values and arithmetic operators
* `lambda`
* Order of evaluation in Scheme
    * Inside out
    * First to last
* higher-order procedures: section, map, compose,
* Strings and string operations

### Program and Software Design

* Document
* Write general procedures; take parameters!
* Understand what the program should do before you write it.
* Choose clear names; other people will have to read your code.
* Consider efficiency!
* DRY!  (Don't Repeat Yourself)
* Write out problems before solving them
* There's more than one way to solve the same problem; you should look
  at multiple solutions and think which is best 
* Even if your first approach doesn't work, that doesn't mean that a
  variant won't work.

### General Thinking Skills

* Working with others
* Thinking on your feet
* You can sometimes achieve a goal by looking at prior solutions to
  related goals.

### And Beyond

* Grinnellians are awesome and do awesome things, you should support them.
* How to handle enormous amounts of frustration.
* When you are stuck, talk to other people  Ask questions!
* Save early and often.
* Bring food!
* Be compasionate, understanding, and snarky
* Care!
* Be moderate in what you do.  Consent is necessary.
* Community is important.
* Real people do CS.
* There is more to life than CS.
* Be the driver sometimes!  But switch drivers!
* Laugh!
* Be accommodating/accessible.

### Other issues

* If you get stuck, take a break.
* "The ultimate outcome of any good liberal arts education is the ability
  to bullshit compelling and coherently on any topic."
* Get sleep, or you won't be able to phrase things coherently.
* Think about the implications of asking people things in a public forum.

Looking Beyond the Course
-------------------------

Where do you go from here?
