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
(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?
- They are in a hurry.
- They start programming with no training or little training.
- They start with the intentions of building a very small project.
- They see the solution as one building unit and cannot visualize the separation of tasks into smaller components of the whole.
What happens when people start writing programs after they have design training?
- We hope the results will be better.
- A course in program design can help you as a programmer see the need to plan.
- Computer programming can be a very complex skill which is enhanced when it begins with a structured approach.
- Design training helps when you are building large interconnected applications.
- They start their programming assignments with sound development techniques. Developers tend to start their programming experience without an organized design approach plus they develop bad habits when they begin with no training.
- We know it is better to start with good techniques rather than have to change from bad techniques to good techniques. Y2K was an example of bad techniques that had to be changed. The cost was huge.
What might encourage the use of modules?
- Wanting to get a good start in programming style.
- Seeing the need, early on, how important it is to break tasks down into manageable pieces.
- To understand the benefits of working together in teams.
- Choosing to keep the program logic as simple as possible.
- Realizing that in the long run you can manage programming projects much better if they are developed using modular techniques.
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).
- Has a name to be called.
- Must be called to activate.
- Receives no values.
- Returns no values.
- Designed to only group instructions.
- Usually relies on global variables to work with values between module calls.
- This is not a data safe module.
- This is not a code safe module.
2) A formal procedure.
- Has a name to be called.
- Must be called to activate.
- Can receive multiple values.
- Can return multiple values.
- Designed to group instructions and share data.
- 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.
- This is a data safe module.
- This is not a code safe module.
3) A function.
- Has a name to be called.
- Must be called to activate.
- Can receive multiple values.
- Designed to return only one value.
- Designed to group instructions and share data.
- 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.
- The function call can be embedded in a mathematical formula.
- This is a data safe module.
- This is not a code safe module.
4) A method.
- First a method must be part of an OBJECT.
- Has a name to be called.
- Must be called to activate.
- Can receive multiple values.
- Designed to return only one value.
- Designed to group instructions and share data.
- 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.
- The method call can be embedded in a mathematical formula.
- This is a data safe module.
- This is a code safe module.
Raptor allows what module types?
- Raptor has Sub-Charts
- Raptor has Procedures
- Raptor does not have plain Functions
- Raptor does have Methods
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.
2) Demo Raptor using modules that are passed values to accomplish a specific task.
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.