02+-+Recursion - 9/1/10 1 Procedural Abstraction and...

Info iconThis preview shows pages 1–3. 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
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: 9/1/10 1 Procedural Abstraction and Recursion EECS 280 Programming and Introductory Data Structures Abstraction Abstraction is a many-to-one mapping that reduces complexity and eliminates unnecessary details by providing only those details that matter. For example, there are several ways to implement a multiplication algorithm (table lookup, summing, etc..). Each looks quite different internally than the other, but they do the same thing. In general, a user wont care how its done, just that it multiplies. There are two types of abstraction: Procedural (the topic of the next three weeks) Data Procedural Abstraction Decomposing a program into functions is a way of providing computational abstractions. Rather than simply being collections of commonly used code, functions provide a useful tool for implementing procedural abstraction within a program. Procedural Abstraction For any function, there is a person who implements the function (the author) and a person who uses the function (the client). The author needs to think carefully about what the function is supposed to do, as well as how the function is going to do it. In contrast, the client only needs to consider the what , not the how . Since how is much more complicated, this is a Big Win for the client! In individual programming, you will often be the author and the client. Sometimes it is to your advantage to forget the details and only concentrate on higher levels of functionality. Procedural Abstraction Procedural abstractions, done properly, have two important properties: Local: the implementation of an abstraction can be understood without examining any other abstraction implementation. Substitutable: you can replace one (correct) implementation of an abstraction with another (correct) one, and no callers of that abstraction will need to be modified. These properties only apply to implementations of abstractions, not the abstractions themselves. It is CRITICALLY IMPORTANT to get the abstractions right before you start writing a bunch of code. If you change the abstraction that is offered, the change is not local, nor is the new version substitutable. Procedural Abstraction Unfortunately, abstraction limits the scope of change. If you need to change what a procedural abstraction does, it can involve many different changes in the program. However, if a change can be limited to replacing the implementation of an abstraction with a substitutable implementation, then you are guaranteed that no other part of the project needs to change. This is vital for projects that involve many programmers. 9/1/10 2 Procedural Abstraction Function Definitions vs. Declarations In small programs, often we just define functions before they are used....
View Full Document

This note was uploaded on 02/14/2012 for the course EECS 280 taught by Professor Noble during the Winter '08 term at University of Michigan.

Page1 / 9

02+-+Recursion - 9/1/10 1 Procedural Abstraction and...

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

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