# Lecture 6 & HW 6: MVVM, Flows

**Textbook**: [Flows](/chapters/8.-flows.md), [MVVM Design Pattern](/chapters/7.-mvvm-design-pattern.md)

### **Lecture:** [**Google Slides**](https://docs.google.com/presentation/d/1xJIHNseHkKkkq5E3-YBPR8tjGgEpc4dGbKW8QWdbV2w/edit?usp=sharing)

### Final Feedback Form: \[TBD]

### Demo: To be posted after the in-class demo

### Quick Note:&#x20;

Y'all are awesome! Thank you for all of your hard work so far; we have a small enough class for me to know that each of you (yes, ALL) are very talented and bright Android Developers. I wish you all success and happiness ☺.

## **Homework: P6, DFA**

### Overview

For this assignment, you are going to create a single-page dog finding application, or DFA for short. Your app will contain information about different dog breeds, and you should allow the user to like and dislike these different breeds. To get this information, you will query the [Dog API V2](https://dogapi.dog/docs/api-v2).

### Starter code

The starter code for the assignment is [linked here](https://github.com/zachseidner1/a6-starter). I tried my best to organize the code base in a way that is somewhat close to what you will see in industry, so this assignment should give you practice with traversing code bases that are a bit more robust.&#x20;

Take some time **reading through all the files provided**. Especially the comments. I *promise you* that doing this up front will save you a lot of time in the long run. &#x20;

### Requirements

<figure><img src="/files/czrkBlNNSqqCNpzRLEBO" alt="" width="145"><figcaption></figcaption></figure>

The final result should look something like this. The specific requirements areas are as follows:

1. Scrolling to the bottom shows a loading spinner and then loads more dog breeds from the API. Note that the API is very fast, so when testing this functionality you may want to add a delay manually so you can see the loading spinner.
2. Use flows to allow the user to favorite dog breeds, and show the updates live. Using combine will make this easier!
3. Favoriting a dog breed *must* move it into the favorites category from the all breeds category, as in the dog breed may not be in the all breeds category once it is a favorite.&#x20;
4. In the infinite list, each dog breed card must display the breed name, male and female weights, whether it is hypoallergenic, and the description. Refer to the screenshot for an example.
5. You must use the MVVM design pattern best practices as we went over in class. This includes implementing `DogRepository` (model), `MainScreenViewModel` (view model), and `MainScreen` (view). Your `ViewModel` should expose a single `viewState` flow to the view (which has been defined for you).&#x20;

### How to get started

Again, the best way to start the assignment is by reading through and understanding the structure of the starter code. After that, an easier first task is specifying the UI and making some previewable composables to plan out how you'll display your information. From there, you can start implementing some of the code. You'll probably want to start by specifying `DogBreedApi`, and then work your way through MVVM, starting with the model and working downwards.&#x20;


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://android-course.cornellappdev.com/archive/fall-2024-course-material/lecture-7-networking.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
