While rather detailed definitions
of each component exist in other learning resources, for the purposes of this
introduction the following will suffice:
604 CHAPTER 24 ?– MVC AND THE Z END F RAMEWORK
??? The model: The model defines the rules for the world or the process an application
is intended to represent. You can think of it as the specification responsible for
both the application??™s data and its behavior. For instance, suppose you create
an application that serves as a conversion calculator, allowing users to convert
from pounds to kilograms, feet to miles, and Fahrenheit to Celsius, among other
units. The model is responsible for defining the formulas used to perform such
conversions, and when presented with a value and desired conversion scenario,
the model carries out the conversion and returns the result. Note that the model
is not responsible for formatting the data or presenting it to the user. This is
handled by the view.
??? The view: The view is responsible for formatting the data returned by the model
and presenting it to the user. It??™s possible for more than one view to utilize the same
model, depending on how the data should be presented. For instance, you might
offer two interfaces for the conversion application: a Web-based interface, and
one created using PHP-GTK (http://gtk.php.net/).
??? The controller: The controller is responsible for determining how the application
should respond based on events occurring within the application space
(typically user actions), done by coordinating with both the model and the
view to produce the appropriate response.
Pages:
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690