Skip to content

Instantly share code, notes, and snippets.

@jwperry
Forked from rwarbelow/week-2-diagnostic.markdown
Last active December 11, 2015 16:36
Show Gist options
  • Save jwperry/6f024a14ca0a4404d7b4 to your computer and use it in GitHub Desktop.
Save jwperry/6f024a14ca0a4404d7b4 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 sends a request with identifying information and the details of the request in the header and body. The server receives, interprets, and routes these requests, and returns a status code (200 being a successful default "OK" response) and/or content.
  2. Explain when each of these HTTP verbs would be used: GET, POST, PUT, DELETE.

    • GET: requesting content.
    • POST: submit content.
    • PUT: edit existing content.
    • DELETE: delete existing content.
  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?

    • CRUD - create, read, update, delete. Additional routes are needed because browsers don't respond directly to update and delete.
  4. Describe the function of models in the MVC structure.

    • Models typically contain most of the logic and data manipulation to be executed in your program.
  5. Describe the function of views in the MVC structure.

    • Views are html/css templates for displaying information to the user.
  6. Describe the function of controllers in the MVC structure.

    • Controllers route incoming requests and data correctly to the various models and views and return response codes to the client.
  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.

    • A model test is a test of logical functions performed by a particular class and set of methods. An example might be a model that takes in a variable from the params or url path of a client request, modifies that information, and then returns it in a differnet format.
    • A feature test is a test of the actual user experience in a browsing context. We have used Capybara for feature tests so far. A feature test might replicate what the user sees when clicking on a link, filling in a form, and submitting it. * A controller test covers controller functionality and might test that the correct response codes are being returned to the client. Controller testing requires actual requests to be hitting the server, so to test it properly, the server should be running and receiving requests via cURL, for example.
  8. What does ActiveRecord do? Why do we use ORMs like ActiveRecord?

    • ActiveRecord is a tool for database interaction. We use ActiveRecord so that it is easy to perform simple database functions without having to write comple raw SQL queries, for example. It also allows us to interact with the database in a Ruby context.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment