section02 - Section Notes 2 CS51—Spring, 2009 Week of...

Info iconThis preview shows pages 1–4. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Section Notes 2 CS51—Spring, 2009 Week of February 8, 2009 Outline 1. Review 2. Abstraction 3. Trees 4. Reading and writing Scheme 5. Style 6. Answers 1 Review By now you should be familiar with the following concepts: • The Scheme evaluation rule and exceptions to it (special forms) • Side effects, including variable assignment, and the fact that we are programming without them • How to write a simple recursive function 2 Abstraction We hope that you will take a great deal away from CS51. However, abstraction is a central concept that stands out among all the others we will study this semester. 1 2 An abstraction in programming is a tool used to generalize code to make it more broadly applicable. One of the first forms of abstraction that you encountered as programmers was the “function”. A function parameterizes a section of code so that the same code can be applied to different inputs. While a parame- terized function is abstract in that it can be applied to different arguments, it is also abstract in that the details of the function’s implementation are hidden. As an example, if you took CS50, you will remember the Spell Checker problem set where you were asked to design and implement functions that would be used to check for spelling errors in an input file. Each student’s “check” function conformed to the same contract - take a string as an argument and return true if the word appeared in the dictionary file and false otherwise. The competition to produce the fastest implementation of these functions was possible because the function interface effectively abstracted away the particular implementation. Why do we care about abstraction? The simple answer is that it makes our jobs as programmers easier. It’s much harder to reason about complex systems than about individual units of programs that have been broken down into pieces with well-defined boundaries. Functional interfaces and contracts are one such boundary, but they are not the only kind that come up in software design. 2.1 Data Abstraction Besides functional or control abstraction, as described above, CS51 introduces data abstraction . Data ab- straction separates the conceptual properties of a datatype from its implementation. An example of an Abstract DataType or ADT is a Set . Conceptually, a Set is a collection of unique values and nothing more. This abstract definition provides no guidance as to how a Set should be represented on a computer. In Scheme, one might consider storing the contents of a given Set in a list, however this is certainly not the only possible concrete implementation of this type, and is probably a rather poor choice of representation.only possible concrete implementation of this type, and is probably a rather poor choice of representation....
View Full Document

This note was uploaded on 07/26/2009 for the course COMPUTERSC CS51 taught by Professor Gregmorrisett during the Spring '09 term at Harvard.

Page1 / 7

section02 - Section Notes 2 CS51—Spring, 2009 Week of...

This preview shows document pages 1 - 4. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online