MOD4 - Writing Modular Programs

Check How Ready You Are

This section is usually from a Chapter 3 textbook content section. Take a look at the study helps and quiz to see if you need to spend some time here. If you are not an experienced programmer trained in a formal classroom setting you may find some items you should spend extra time studying. Once you feel you have mastered this section you should be ready for our topic of Modular Programs. Setting up good modular programs can be one of my favorite parts in program development. This is a great reason to use a tool like Raptor. 

Link: Chapter 3 Review

If you are really energetic you might want to try this quiz.

Link: Chapter 3 Quiz

Building Modular Programs

alternative accessible content

(after watching the intro video you might want to scroll to the bottom of this page to watch an example of program modules)

Why would people build programs that do not use modules?

What happens when people start writing programs after they have design training?

What might encourage the use of modules?

 

What is a modular program?

A modular program is a program that was developed grouping statements that perform similar (specific) tasks together. Each module in a program can contain a few lines of code or may include several lines of code depending on how broad you define the operation being performed.

What are four levels of modules we might tend to use?

1) A simple procedure (might be called a subchart).

  1. Has a name to be called.
  2. Must be called to activate.
  3. Receives no values.
  4. Returns no values.
  5. Designed to only group instructions.
  6. Usually relies on global variables to work with values between module calls.
  7. This is not a data safe module.
  8. This is not a code safe module.

2) A formal procedure.

  1. Has a name to be called.
  2. Must be called to activate.
  3. Can receive multiple values.
  4. Can return multiple values.
  5. Designed to group instructions and share data.
  6. Usually does not rely on global variables to work with values between module calls. The desire is to pass all values from and to the module.
  7. This is a data safe module.
  8. This is not a code safe module.

3) A function.

  1. Has a name to be called.
  2. Must be called to activate.
  3. Can receive multiple values.
  4. Designed to return only one value.
  5. Designed to group instructions and share data.
  6. Usually does not rely on global variables to work with values between module calls. The desire is to pass all values needed to the module and return only one value.
  7. The function call can be embedded in a mathematical formula.
  8. This is a data safe module.
  9. This is not a code safe module.

4) A method.

  1. First a method must be part of an OBJECT.
  2. Has a name to be called.
  3. Must be called to activate.
  4. Can receive multiple values.
  5. Designed to return only one value.
  6. Designed to group instructions and share data.
  7. Usually does not rely on global variables to work with values between module calls. The desire is to pass all values needed to the module and return only one value.
  8. The method call can be embedded in a mathematical formula.
  9. This is a data safe module.
  10. This is a code safe module.

Raptor allows what module types?

 

Now let's get into a few Raptor Examples

1) Demo Raptor using 3 modules to show how modules can operate with a global approach to variables.

alternative accessible content

2) Demo Raptor using modules that are passed values to accomplish a specific task.

alternative accessible content

 

Feedback for MOD4

I really appreciate feedback from people who use my site. Each time you complete a subject from the top it would be great if you could go to the last topic (Survey),complete the survey quiz and then send the email request. Thank you for your help.