A13Advanced

Backward Compatibility Thinking

30 minWhen modifying APIs/data structures

Format: Given a change requirement, determine whether it's backward compatible.

Scenario: Your API returns user data in the current format:

{
  "name": "Alice",
  "email": "alice@example.com"
}

Change Requirement: You need to split the name into first name and last name. Which of the following approaches is backward compatible?

Option A:

{
  "first_name": "Alice",
  "last_name": "Smith",
  "email": "alice@example.com"
}

Option B:

{
  "name": "Alice Smith",
  "first_name": "Alice",
  "last_name": "Smith",
  "email": "alice@example.com"
}

Answer Guide: Option B is backward compatible — old fields are preserved, new fields are added. Clients using the old version won't break.

More Exercises:

  1. Adding a new column to a database table — backward compatible?
  2. Deleting a column from a database table — backward compatible?
  3. Adding a new optional parameter to an API — backward compatible?
  4. Removing a return field from an API — backward compatible?
  5. Changing an API's URL path — backward compatible?

My Notes