Exercise 12: Focusing on Design

This week, your task is to design - not implement - a program to analyze a spreadsheet and find the greatest apartment in Madison.

  • design.txt OR design.rtf OR design.doc - This may be completed in pairs if you wish.

The Program

The time has come to find an apartment for next year. Of course, you don't just want any apartment, you want THE BEST apartment. Visiting every single apartment complex in Madison to decide which one you like the best is unfeasible, so to some extent you will have to settle. Luckily, UW-Madison provides a service for finding housing for students, so with their help you should be able to find one with which you are happy. They've agreed provide you with a list of currently available apartments (in the form of a CSV file - a type of spreadsheet), and include with each one the following information:

  • Apartment Name (string)
  • Monthly Rent (float, dollars)
  • Estimated Monthly Utility Cost not Included in Rent (float, dollars)
  • Distance From the Computer Science Building (float, miles)
  • Size (integer, square feet)
  • Average landlord rating from past residents' reviews (float between 0 and 10)
  • Parking Availability (string, 'yes' or 'no')
  • Address (string)
  • Phone Number (string)

You have decided that there exist a certain set of strict requirements which must be met by any apartment for you to live in it: there is a maximum amount of money you are willing to spend on rent and utilities combined. There is a maximum distance away from the Computer Science at which you are willing to live. There is a minimum square footage. Finally, if you have a car, you will also need an apartment with parking.

To come up with a shortlist of potential apartments to actually visit, you will filter the long list from UW-Madison housing down to the ones which meet all of your strict requirements. After this, you will find the mean and standard deviation of average resident ratings, and remove any apartments which are not at least one standard deviation above the mean in average user rating. The remaining apartments are the ones you will visit.

Program Requirements

In high level terms, your program should:

  1. Prompt the user for the path to the CSV file, and read it in.
  2. Prompt the user for their preferences as described in the previous section.
  3. Filter the results according to preference.
    1. Remove all apartments which do not meet requirements.
    2. Find the average resident rating of the remaining apartments, remove all apartments not at least one standard deviation above the mean.
  4. Write the remaining apartments to a file called shortlist.csv, with the same format as the input file.

Design Requirements

Here are some guidelines for creating your document:

  • Be organized. Divide your document up into sections, one for each of the points above, and add other sections as needed.
  • Be detailed. There is a difference between "read the file in" (not specific enough!), "read the whole file in as a string", and "loop through the file" - be as detailed as possible when describing your design.
  • Be complete. Are you using any external modules? Which ones? What data structure will you use to represent an apartment? How will you store all the apartments in your program? What functions will you write? What are their parameters and return values?
  • And of course, check your spelling. This isn't an English class, but using proper grammar and spelling facilitate the clear communication of ideas.
  • You are welcome to include flow charts and other graphical representations of your design in your document!

There is no length requirement for this document, but if your design takes less than a page to describe, consider that you might not be going into enough detail.

Example Design

Last week, you were asked to translate a Caesar Cipher into English using brute force. There were a lot of different approaches students took! Here's an example of what we'd consider good, detailed design for one approach of the decoding process:


Using the two lists of frequencies from English and the message (where a=0, b=1, etc), multiply the elements together pairwise and put the sum in a new list. Repeat this process, shifting the index into the message frequencies by 1 each time through. Using the max() function, get the largest element of the new list, and find its index using a list function. That index will be how much we need to subtract from the numeric value of an encoded letter when we translate the message.

...and one that's really, well, not good:


Find the best rotation and use it to translate the message.

You don't need to test your design! We're looking for completeness (see "Be complete" in the previous section), not necessarily correctness. You can absolutely test and refine your design if you want to, though!

Submitting your files

As usual, you'll be handing in your lab work via the course Learn@UW dropboxes. Navigate to our 301 course page, and click the Dropbox link in the top navigation bar. You should see a dropbox for Program 12 - this is where you should hand in your design document.

Note that the dropbox will close at noon on 28 April, so be sure to submit your files before then.