ud009 ยป

Using ShoppingList++ Github Repository

What is the ShoppingList++ Github Repository?

The ShoppingList++ Github repository is an online code repository that shows every step you, as the developer, would take, to make the final ShoppingList++ app. It employs branches not for merging, but instead to mark different state of the code.


There are four types of branches.

  1. Start Code: At the start of every lesson (called versions in the class) is the version start code. This code contains new skeleton code for features you'll implement in the lesson.
  2. Quizzes: Each normal code step contains a quiz and a solution (as seen above). The quiz code steps include TODO comments, which are meant to help you complete the code step.
  3. Solutions: Each normal code step also contains a matching solution (as seen above). The solution code includes all the code necessary to complete the quiz.
  4. On Your Own: At the end of each lesson are On Your Own exercises. The branches associated with these are OYO

The branches are named with the lesson number and the checkpoint number. 4.02 would therefore be the second checkpoint in Lesson 4.

Below is a very brief explanation of the git commands you can use to navigate the repository and do quizzes. If you are completely unfamiliar with version control or want a more in-depth introduction, consider taking Udacity's Git and Github course.

Completing Quizzes

This assumes you've already downloaded the codebase and you're following along with the repository the "fast way" (i.e., you're just doing each quiz and not building the entire app). The instructions for downloading the code are here if you do not have it yet.

  1. (Optional) Commit your changes from the previous quiz. When you make changes to solve a quiz and then move on to the next quiz, these changes will be overwritten. If you'd like to save what you've done in a commit, you can type the following in a terminal:

    git add .
    git commit -m "My changes for <lesson and quiz number>"

    If you would prefer to just delete the changes you've made, you can type the following (NOTE This CANNOT be undone)

     git reset --hard HEAD 
  2. Checkout the correct quiz branch checkpoint. When you're ready to work on a new quiz, find out what the quiz checkpoint is. In the instructor notes or the code spec, it's listed next to the word Code Step.

    Where to find the codestep

    Once you have the code step, you can copy this text and in a terminal type the following to check out the code step. It should say quiz at the end. (Note that git tab completes, so you can also just start typing the number and press tab to complete):

     git checkout 2.03_edit_shopping_list_name-quiz 
  3. Do the quiz. Now if you open your ShoppingList++ app in Android Studio, the code will be a at a state before the quiz has been solved, with TODOs to guide you through what to do. Finish the code step. Make sure to check that your solution works according to what's in the spec.

  4. Compare your solution with the course's solution If you look at the Instructor Notes or the Spec solution, you should see a link to the Code Diff. Where to find the Code Diff

If you're doing things the thorough way (building the entire app alongside me), you can simply use the github pages as guidelines for where you should edit your code for each quiz. You can then compare your solution with our solution using the diffs.

Reading A Code Diff

Look at the top of the picture, you can see the two branches that are being compared. The left-side shows 1.01_connect_firebase_to_your_app-quiz and the right side shows 1.02_connect_firebase_to_your_app-solution.

Look at the lines highlighted in red and green. A red highlighted line was one that was deleted from the first branch in the second branch. A green highlighted line was one that was added to the first branch in the second branch.

Highlighted red and green lines

You can see here that the TODO comments were replaced by other comments, describing the solution code.