A component diagram has been used to describe MVC pattern.
Download MVC Example
- Model – This component contains one or more classes and interfaces that are responsible for maintaining the data model. The state of the model is kept in attributes and the implementation of methods. To be able to notify view components of any change in the model, the model keeps a reference to each registered view (there can be more than one at the same time). When a change occurs, every view component that has registered should be notified.
- View – The classes and interfaces of the view provide a representation of the data in the model component. The view may consist of visual GUI components, but is not required to. A view must be registered with the model to be notified of changes to the model data. When a notification of such a change is received, the view component is responsible for determining if and how to represent this change. The view component also keeps a reference to the model to retrieve data from the model, but it can only retrieve information, not change it. The view can also be used to render the controller, but requests for change are always forwarded to a controller component; so the view needs to keep a reference to one or more controllers.
But not all views require a controller, some view provide a visual presentation of data, but don't support any changes to model from that view.
- Controller – This component manages changes to the model. It keeps a reference to the model component who is responsible for carrying out the change, whereas the controller calls one or more update methods. The requests for change may come from a view component.
Download MVC Example
- Model – This component contains one or more classes and interfaces that are responsible for maintaining the data model. The state of the model is kept in attributes and the implementation of methods. To be able to notify view components of any change in the model, the model keeps a reference to each registered view (there can be more than one at the same time). When a change occurs, every view component that has registered should be notified.
- View – The classes and interfaces of the view provide a representation of the data in the model component. The view may consist of visual GUI components, but is not required to. A view must be registered with the model to be notified of changes to the model data. When a notification of such a change is received, the view component is responsible for determining if and how to represent this change. The view component also keeps a reference to the model to retrieve data from the model, but it can only retrieve information, not change it. The view can also be used to render the controller, but requests for change are always forwarded to a controller component; so the view needs to keep a reference to one or more controllers.
But not all views require a controller, some view provide a visual presentation of data, but don't support any changes to model from that view.
- Controller – This component manages changes to the model. It keeps a reference to the model component who is responsible for carrying out the change, whereas the controller calls one or more update methods. The requests for change may come from a view component.
Comments
Post a Comment