How a Program can be like Alice in Wonderland
The White Rabbit put on his spectacles. "Where shall I begin, please your Majesty?" he asked.
"Begin at the beginning," the King said gravely, "and go on till you come to the end: then stop."
Without a guiding structure, how can anything be accomplished? If you don’t know where to start, you won’t know how to stop, and as elementary as it sounds, anything you do will end up as a mess without a basic, recognizable structure. The Elementary Program Design Structure Model is a framework for organizing a program into a logical beginning, middle, and end, much like the structure of a good movie. Why is this form necessary? When another programmer is reviewing the written code, this structure helps someone else to understand what is being done, because the program is following a well understood structure.
In the Setup of an Elementary Program Design Structure Model, a programmer will list the variables that are being used. This process is often referred to as the Declaration of Variables. In this section, it is good form to provide a significant amount of documentation in the form of programming comments that list the purpose of each variable. Also in the Setup, variables are Initialized, meaning that they are either zeroed out, or they are set to match the first record from the program input that will be used. This process ensures that, if the memory space had been used by another application that didn’t close out the memory properly, then there would be no unknown values that would create false values later in the application. As you would expect, the Setup section would only be done once, at the beginning of the application.
It is in the Process section of the application where the rubber meets the road. This is where the action of the application happens: Arithmetic Expressions, Logic Loops, the dynamic use of Arrays, and other Logical Expressions are used in this section. Once the foundation for the application is created in the program Setup, the variables that were defined are now manipulated and processed to resolve the central questions that the program is written to answer. Arithmetic expressions take the initialized data and apply algorithms to the data to get a resulting set of answers. Loops are used by the application to repeat a process or calculation a number of times, based on either a counter, or on a logical condition that creates a break in the Loop . Arrays are used in the Process section to create relational models of the data as it is being manipulated. Finally, Logical Expressions are used on resultant sets of data to determine if certain conditions have been met, such as the purpose of a Looping statement having been satisfied.
Once all of the data being manipulated in the Process section of the program has resulted in the answers being sought, then it is time to Wrap-Up the application. This process is as short and simple as the Setup section. It involves closing out any and all open file structures and releasing memory used by variable structures that have been called up by the application.
This process of organizing an application is almost painfully simple, but without it, the results would be a dreadful waste of time, just like a movie without a plot is mind-numbing. If you were going to make a home movie, you would create a Setup, where you introduce the characters and prepare to set things in motion by giving some background and giving the audience an idea of what they are getting ready to accomplish. The main body of your movie would involve the plot mechanics, where the plot would build, twist, turn, and finally deliver a climactic end to all that was building throughout the movie. Finally, just as a movie that goes black the moment the climax is over is not very satisfying (leaving the viewer to wonder what really happened), there needs to be a Wrap-up process to the movie, letting everyone know what eventually happens to the characters as a result of the crazy hijinks they experienced throughout the movie.
No comments:
Post a Comment