|Welcome to CS1315. Click on the python to add comments.|
|This page removed for FERPA compliance|
Final Exam Review Spring 2003: Questions on Functions
Questions, answers, comments?
(Back to Sp2003 Final Exam Review)
1. Functions are for managing complexity. They hide details so you can ignore them, make testing easier, and allow you to reuse trusted functions.
2. Procedural abstraction changes the program considerably. REMOVED are the steps: state the problem, break it into sub-problems, keep doing this until you know how to write a program to solve one small sub-problem. The goal is to have the main function "telling" all the subfunctions what to do.
3. Good modularity means that each function does one and only one task well.
|Procedural abstraction isn't for changing programs. When do you use it? What's "good modularity" good for? Why do you want it? (Other than it's "good"?) Mark Guzdial|
2. Procedural abstraction defines tasks to be performed, breaks tasks into smaller and smaller pieces until you reach an implementable size, defines the data to be manipulated, designs how functions interact, groups functions into components, and writes the code.
A simpler answer to number 2 might be this: the process of breaking code into the smallest most general pieces so it is reusable for the most varied applications. REMOVEDt me know if this is not correct.
|Both of the above REMOVED's are good – the important point is that procedural abstraction is a design process. It's how you get to a program, not how you change an existing program. Question: Does procedural abstraction lead to functions that are modular, i.e., have good modularity? Mark Guzdial|
1. Multiple functions make it easier to manage complexity. Multiple functions do three helpful things: hide details so that you can ignore them, make testing easier (since you can test each function separately), and make writing new programs easier since you can reuse old, trusted functions.
2. Procedural abstraction is method of approaching the problem of writing a new program with good modularity:
3. A program with good modularity is a program in which each function does one and only one task well. This means that the sub-functions each accomplish one piece of the task and do not duplicate each other. This is good to have since then each sub-function can be reused in other programs with similar steps.
- State the problem.
- Break the problem into sub-problems.
- Keep breaking the sub-problems into smaller problems until you know how to write that chunk.
- Goal: Main function is basically telling all the sub-functions what to do.
- • Each sub-function does one logical task.
|Nice, Lauren! But my earlier question still stands: Does procedural abstraction have anything to do with creating modular functions? Mark Guzdial|
Procedural abstraction actually creates modular functions I think. The final sub-function in procedural abstraction is a modular function because it performs only one task.
|The "final"? Meaning the bottom ones (also called the "leaf" ones)? Yes, I agree. Mark Guzdial|
Link to this Page