Skip to content

Instantly share code, notes, and snippets.

@GregoryArmstrong
Forked from rwarbelow/week-2-diagnostic.markdown
Last active December 11, 2015 16:43
Show Gist options
  • Save GregoryArmstrong/a3c45f0233e1eb8d33fd to your computer and use it in GitHub Desktop.
Save GregoryArmstrong/a3c45f0233e1eb8d33fd to your computer and use it in GitHub Desktop.
Week 2 Diagnostic
  1. Describe the request-response cycle. Start with the client making a request.
  • The client makes a request to the server. The server routes this request to the appropriate file or web page or other data, and sends it back to the client.
  1. Explain when each of these HTTP verbs would be used: GET, POST, PUT, DELETE.
  • GET: A request for data from the server.
  • POST: A submission of data to the server.
  • PUT: Sending an update to existing data on the server.
  • DELETE: Deleting data from the server.
  1. What are all of the necessary routes for full CRUD functionality in Sinatra app? Why do we need seven routes when there are only four CRUD actions?
  • GET = Handles retrieval of data from the server.
  • GET + form = Handles the beginning of creating data, by supplying the user with a form or field to enter the data
  • POST = Handles the end of creating data, by actually submitting the data to the server
  • GET + form = Handles the beginning of updating the data, by supplying the user with a form or field to enter or modify the data.
  • PUT = Handles the second part of updating the data, by actually submitting the data to the server.
  • DELETE = Handles elmination of data from the server.

Im a little fuzzy on these 7 routes, I feel as though they're correct but cant remember if the first part of both creating and updating are GET requests or not

  1. Describe the function of models in the MVC structure.
  • Models sit between the controller and the database, they're responsible for talking to the database.
  1. Describe the function of views in the MVC structure.
  • Views display the data retrieved from the database by the model, by way of the controller.
  1. Describe the function of controllers in the MVC structure.
  • Controllers simply route requests coming into the server to the appropriate model or view.
  1. What is the difference between model tests, feature tests, and controller tests? Give an example of functionality tested using a model test, functionality tested in a feature test, and functionality tested in a controller test.
  • Model Tests: You would want to test that the model handles the data that it has been given correctly. So, if it is given a payload, does it check the database for an identical payload and a registered client before entering that payload into the database.
  • Feature Tests: You would want to test that the views are working correctly. So, if there's a button linking to another view, does it correctly redirect the user when pressed?
  • Controller Tests: You would want to test that the controller correctly routes requests to the appropriate models for data creation, retrieval, modification or elimination. So if you were to send a post request to the server, does it send that request to the correct model for entry into the database?
  1. What does ActiveRecord do? Why do we use ORMs like ActiveRecord?
  • ActiveRecord supplies a way to easily interface with the database. It manages the creation and modification of tables and ties them to the models you're using in your app, while also allowing for easy retrieval and formatting of data from those tables.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment