CSE Roadmap

Core tier · about 3 hours · 9 parts

Part 9 of 9 · 4 min read

Exercises

Easy

Easy 1: Name the resources (20 minutes)

A library app has books, members and loans. Write the URL for: the list of books, one book, the loans of one member, and one loan. Give the method and the meaning of each.

Done when: at least five lines, each with a method, a URL and a one-line meaning, and no verbs in the URLs.

Hint

Collections are plural nouns. The action lives in the method.

Easy 2: Safe or idempotent (20 minutes)

For each call say whether it is safe, idempotent, or neither: read a profile, set a name to "Asha", add one item to a cart, delete an order, send an email.

Done when: five rows, each with a yes or no for both properties and a reason.

Hint

Ask "what happens on the second call?" for the idempotent test.

Easy 3: Pick the status (20 minutes)

Choose a status code for each case: created a product, malformed input, no login, logged in but not allowed, missing product, database down.

Done when: six codes, each with the group name and a retry decision.

Hint

First digit first, then the detail.

Medium

Medium 1: Safe retry of a transfer (30 minutes)

A bank API has POST /transfers. Describe the server table, the steps for a first call, a retry after a lost reply, a retry during the work and a retry with a different body.

Done when: a table of columns and four step lists, each ending in the reply that the client sees.

Hint

Four cases: new key, same key done, same key working, same key with another body.

Medium 2: Offset or cursor (30 minutes)

A table of 5 million rows is read 20 at a time. Assume skipping a row costs 0.5 microseconds. Work out the cost of the page at offset 4,000,000 and compare it to a cursor call. Then show how 5 new rows at the front break the offset reading of page 3 at size 10.

Done when: a time in seconds for the offset page, a statement of the cursor cost, and the list of repeated rows.

Hint

Seconds = rows skipped × cost per row. Remember 1 microsecond is 0.000001 seconds.

Medium 3: Is this change safe (30 minutes)

Sort these changes into safe and breaking: add a field, rename a field, add an endpoint, change price from a number to a string, make limit required, remove an endpoint. Offer a safe way for each breaking one.

Done when: six rows with a verdict, and a plan for each breaking change.

Hint

Adding is safe. Removing, renaming and retyping are not.

Hard

Hard 1: Design a small API (45 minutes)

Design the API for a to-do app: lists, tasks, comments. Give every URL, method, status code and error body. Mark the calls that need an idempotency key and describe the paging of the task list.

Done when: a table of at least ten endpoints, one example error body, and a paragraph on paging.

Hint

Start from the nouns, then add the methods, then the exceptions.

Hard 2: REST against GraphQL for one screen (45 minutes)

A mobile order screen shows the order, 5 items, the shipping status and the seller. The round trip is 200 ms. Compute the time with REST calls in turn, with REST calls together, and with one GraphQL query. List two risks of the GraphQL choice.

Done when: three totals with the steps, and two risks with a guard for each.

Hint

In-turn REST is the sum of the round trips. Calls together take the longest single one.

Hard 3: Retire version 1 (50 minutes)

An API serves 4 million calls a day on v1, split 70 percent from an app version that 60 percent of users still run, and the rest from partners. Plan the end of v1: what to measure, what dates to announce, what to do with the partners, and when to switch off.

Done when: a plan with at least four dated steps, a metric for each step and a rule for the final switch-off.

Hint

Watch the count of calls per client over time, and give the partners a longer date.