CS 107: Midterm 2 Review and Study Questions

Fall 2012

The midterm is Tuesday, November 20 and is closed books and notes. You will be asked to answer conceptual questions  and sketch the blocks. You will be given two page of sample blocks, 1 and 2 The sample questions below are indicative of the types of questions you'll see.

  • Practice writing out answers to the sample questions.
  • Study with classmates and critique each others' answers.
  • Come to office hours and work with your instructor. Make an appointment if necessary.
  • Practice sketching blocks.
  • Read the specified chapters in the book
  • Use App Inventor to program out blocks and verify that your block sketches are valid.

App Architecture Revisited
    Chapter 14 App Architecture, Ch 16 Programming an App's Memory
    Ch 18-22: Conditionals, lists, iteration, procedures, databases

What does an app consist of, from a programmer's perspective (i.e., what are the elements you create and see in app inventor)? Use a diagram and text to explain, and be sure and talk about view, behavior, components, properties, event-handlers, events, responses, iteration, conditionals, procedures, variables, databases, and the web.

List data
  • Lists with fixed data  (Ch 8. Presidents Quiz)
  • Stepping through a list using an index (Ch 8. Presidents Quiz)
Consider an app which is a slideshow of images. Clicking next/previous allows the user to navigate through the pics.

a. What variables would you define for this app?

b. Show the blocks for a next button and for a previous button.

c. Show the blocks for this app if you want to the next button disabled when you reach the last image, and the prev button disabled when you reach the first. Alternatively, what if you wanted the slide show to "loop back" to the first item when next is clicked on the last item.
  • Foreach iteration to process each item in a list (ch 20)
What is iteration and how do you program it in App Inventor?

How does the concept of iteration modify the definition of "event-handler"?

Consider an app that lets the user click a button to send a text "hi there" to a list of three people. Sketch the blocks for this app.

Sketch the blocks for an app that, on a button click, adds up a list of numbers. The app should use a foreach loop and display the sum in a label. Here are some of the necessary blocks:

  • Iterating through a list using an index.

    sketch the blocks for a music recording app that lets you play back recorded musical notes, with a delay between notes.

          sketch the blocks for an app that sends a different love message to someone              every minute, where the love messages are in a list.

          Sketch the blocks for an app that speaks out the words in the list "colores", one every five seconds. Here are some of the necessary blocks:

          Could you use a foreach for the problems in this section? Why or why not?
  • Input forms and dynamically adding and removing items from a list (ch. 11 Broadcast Hub, Ch 19 Lists, Note-taking sample, music sample). Use of PhoneNumberPicker
Suppose you want a dynamic phone number list, i.e., the user can input the numbers in the list using a text box and a button.

a. Show the blocks for allowing the user to enter phone numbers into a list using a text box. Display the list after each new number is entered.

b. Show the blocks if a PhoneNumberPicker instead of a textbox are used to input the numbers.
  • Texting and dynamic lists
    Show the blocks for a "broadcast hub" app that lets users text "join" to the app and the app adds their phone number to its broadcast list.

Complexity with Conditionals

Study the broadcast hub app and its complex if-else blocks.  Write out the blocks for a broadcast hub which lets users 1) join the list by texting "join" and 2) broadcast to the list by texting again after joining, 3) sends a texter an invitation to join if they text something other than "join" when they are not in the list

For a quiz app, how can you check that the user's entry (e.g., in a text box) is equal to the correct answer irrespective of upper/lower case?

Persistent Data (Ch 22)
  • TinyDB
  • TinyWebDB
  • process for storing and retrieving data
a.Define persistent data

b. When is it appropriate to use TinyWebDB instead of TinyDB?

c. When you retrieve data from the database using TinyDB or TinyWebDB, you have to be careful about an important special case. What is it, and how can an app handle the special case?

d. The blocks for retrieving data are different with TinyWebDB compared to TinyDB. Why are they different and how are they different?

e. Show the blocks for making a dynamic phone list (one in which the user can add numbers to the list) persistent using TinyDB.

e. Show the blocks for making a dynamic phone list persistent using TinyWebDB.

Connecting an app to the Web (Ch 10, Ch. 13, Ch 24, and see notes on the Web component
  • APIs, web services
  • Yahoo Finance API
  • Building URLs for API requests
  • Using the Web Component and working with data returned from the web.
Many apps communicate with the web by sending URLs to web services (APIs) that send data back.

a. Describe, in general, the format of a URL request to a web service. Be sure and show/explain how parameters are specified.

b. Describe how a web service is different than a web site.

c. You built an app that communicated with the Yahoo Finance API. Describe the API-- what parameters are in the URL you send and what format is the data that the API returns. Describe how the App Inventor Web component is used and how it works.

d. This URL calls on the Yahoo Finance API:


How many parameters does this URL have and what are they?

e. Sketch the blocks for an app in which the user can enter any stock symbol to see the price of its stock.

Cloud Computing

What is cloud computing from a user's perspective? What cloud software have we used in this class?

How does Google's App Engine (or Amazon's Elastic Computing Cloud) facilitate cloud computing? How does it foster innovation?

Explain how we used App Engine to build a shared music app. What does App Engine have to do with TinyWebDB and how does a programmer connect the two?

Location and Maps

            What is latitude? longitude? What is at 0.0 latitude? What is at 0.0 longitude?

            Explain the following URL:

                Circle and label each part.
                What kind of page appears when such a URL is put into a browser.

            Describe how the LocationSensor component works. What are the key events
            and properties?

            Consider the following blocks. The goal is to show the user a map to USF,                 from their current location, on app startup:

             These blocks won't work. What are the problems?How could you fix it--
             sketch blocks for an app that meets the goal.

            Sketch blocks to show the user's current location at all times.

Procedures  (see p. 47 in text, and ch. 21)

a. How is an event-handler similar to a programmer-defined procedure? How are they different?
b. How does procedural abstraction help people solve complex problems and build complex apps?
c. There are built-in procedures (functions) and programmer-defined procedures. Explain what this means.
d. What is a parameter? What is the difference between an event parameter and a procedure parameter.
e. What are the advantages of defining a procedure for an app compared to copying and pasting snippets of code?
f. In a broadcast hub, you might allow both the app's user (administrator) and people texting in to broadcast messages. How would a procedure fit into this app? Show the blocks for this.