Procedural Decomposition Assignment
Consider this program.
- Identify what is good about the program, what is done right.
- Identify what is wrong with the program, needs improvement.
Hopefully one of the items you identified above is there is a lot of redundancy.
On paper, identify the redundancy by answering the following:
- How many sections of repeated code are there?
- For each group of repeated code, identify the lines numbers of the repeated blocks.
-
We will be creating static methods to eliminate the redundance and clarify the structure of the program. Come up with a method name for each group of repeated code.
Remember, when you create a method you are defining a new action word (verb) for the Java language. Make sure you follow the proper method naming protocols!
- Write a proper Java static method for each of the repeated groups. Write good code, with proper curly brace alignment and indentation!
- Rewrite the 3 worker methods (drawDiamond, drawX, and drawRocket) using these newly created methods.
- Now, write the code in jGrasp and get it running!
- Once you have it running and producing the correct output, play with it. Combine the shape methods to create new pictures.
- Create new shape methods to create new pictures.
Be prepared to show and discuss what you've found!