Skip to content

Instantly share code, notes, and snippets.

@SteveOscar
Forked from rwarbelow/week-2-diagnostic.markdown
Last active December 11, 2015 16:47
Show Gist options
  • Save SteveOscar/8956adb1f38ba6e97a57 to your computer and use it in GitHub Desktop.
Save SteveOscar/8956adb1f38ba6e97a57 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.
    Browser sends a request to the server,, the server generates a response with a status code, repeat.

  2. Explain when each of these HTTP verbs would be used: GET, POST, PUT, DELETE.
    GET - used to request information
    POST - used to submit information
    PUT - used to update/edit data
    DELETE - used to remove/destroy data

  3. 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?
    POST - create PUT - update DELETE - destroy GET - retrieve single row GET - retreive all rows GET - lookup item by ID in preparation to update GET - a new item, first step of create

  4. Describe the function of models in the MVC structure.
    Models are ruby classes that handle the data retreival and calculations.

  5. Describe the function of views in the MVC structure.
    Views render pages for the user to view in the browser. They are 'dumb' in that they shouldn't have logic built-in, but rely on the models for data and controller for routes.

  6. Describe the function of controllers in the MVC structure.
    Controllers interact with the server and direct the views and models. Controllers do not interact with the database, but direct the models to.

  7. 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.
    Models tests test models, ie retreiving data from the db and converting that data to the desired format. Controller tests test the controller, ie for a given route, rendering the correct views and sending the correct response to the server. Feature tests test the views, ie using capybara to click on a link and verify the the expected redirect happens.

  8. What does ActiveRecord do? Why do we use ORMs like ActiveRecord?
    ActiveRecord stores data and, most importatnly (lots of programs can store data in tables, but) ActiveRecord uses relationship mapping between tables to allow for dynamic and flexible queries into the database. Depending on your priorities, you can use these abilities to build a db that is very flexible for a range of queries, or that effecietnly stores data by avoiding repitition.

@SteveOscar
Copy link
Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment