02+-+Recursion - 9/13/2009 Abstraction EECS 280 Programming...

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

View Full Document Right Arrow Icon
9/13/2009 1 Procedural Abstraction and Recursion EECS 280 Programming and Introductory Data Structures Abstraction c Abstraction is a many-to-one mapping that reduces complexity and eliminates unnecessary details by providing only those details that matter. c 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 won’t care how it’s done, just that it multiplies. c There are two types of abstraction: c Procedural (the topic of the next three weeks) c Data Procedural Abstraction c Decomposing a program into functions is a way of providing “computational” abstractions. c Rather than simply being collections of commonly used code, functions provide a useful tool for implementing procedural abstraction within a program. Procedural Abstraction c For any function, there is a person who implements the function (the author) and a person who uses the function (the client). c 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. c 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! c 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 c Procedural abstractions, done properly, have two important properties: c Local: the implementation of an abstraction can be understood without examining any other abstraction implementation. c 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. c These properties only apply to implementations of abstractions, not the abstractions themselves. c It is CRITICALLY IMPORTANT to get the abstractions right before you start writing a bunch of code. c If you change the abstraction that is offered, the change is not local, nor is the new version substitutable. Procedural Abstraction c Unfortunately, abstraction limits the scope of change. c If you need to change what a procedural abstraction does, it can involve many different changes in the program. c 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.
Background image of page 1

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

View Full DocumentRight Arrow Icon
9/13/2009 2 Procedural Abstraction Function Definitions vs. Declarations c In small programs, often we just define functions before they are used. c
Background image of page 2
Image of page 3
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 10/26/2010 for the course EECS 280 taught by Professor Noble during the Fall '08 term at University of Michigan.

Page1 / 9

02+-+Recursion - 9/13/2009 Abstraction EECS 280 Programming...

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