L11: Structuring the system itself Flashcards

1
Q

MVC

A

Resembles a widely used architectural design pattern for GUI-based software systems:
- Model
- View
- Controller

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

Why use the MVC?

A
  • Make presentation independent of data
  • Allow to compose the presentation
  • Switch input/view modes or controllers even during runtime
  • Separate concerns/responsibilities (note: it defines what to separate, but not how)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Is the MVC connected to other design patterns?

A

MVC can incorporate many other design patterns:
- Command to pass information between the components
- Decorator to add elements to a view
- Facade to specify interfaces for the individual units
- Factory to specify and create default controllers
- Listeners to react to user interactions and changes
- Observer to update views on model changes
- Strategy to choose between different behaviors

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

What exactly is the model?

A

Internal representation of information/data:
- Manages data, logic, and rules
- Defines methods for data manipulation
- Manages requests on data state
- Implements business logic

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

What exactly is a view?

A

A user interface (I/O)
- Displays/represents information from the model
- Accepts input from the user

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

What exactly is the controller?

A

Unit that links model and view
- Translates inputs into commands for the model or view
- Today, often already integrated into standard libraries

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

Observer: What it does, what is it used for?

A

Define a one-to-many dependency between objects
- Ensure loose coupling
- When the one object (subject) changes, the many (observers) update automatically
- Notifying multiple dependent objects

Used for
- MVC/GUIs to update views
- Distributed event handling

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

Push method vs pull method

A

Push method:
- Subjects send necessary data on change
- Less independent (subjects require knowledge about what to send)

Pull method:
- Subjects notify observers that they change
- Observers pull data via subject’s getters
- More independent, but can be inefficient (easier to reuse, but they must identify what changed)

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

Being careful with the observer

A
  • Triggering the update (updating after each operation can cause overhead)
  • Managing object deletion (deleting observer/subject dependencies)
  • Ensuring consistent subject state before updating
  • Deciding what data to send/how to update (push versus pull)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly