1 / 14

Enhancing Programming Style and Grading

Improving code readability and maintenance by enforcing strict style guidelines. Tips on procedure naming, comments, avoiding nested statements, and organizing test cases. Midterm 2 coverage and advanced recursive concepts highlighted.

rross
Download Presentation

Enhancing Programming Style and Grading

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Programming Style and Grading • During grading, we are going to start becoming “more strict” on style issues • Starting with miniproject #3 • For the big project, style is important • Why? • Program maintenance: 6 months later, will you know what your code does? • Code “literacy”: sharing code

  2. What issues of style matter? • Avoid nesting conditional statements • Keep procedures small ! • Good names for procedures and parameters • Adequate comments • Above and within procedures • Put tests cases in a comment block • Indent to aid program comprehension

  3. Midterm 2 • Midterm 2: April 11th (next Monday). • In the lecture slot (5-6 pm, 105 North Gate) • Practice exam in reader (do this all at once) • Check announcements for more practice items and solutions. • Review session this Sunday, April 10th, 10-12. 430 Soda (Wozniak lounge). • Email problem requests to Fu, Elham, and Nate.

  4. What does midterm #2 cover? • Advanced recursion (accumulating, multiple arguments, etc.) • All of higher order functions • Those "big" homeworks (bowling, compress, and occurs-in) • Elections miniproject • Reading and programs: • Change making, • Difference between dates #3 (HOF), • tic-tac-toe • SS chapters 14, 15, 7, 8, 9, 10 • Everything before the first Midterm (although, this won't be the focus of a question

  5. make-decreasing • make-decreasing • Takes a sentence of numbers • Returns a sentence of numbers, having removed elements of the input that were not larger than all numbers to the right of them. (make-decreasing '(9 6 7 4 6 2 3 1))  (9 7 6 3 1) (make-decreasing '(3))  (3)

  6. When do you NEED lambda? • When you need the context (add-suffix '-is-great '(nate sam mary)) (nate-is-great sam-is-great mary-is-great) • When you need to make a function on the fly

  7. Procedures that make procedures • Generally, name procedures that create procedures "make-XXX" (make-bookends 'o)  #[closure arglist=(inner-wd) d7d0e0] ((make-bookends 'o) 'hi)  ohio ((make-bookends 'to) 'ron)  toronto (define tom-bookend (make-bookends 'tom)) (tom-bookends "")  tomtom

  8. Repeated (this is hard) > (repeated butfirst 3)  #[closure arglist=(x) d81d70] > ((repeated butfirst 3) '(a b c d e f g))  (d e f g) > ((repeated butlast 3) '(a b c d e f g))  (a b c d) • What does the function that (repeated butfirst 3) returns look like? • Write repeated

  9. Lists (after the midterm) • 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 …)

  10. 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 lists put together • List • Takes any number of elements • Returns the list with those elements

  11. List selectors • car • Like first • cdr • Like butfirst

  12. Common list procedures • Map = every • Filter = keep • Reduce = accumulate • Null? = empty? • Recursion is just the same!

More Related