undefined undefined
undefined

| by 張貼者: Joshua

0

MVC defines the separation of these three types of objects:

Model objects hold data and define the logic for manipulating that data. For example, a Student object in the Basic sample application is a model object. It holds data describing facts about the object like the first and last name of the student and has methods that can access and change this data (getters & setters). Model objects are not directly displayed. They often are reusable, distributed, persistent and portable to a variety of platforms.

View objects represent something visible in the user interface, for example a panel or button. In order to display the data from the model objects you might want to create your own custom objects, like a graph for example.
The Controller object acts as a Mediator between the Model and View objects. A Controller object communicates data back and forth between the Model objects and the View objects. For example a controller could mediate the first name of a student from a model object to a visible text field in the User Interface. A controller also performs all application specific tasks, such as processing user input or loading configuration data. There is usually one controller per application or window, in many applications the Controller is tightly coupled to the view. The Basic sample application shows this - every GUI class implements its own ActionListeners. Since controllers are application specific they usually do not find any reuse in other applications.  

0 意見:

張貼留言