23
Slide 1 CS3 Fall 2005 Lecture week 13: Introduction to the Big Project

Slide 1 CS3 Fall 2005 Lecture week 13: Introduction to the Big Project

  • View
    214

  • Download
    2

Embed Size (px)

Citation preview

Page 1: Slide 1 CS3 Fall 2005 Lecture week 13: Introduction to the Big Project

Slide 1

CS3 Fall 2005

Lecture week 13:

Introduction to the Big Project

Page 2: Slide 1 CS3 Fall 2005 Lecture week 13: Introduction to the Big Project

Slide 2

todo

• Fix dates in calendar here, and in project description in ucwise.

• Fix printing and sequencing slide

Page 3: Slide 1 CS3 Fall 2005 Lecture week 13: Introduction to the Big Project

Slide 3

Midterm #2

Any questions?

Page 4: Slide 1 CS3 Fall 2005 Lecture week 13: Introduction to the Big Project

Slide 4

Midterm #2

• Average:30.6

• Std. Dev.11.5

MT2 raw scores

50.0

47.5

45.0

42.5

40.0

37.5

35.0

32.5

30.0

27.5

25.0

22.5

20.0

17.5

15.0

12.5

10.0

7.5

5.0

20

10

0

Std. Dev = 11.46

Mean = 30.6

N = 148.00

Page 5: Slide 1 CS3 Fall 2005 Lecture week 13: Introduction to the Big Project

Slide 5

Midterm #2 – question 3

• (random) isn't something you have ever seen before, because:– This procedure creates a "side-effect"– It does more than just calculate a return-

value, it changes the state of Scheme so that the next call is different.

Page 6: Slide 1 CS3 Fall 2005 Lecture week 13: Introduction to the Big Project

Slide 6

;; check random runs (random val) n times, and returns the;; minimum and maximum values(define (check-random val n) (check-random-helper val n 0 0))

;; this version doesn't work! (define (check-random-helper val n cur-min cur-max) (if (<= n 0) (se cur-min cur-max) (check-random-helper val (- n 1) (if (< (random val) cur-min) (random val) cur-min) (if (> (random val) cur-max) (random val) cur-max) )))

Page 7: Slide 1 CS3 Fall 2005 Lecture week 13: Introduction to the Big Project

Slide 7

The Big Project

• Three possible projects:– Database– Blocks World– Yukon

• You can work in partnerships

• You will have three weeks to work on this (it is due on the last lab)

• Worth 15% of you final grade

Page 8: Slide 1 CS3 Fall 2005 Lecture week 13: Introduction to the Big Project

Slide 8

Project Check-offs

• There are 3 checkoffsYou need to do them on time in order to get credit for the project

1. Tell your TA which project you will do and who you will do it with.

2. Show your TA that you have accomplished something. S/he will comment.

3. Show that you have most of the work done: your TA will run your code.

Page 9: Slide 1 CS3 Fall 2005 Lecture week 13: Introduction to the Big Project

Slide 9

Nov 14 Extending sentences, words to lists

Nov 21 Lab: Finish lists

Start on the big project

Thanksgiving Break – Thur/Fri

Nov 28 Lecture: What is CS at Berkeley? (guests)

Lab: Big Project CHECKOFF #1 – Tue/Wed (beginning of

lab)

CHECKOFF #2 – Thur/Fri

Dec 5 Lecture: Summary, other languages

Lab: Finish up the Project

CHECKOFF #3 – Tue/Wed

Project Due on Thur/Fri

Page 10: Slide 1 CS3 Fall 2005 Lecture week 13: Introduction to the Big Project

Slide 10

Only two more lectures (after this one)…

What would you like to do?

– Hear about the CS major, and other courses…

– Do exam-type problems…– Review…

Page 11: Slide 1 CS3 Fall 2005 Lecture week 13: Introduction to the Big Project

Slide 11

Lets see the projects in action

