Architecture Flashcards

1
Q

Should you store any app data/state in your app components?

A

No. Because the process of destroying activities is largely out of the developer’s control and therefore they cannot rely on the app data/state in an activity to be saved after a config change or lifecycle change.

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

What is separation of concerns and how does it bode with Android architecture?

A

Separation of concerns is about separating code into individual classes that each address a separate concern. Therefore, UI components like Activities and Fragments should only be used to display and handle the UI & OS callbacks. UI components should be slim with as much business logic delegated to the viewModel as possible.

UI components can be destroyed by the OS or user at anytime so it’s best to separate our important data/state into viewModels.

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

What does it mean to ‘drive your UI from a model’ ?

A

Models are components responsible for handling the data for the app. Independent from the View objects, they are unaffected by lifecycle changes. Models should be used to supply the data to be displayed in the app components. By basing your app on model classes, the app is more testable and consistent.

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

What is a ViewModel?

A

A ViewModel provides the data for a specific UI component. It contains data-handling business logic to communicate with the model, e.g. a repo dependency that it uses to query a data source. The ViewModel knows nothing about UI components so is not affected by config changes like the activity rotating.

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

What is live data?

A

An observable data holder that allows other components to monitor changes to objects within the holder without creating rigid dependency paths between them. LiveData components also respect the lifecycle state and include logic to prevent objects leaking and excessive memory consumption.

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

What is MVVM?

A

Model, View, ViewModel is an architecture pattern that allows for the separation of the UI, business logic and back-end data repositories.

  • The ViewModel is responsible for exposing the data objects to the view.
  • The View is responsible for listening to changes from the ViewModel and displaying the data its given, it is also responsible for receiving user interaction and forwarding the handling to the ViewModel.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is the difference between MVVM and MVP?

A

The main difference is that the ViewModel in MVVM does not have a reference to the View where as the Presenter in MVP does have a reference.

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