Google Professional Cloud Developer Question 243
Single answerGoogle Cloud PlatformYou are developing a cloud-based application hosted on Google Kubernetes Engine (GKE). Your team collaborates on code using a Git-based source control system. Recently, there have been issues with multiple developers overwriting each other's changes during feature development. To address this, the team wants to implement a source control strategy that minimizes conflicts, ensures code quality, and integrates well with Google Cloud Build for CI/CD. What is the most appropriate source control strategy to adopt?
- A
Adopt a feature branch workflow and use pull requests for code reviews.
- B
Use a single shared development branch and commit directly to it.
- C
Implement a GitFlow workflow with specific branches for features, releases, and hotfixes.
- D
Use a trunk-based development approach where all changes are committed directly to the main branch.
Show answer and explanation
Correct answer: A
Explanation
The feature branch workflow is widely adopted in collaborative development teams as it allows developers to isolate their work, reducing the risk of conflicts. Using pull requests ensures that all changes are reviewed before integration, improving code quality. This workflow integrates seamlessly with Google Cloud Build, enabling automated testing and deployment as part of a CI/CD pipeline.
- A. Correct.
This is the correct answer. A feature branch workflow using pull requests allows developers to work on isolated branches, reducing conflicts. Pull requests provide an opportunity for code review, improving quality before merging changes. This approach integrates well with Google Cloud Build pipelines.
- B. Incorrect.
Using a single shared development branch can lead to frequent conflicts and overwriting of changes, especially in a collaborative environment. This approach lacks proper isolation for feature development and does not align well with best practices.
- C. Incorrect.
While GitFlow provides a structured branching model, it can be overly complex for teams working on modern cloud-based applications with frequent releases. It is less commonly used in Google Cloud environments that favor agility and simplicity.
- D. Incorrect.
Trunk-based development emphasizes fast integration, but committing directly to the main branch without proper safeguards like pull requests can lead to quality issues and conflicts, particularly for larger teams.