Page 12: Slide 1 CS3 Fall 2005 Lecture week 13: Introduction to the Big Project

Slide 12

Programming Style

• Why does it matter– Bad style gets worse in large programs– Program maintenance: 6 months later, will

you know what your code does?– Code “literacy”: sharing code

• Remember, programming style will be considered in your project grade

Page 13: Slide 1 CS3 Fall 2005 Lecture week 13: Introduction to the Big Project

Slide 13

What issues of style matter?

• Keep procedures small !• Good names for procedures and parameters• Adequate comments

– Above and within procedures• Avoid nesting conditional statements• Put tests cases in a comment block• Indent to aid program comprehension

• Data abstraction – E.g. Don't do (bf (car '((a b) (c d)))

Page 14: Slide 1 CS3 Fall 2005 Lecture week 13: Introduction to the Big Project

Slide 14

Of course, other issues matter

• Reading specifications carefully

• Error checking inputs, where required

• Adequate testing

• Code reuse (most useful with the database project)

Page 15: Slide 1 CS3 Fall 2005 Lecture week 13: Introduction to the Big Project

Slide 15

Working in partnerships

• Highly recommended!– For those of you continuing with CS, you'll be

doing this for many future projects

• Won't be faster, necessarily– While you are less likely to get stuck, there

will be a lot of communication necessary

• A big benefit will be with testing

• Remember, only one grade is given…

Page 16: Slide 1 CS3 Fall 2005 Lecture week 13: Introduction to the Big Project

Slide 16

Functional Programming

• In CS3, we have focused on programming without side-effects.– All that can matter with a procedure is what it

returns– In other languages, you typically:

• Perform several actions in a sequence• Set the value of a variable – and it stays that way

– All of this is possible in Scheme.

Page 17: Slide 1 CS3 Fall 2005 Lecture week 13: Introduction to the Big Project

Slide 17

Printing, and sequencing

• With Blocks World and Yukon you will need to display information.– Simply Scheme chapter 20 is nice summary.– And, all the projects have file input /output

routines that you don't need to "understand", as well as user input routines.

Page 18: Slide 1 CS3 Fall 2005 Lecture week 13: Introduction to the Big Project

Slide 18

Data structures

• The format of data used in these projects in a central feature– A "data structure" (abstract data type) is a

specification of that format. Here, generally, lists of lists (of lists).

– Accessors and constructor allow for modularity: letting parts of a program work independently from other parts.

Page 19: Slide 1 CS3 Fall 2005 Lecture week 13: Introduction to the Big Project

Slide 19

Strings versus words

• One useful data structure is a string– Strings are surrounded by double quotes

when printed.– Strings are a native type in Scheme.

• In CS3, you used words (sometimes sentences) to present names and other output to the user.– In the real world, strings are used.

Page 20: Slide 1 CS3 Fall 2005 Lecture week 13: Introduction to the Big Project

Slide 20

Lists

• Lists are containers, like sentences where each element can be anything– Including, another list

((beatles 4) (beck 1) ((everly brothers) 2) … )

((california 55) (florida 23) ((new york) 45) )

(#f #t #t #f #f …)

Page 21: Slide 1 CS3 Fall 2005 Lecture week 13: Introduction to the Big Project

Slide 21

List constructors

• cons– Takes an element and a list– Returns a list with the element at the front, and the list

contents trailing

• append– Takes two lists– Returns a list with the element of each list put

together

• list– Takes any number of elements– Returns the list with those elements

Page 22: Slide 1 CS3 Fall 2005 Lecture week 13: Introduction to the Big Project

Slide 22

List selectors

• car– Like first

• cdr – Like butfirst

Page 23: Slide 1 CS3 Fall 2005 Lecture week 13: Introduction to the Big Project

Slide 23

Common list procedures

• Map = every• Filter = keep• Reduce = accumulate

• Null? = empty?

• Recursion is just the same!