Skip to content

iOS-Firebase #15

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .DS_Store
Binary file not shown.
64 changes: 64 additions & 0 deletions POST & PUT Comprehension Questions.rtf
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
{\rtf1\ansi\ansicpg1252\cocoartf1561\cocoasubrtf600
{\fonttbl\f0\fswiss\fcharset0 Helvetica;}
{\colortbl;\red255\green255\blue255;}
{\*\expandedcolortbl;;}
\margl1440\margr1440\vieww10800\viewh8400\viewkind0
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural\partightenfactor0

\f0\b\fs28 \cf0 POST and PUT Comprehension Questions
\fs24 \
[ Week 5 MBP ]\
\
What is a RESTful interface? When do you use it? What are its characteristics?\
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural\qr\partightenfactor0

\b0 \cf0 >> A RESTful interface is an architectural style that provides standards or guidelines between computer systems on the web. It allows for communication between the API and the device. REST uses HTTP requests to do different things with data on databases stored on a remote web service. The four resource methods of REST line up with CRUD methods - which are POST, GET, PUT, and DELETE. You use a RESTful interface anytime you want to retrieve, modify, or store resources on a remote web service. One characteristic of a RESTful interface, or a system that is compliant with RESTs guidelines, is that it keeps the user interface separate from the data storage. Another characteristic is that components can be managed or updated without affecting the system as a whole - this is called \'93statelessness.\'94
\b \
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural\partightenfactor0
\cf0 \
What is the difference between POST and PUT?\
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural\qr\partightenfactor0

\b0 \cf0 >> POST and PUT are both ways of giving data to an API. However, PUT is idempotent and POST is not. It doesn\'92t matter how many times you send the data, the API will place the info exactly where you told it to. So if you have already created the data, if you send the data again, it will update the existing resources. If you send the data multiple times using POST, the API will create a unique identifier and add it onto your base URL each time, putting the information at a newly created, unique URL for each time you POST the data.
\b \
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural\partightenfactor0
\cf0 \
How does the record ID work in Firebase? Why does it take two steps to save a record (first POST then PUT) app? Why does the FirebaseItem protocol even exist?\
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural\qr\partightenfactor0

\b0 \cf0 >> When you post to the main database, it will return a new record identifier, which allows you to have a URL that is specific to your method. It takes multiple steps to save a record because the first time we POST in order to get a record ID. This is the first time we receive a record ID. Then we add the record ID to our device and save it again (PUT), which then firebase will have the record ID with the data stored. The FirebaseItem protocol is needed so that we have a record ID field.
\b \
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural\partightenfactor0
\cf0 \
Explain what a generic type is and what advantages it offers.\
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural\qr\partightenfactor0

\b0 \cf0 >> A generic type is a feature in Swift that allows you to use any type - you don\'92t have to write code that is specific to one type, as long as the behavior is followed of what you conform your type variable to. We call the generic type with <angular brackets>.
\b \
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural\partightenfactor0
\cf0 \
What does a URLRequest do? When do you need one and when can you just use a URL?\
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural\qr\partightenfactor0

\b0 \cf0 >> URLRequest objects are the thing that we send to an API. Inside the request is our URL, telling the API where we want to access data, and the HTTP Method that we want to use at that URL. You can use just the URL without a URLRequest when you are doing one of the \'93reading\'94 actions - GET. If you are passing a method and a body, like a PUT/POST/DELETE, then you need to create a URL Request instance.
\b \
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural\partightenfactor0
\cf0 \
What is the role of a URL session? How does it work?\
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural\qr\partightenfactor0

\b0 \cf0 >> The role of a URLSession is to create the data task that will actually perform the request. It\'92s a very large class that does many things relating to interacting with network resources. After you encode, you create a data task that will perform the request by creating a dataTask constant and setting it to URLSession.shared.dataTask(with: request) and then a completion closure.
\b \
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural\partightenfactor0
\cf0 \
What are completion handlers? Why use completion handlers? What advantages do they provide?\
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural\qr\partightenfactor0

\b0 \cf0 >> Completion handlers take the place of delegation or notification because they allow you to send things that need to happen after a task is done. When something is running asynchronously, we can give it something to do as soon as it has finished its first task. A completion handler is the same concept as using protocols and delegates, but it\'92s much better because nothing is stored in multiple places - it stores no information other than the stuff that\'92s going to run once something is complete.
\b \
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural\partightenfactor0
\cf0 \
Explain at least three strategies that promote code reuse that we used in today\'92s project.\
\pard\tx720\tx1440\tx2160\tx2880\tx3600\tx4320\tx5040\tx5760\tx6480\tx7200\tx7920\tx8640\pardirnatural\partightenfactor0

\b0 \cf0 >> The firebase.swift file was completely reusable because nothing in our code was specific to the project. Using a model that stores Core Database Management Methods, like the add, count, delete, and update functions are reusable and nice to keep in our Model for this reason. And keeping things in separate files and organized also promotes code reuse by sectioning off tasks.}
Binary file not shown.
Loading