Model View Controller With Observer View Flashcards

1
Q

Basic MVC roles

A

Model: Hold and manipulate data. Notifies view when changes occur.
View: Takes user input. Presents and visualizes data.
Controller: Receives user input. Converts input messages to the model.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

How does the observer pattern fit into MVC?

A

Model becomes observable. View observes model. Controller has listeners that listen to things in the view.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

View.

A

Implements observer interface.
update() called by Model

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Model.

A

Inherits from Observable class.
Has observer.
addObserver(Observer o)
model.addObserver(view) usually done after model and view are created. Lets the model notify the view with setChanged() and notifyObservers()

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

How can the view be updated?

A

After notification, the view either pulls data via accessors, or the model pushes data.

Note: If pull used, view must store model as an instance variable.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

How to push an update?

A

notifyObservers(Object arg)
Sends an object of our choice to all observers. In this case, the view doesn’t necessarily need access to the model.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Controller.

A

Intercepts events when buttons clicked, and tells model to change.
This indirectly causes observers like the view to be notified.
The view then gets the data one way or another.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q
A
How well did you know this?
1
Not at all
2
3
4
5
Perfectly