Chp 2 - Architecting Flutter Apps Flashcards

(30 cards)

1
Q

What is a common consequence of making poor app design decisions due to tight deadlines?

A

The app becomes harder to maintain long-term (technical debt)

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

List 4 examples of ‘short-term hacks’ in app development.

A
  1. Tailoring to specific devices
  2. Blindly copying and pasting code into files
  3. Placing all business logic in UI files.
  4. Hardcoding user-facing strings in code
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is the key benefit of good architecture regarding problem-solving?

A

It lets you benefit from already-solved problems

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

What is the key benefit of good architecture regarding teamwork?

A

Makes it easier for develpers to collaborate

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

What is the key benefit of good architecture regarding testability?

A

Makes code easier to test

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

What is the key benefit of good architecture regarding technical debt?

A

Saves time and reduces technical debt as you extend the app

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

Which core design principle separates the UI from the Data Layer?

A

Separation of concerns.

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

In the MVVM diagram, what component does the Activity or Fragment communicate with directly?

A

The ViewModel.

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

In the MVVM diagram, where does the Repository fetch data from?

A

The Model (Local DB) and Remote Data Source (Network).

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

What is the primary responsibility of the ViewModel?

A

To prepare data for the UI.

And mustn’t reference any UI Component

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

Why must a ViewModel never reference a UI component (like a Widget)?

A

To avoid memory leaks and decoupling issues.

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

How does a ViewModel handle configuration changes like screen rotation?

A

It survives the change and retains the data.

Survives as long as the scope is alive

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

What is the primary role of the Repository in app architecture?

A

To provide a single, clean API for accessing app data.

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

Is the Repository class part of the official Architecture Component libraries?

A

No, it is a recommended best practice.

Use 2 repository when there is 2 databases

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

What logic does a Repository typically handle regarding data sources?

A

Deciding whether to fetch new data from the network or use cached local data

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

What is LiveData?

A

A data holder class that is observable and lifecycle-aware.

17
Q

What happens when LiveData is observed and the data changes?

A

It notifies the observer (the UI) to update.

Is lifecycle aware

18
Q

Why is LiveData considered ‘lifecycle-aware’?

A

It respects the lifecycle of other components (like preventing updates when an app is stopped)

19
Q

What is ‘Floor’ in the context of Flutter architecture?

A

A SQL object mapping library (ORM) that generates SQLite code.

20
Q

What does an ‘Entity’ represent in the Floor library?

A

It defines the schema of a database table.

21
Q

What does a ‘DAO’ (Database Access Object) define in Floor?

A

It defines the read and write operations for the database.

22
Q

What does CRUD mean?

A
  1. C - Create
  2. R - Retrive
  3. U - Update
  4. D - Delete
23
Q

In a Floor Entity class, what does a member variable correspond to?

A

A column name in the database table.

24
Q

On which thread must database operations NOT run?

A

The main thread

25
How should the FloorDatabase typically be instantiated to manage resources?
As a singleton instance.
26
When passing data from the Database to the UI, what wrapper should be used in all layers?
LiveData.
27
What annotation is used to declare a class as a Floor Database?
@Database
28
What annotation is used to mark a class as a table definition in Floor?
@Entity
29
What can ViewModel represented as in Restaurant?
Waiter
30
What can Repository represented as in Restaurant?
Chef