<< Chapter < Page Chapter >> Page >
A general explanation of specific task functions.

Prerequisite material

Critical to this module is the review of two Connexions modules:

  1. m_18861 – Titled: Modularization and C++ Program Layout
  2. m_19145 – Titled: Program Control Functions

You should review these materials before proceeding. If you are viewing this module on-line, links to these items are in the "Links" box to your right.

General concept

Program Control functions which might have similar identifier names usually perform slightly different tasks in one program to another. Looking at the organizational chart or hierarchy chart for two companies, both might have a vice president of production, but producing automobiles is different than producing ice cream. Similar but different. As you go down deeper into an organization you might find the job title of security guard. Notice that the security guard at the automobile plant and the security guard at the ice cream plant have exactly the same job. In fact, they are most likely interchangeable. Within programming when a task gets specific it might be useable in several programs. The calculation of leap year is a good example. Needed for the verification of dates, is there or is there not a 29 th of February for this year. Needed in thousands of programs.

Specific task functions

To create good Specific Task functions you need to do all communication needed via parameter passing. Thus all programs that will use the function will communicate in precisely the same way. In our leap year example, you would communicate into the function the year and the function would return the communication of true or false; meaning it is a leap year and there is a 29 th of February (true) or it is not a leap year (false).

The ability to modularize our program into specific task functions means that we can write the specific task function once making sure it works correctly, then reuse it over and over in many programs. As you can guess there is a balance. Most programs will have some program control functions and some specific task functions. The key to deciding if the function should be a specific task function is usually rooted in the uniqueness of the task so that it can be used in many programs. Specific task functions once created are usually placed into a user defined library then shared with others for use in many programs.

Definitions

user defined library
A file containing specific task functions created by individuals to be used in many programs.

Get Jobilize Job Search Mobile App in your pocket Now!

Get it on Google Play Download on the App Store Now




Source:  OpenStax, Programming fundamentals - a modular structured approach using c++. OpenStax CNX. Jan 10, 2013 Download for free at http://cnx.org/content/col10621/1.22
Google Play and the Google Play logo are trademarks of Google Inc.

Notification Switch

Would you like to follow the 'Programming fundamentals - a modular structured approach using c++' conversation and receive update notifications?

Ask