Gems Assignment

Video

Overview

The learning objectives for this assignment include the following.

Assignment folder

Create a directory named gems for the work you do for this assignment. This folder should contain your project code and a file README.md with notes. You should create this folder by cloning the gems repository into ~/405 and then deleting the .git folder within gems. Here are the commands to use.

cd ~/405
git clone https://github.com/csusbdt/gems.git
cd gems
rm -rf .git

Deleting the .git folder of the cloned gems project enables you to add the gems project code to your 405 repository.

Instructions

Study the gems project code to understand its function. Then, add a game screen with the following elements.

In couchDB, documents have revision string. When you update a document, you need to provide the current revision for the document you are updating. If the revision label you submit does not match the current revision string in the document, then CouchDB will not perform the update. In this case, it returns a result object that contains an attribute named error set to the string 'conflict'. This outcome occurs when two separate activities are trying to update the same document. If both of these activities obtain the version string for a document before either of them does an update, then a race condition is set up. The activity that executes the update first wins and the one that follows loses.

The gem application uses a simple strategy to resolve version conflicts that occur within document updates; it replaces any stale information in the user's interface and suggests that the user try again. To see how this works in the starter code for the gems application, open 2 different browsers and log in as user 'a' in both browsers. Buy a gem in one browser window and without refreshing the screen, try to buy a gem in the other browser window. The application updates the balance and gem count that is displayed and then asks the user to try again. As you extend the gems application, you should follow this pattern in each place where you update a document.

The README.md file in the project contains links to videos I made that explain the code.