Google Professional Cloud Developer Question 324
Select 3Google Cloud PlatformYou are developing a new version of a REST API for a cloud-based application deployed on Google Cloud. The application has thousands of active users who rely on the existing version of the API. To ensure backward compatibility while introducing new features, which of the following actions should you take?
- A
Add new fields to existing API responses and mark them as optional.
- B
Remove unused fields from the existing API responses to simplify the payload.
- C
Introduce a new API version and maintain the existing version for current users.
- D
Change the data type of a field in the existing API responses for improved performance.
- E
Deprecate older API endpoints and provide clear documentation on how to migrate to the new version.
Show answer and explanation
Correct answers: A, C, E
Explanation
Backward compatibility ensures that existing clients continue to function as expected when changes are made to an API. Adding optional fields, introducing new API versions, and providing clear deprecation plans with migration guidance are all strategies that help maintain backward compatibility. Removing fields or changing data types in existing APIs, however, can lead to breaking changes and should be avoided.
- A. Correct.
Adding new fields to existing API responses and marking them as optional ensures that existing clients continue to work without requiring changes, preserving backward compatibility.
- B. Incorrect.
Removing unused fields from existing API responses can break existing clients that may rely on those fields, even if they seem unused from a server perspective.
- C. Correct.
Introducing a new API version and maintaining the current version allows clients to migrate at their own pace, ensuring backward compatibility for existing users.
- D. Incorrect.
Changing the data type of a field in the existing API responses can break existing clients that expect the original data type, violating backward compatibility.
- E. Correct.
Deprecating older API endpoints while providing clear migration documentation ensures clients have time and resources to transition to the new version without immediate disruption.