Exercise Tuesday

Goal: Continue familiarizing yourselves with the MVC framework, paying special attention to the difference between GET and POST requests, testing controller logic, and creating multi-controller applications.

Warm Up

  • Why is it a good idea to use multiple controllers?
  • Where does a controller automatically look for its corresponding views?
  • What's the difference between a GET and POST request?
  • Describe an example of a GET request.
  • Describe an example of a POST request.


To Do List Continued

Work through the homework lessons and complete the to do list application.

Car Dealership

In section one, we built a car dealership application with our pairs. Today, either restart or build upon your existing car dealership to create an MVC web application that allows users to add new cars through a nicely-formatted web interface.

  • Make sure the Car class includes a constructor as well as getters, setters and private properties.

  • Think carefully about how to use static properties to post new cars to site. (In the To Do List example, we added Items to a list using the keyword this. For this exercise, we are dealing with Cars instead. How should we declare _instances in this case? What kind of data type should we use?


Following the guidelines below, create a website for a fictional shipping company that helps users calculate shipping estimates:

  • Create a Parcel class. It should contain a constructor, and getters and setters for each property. You should be able to create a new parcel and specify the dimensions and weight in the arguments.

  • Create a website where the user can submit a form with the dimensions and weight of a Parcel, and you can use the data in the form to instantiate a Parcel object and display its dimensions and weight.

  • When you call a method called Volume() on a Parcel instance, it should return the product of the sides.

  • When you call a CostToShip() method on your parcel, return a cost based on a formula you make up.

  • Display the cost to ship and the volume of a Parcel with its dimensions in your site.

  • Bonus: Add validation and make sure the Parcel object is not created if any of the form fields are blank. Display an error message instead. Also make sure your user can only enter numbers into the form.

Job Board

Create a section of a job posting board where a user can create one instance of a JobOpening class by submitting a form. It should include properties for a title, description, and contact info for the person posting the job.

If you're feeling fancy, make the contact info into an object with its own class declaration. Hint: A Contact object would include properties like a name, email and phoneNumber, and you would want to store it inside the JobOpening object.

Peer Code Review

  • Are Razor templates used correctly?
  • Are routes and route decorators clearly named? Is the code in each route easy to read and understand?
  • Is code separated into different controllers if necessary?
  • How well does the site work?
  • Are clear and complete instructions for setting up the project included in the README?

Lesson 28 of 38
Last updated more than 3 months ago.