Homework 7: As Memory Serves

Image Not Showing Possible Reasons
  • The image file may be corrupted
  • The server hosting the image is unavailable
  • The image path is incorrect
  • The image format is not supported
Learn More →

Due: Tuesday, November 23rd, 2021 at 9:00PM EST.

Learning Objectives

The goals of this assignment are to:

  • check your understanding of how different bits of code affect the connections between data at the level of memory
  • make sure you can write tests for functions that update data in memory
  • begin thinking about the relative roles of companies, policies, and consumers in managing the impact of data-oriented applications

Setup and Handin

Setup

  • Put import pytest at the top of your hw7_test.py file
  • Do not put your name anywhere in your homework files

Handin

You will be submitting two separate files to Gradescope under Homework 7:

  • tracing.txt, tracing.pdf, or tracing.png with your answers to the "Memory Tracing" section exercises
  • hw7_test.py, which will contain the testing function from the "Testing Under Mutation" section

In addition, the final SRC assignment for the course will be provided on this handout to help you plan your work as we near the end of the course. You have until the final project deadline to turn in that work, but you are welcome to finish it now if you prefer. This work will get submitted to Gradescope under "Final SRC".

Remember your resources!

Memory Tracing (No Programming)

You can submit your answers to this either written in a text file, drawn in some tool that saves to pdf, or as a photograph of work done on paper. Name your file tracing.txt, tracing.pdf, or tracing.png accordingly.

Here is part of a program for managing orders in an online store, offering our space travelers some of the creature comforts of home. There is a data structure for the Items for sale, as well as a catalog of all items. There is a data structure for Orders, which capture the name of a customer and a list of items that the customer wants to buy. There are also two versions of a function to update the price of an item in the catalog.

At the bottom of the file is a sequence of expressions to evaluate.

Task: Without running the program, predict what will be in each of k_order and m_order (items and their prices) after the four expressions evaluate (you won’t lose points for an inaccurate prediction – the point of the question is to help you calibrate your predictions against the memory contents.) Write down your answers.

Task: There are four comments in the code marked "Memory point". Show the contents of memory (known names and memory) at each of these four points, as we did in lecture on Wednesday 11/17. Write your answers to the first task (the answer predictions) in/on whichever file you are submitting with your memory diagrams.

You can write these in a text file or draw (and scan to PDF or png) pictures of memory drawn on paper. Just make the information for each memory point is clearly labeled so we see which memory layout goes with each point.

Testing Under Mutation

The online space store code contains two versions of a function called update_price. Assume we want a version of this function in which changes in price reflect in the catalog, but not in any orders that are still open.

Task: Write a list (in prose/your own words) of the changes that you do and do not expect to see after a price is updated. Put this in a comment at the top of your testing file. Python doesn't have block comments, so just use a multi-line string via #.)

Task: Use your list to write a test function test_update_price (using pytest assertions).

Your function will need to set up some data (catalogs, items, and orders), make one or more calls to update_price, then run a series of assertions to check the impacts of the update_price call on the data. The general form of your function should be as follows:

def test_update_price():
    "test whether update_price works"
    "SETUP"
    # create data here

    "PERFORM MODIFICATIONS"
    # call update_price

    "CHECK EFFECTS"
    # assertions go here

You are only writing a test function for this question. You are NOT writing code for update_price itself. The goal of this question is to see whether you are understanding how to test the behavior of a function that updates data.

Who is Responsible for Harms from Technology?

You can complete and submit this portion anytime between now and the final project due date in December. Use Gradescope assignment "Final SRC" to upload your answers on this question. Put all answers in a single text or PDF file.

For this final SRC assignment, you will read a couple of articles from the Wall Street Journal's Facebook Files series and a couple of articles about ways we as a society might respond to some of the recent impacts from technology. You'll also answer some questions based on those readings.

From the Facebook Files

Read these articles from the WSJ series:

Task: Choose one of the issues identified in the Facebook files (based either on one of the links we gave you or another one in the series) and answer the following questions:

  • List at least 5 different stakeholders who influence or are influenced by the issue you chose. For each stakeholder, briefly (couple of sentences) describe the influence, benefit, or harm that it has in relation to the issue you chose.
  • Now looking beyond the stakeholders, think about the broader context that enables the issue to arise. Specifically:
    • Identify 2 technical aspects that have amplified the impact of your chosen issue
    • Identify 2 societal aspects that have amplified the impact of your chosen issue
    • Identify 2 legal/policy aspects that have amplified the impact of your chosen issue

Task: In less than 200 words and using at least three supporting pieces of evidence, discuss the ongoing ability for people inside and outside technology companies to participate in shaping the digital space that is shaping them.

Moving Forward

Facebook claims that the solution to its problems lies in more artificial intelligence:

Others believe that we need to rethink the design of our current socially-oriented technologies.

Task: Read/watch all three pieces. Then, pick a substantive suggestion from one of them that would move us past a model of clicks and attention. Describe the suggestion and its underlying design goal (instead of clicks and attention). Then, identify multiple threats that the corresponding speaker/author didn't mention (in other words, what could go wrong?).

Theme Song

Space Traveling [Lo-Fi / Jazz Hop / Chill Mix] by The Jazz Hop Café.


Brown University CSCI 0111 (Fall 2021)
Do you have feedback? Fill out this form.