Finally, the fifth concept in using the MVC model is to call methods and objects as low as possible within the program that you have developed. The scope, like a construct, like any other construct, affects object life. If the method call is located close to the method that it is being called, then when you are done with it, for all practical purposes the called method ceases to exist. This is what frees the space for its variables within the data segment, or what frees the method location within the code segment. Insofar as you can do this and stay within the Model-View-Controller model, the calling method can be located near the called method.
The program may not be optimal if all methods are called at the high level in the controller; this affects how much code must stay in memory for the program to run.
The original list of tasks helps determine where their subtasks, and the associated methods, could be located in the program. If there are methods that are best used in the view, they would not be called in either the model or the controller. If the model needs information that is not GUI-specific, the program might contain more than one GUI component - one that communicates with screen/ keyboard devices, and another that manages the information from the external source.
If the methods stay within the view, then the lowest level for calls to those view methods is in the view, which affects how long those pieces of the view will exist in memory. This is the scope that affects the lifetime of the object; when the object ceases to exist, its space is eventually collected and given back to the operating system.
Select the "Next" link to view the summary.
|Previous Page||Page 8 of 9||Next Page|
|Copyright 2012 Yvonne V. Richardson|