Change Contents of the Bubble
Welcome to CS1315. Click on the python to add comments.

Looking for the book? They have it at the Engineer's Bookstore at 748 Marietta St NW. Here is there website: http://www.engrbookstore.com/ - Monica

Hotspots: Slides and CodeTA CornerComments?AnnouncementsFAQStatic Webspace
View this PageEdit this Page (locked)Uploads to this PageHistory of this PageHomeRecent ChangesSearchHelp Guide

Final Exam Review Fall 2003: Questions on Functions

Questions, comments, answers?

Back to Fall2003 Final Exam Review

1)Identify three reasons why someone should use multiple functions
rather than one big function in their programs.

2)What is procedural abstraction?

3)What is good modularity?

1) This is a repeat question from #4 under Questions on Functional Programming
2) Procedural abstraction is the process of breaking a problem up into smaller and smaller sub-problems that are more manageable. Your sub-functions each do one logical task while your main function tells all the sub-functions what to do.
3) Good modularity is when each function does one and only one task well.




2.Procedural abstraction:
1) Break the problem down into the smallest pieces that you can write down easily as a function.
2) Re-use as much as possible

3.Good Modularity means that the program or functions are fairly generic (Procedural Abstraction) so that you can use them again if a different but similar problem comes up. This way you will not need to rewrite code from scratch, you will only need to modify slightly different but existing code.

For instance, if you have a function that replaces every “a” in a string with a “b”, instead of coding the function so that it puts a “b” in every time, have the function take in two letters and then replace one of them with the other. This way in the future, if you need to replace a “K” with a “z”, you can reuse this program without modifying anything!




The two 3's need to be combined. Mark Guzdial

In other words, think about both reuse and "doing one and only one thing." Mark Guzdial


1. Multiple functions make the main function simpler and easier to read, easier to debug and test, and easier to use later for other functions.

IF the functions are well-designed, have good modularity. Mark Guzdial

2. Keeps on breaking one big complex function into smaller and simpler sub functions until the code/program for each sub function does only one logical task. Also, procedural abstraction is a strong tool to process different types of objects.

3. A modular program in which each function does one and only one task well and there are no duplicate task in the main function.

Pls. correct me if I am wrong



Link to this Page