The anatomy of a perfect pull request

How does a good pull request look like

Photo by Ash Edmonds on Unsplash

Why should I care?

  • A good pull request will be reviewed quickly;
  • It reduces bug introduction into codebase;
  • It facilitates new developers onboarding;
  • It does not block other developers;
  • It speeds up the code review process and, consequently the product development.

The size of the pull request

Classic, right?

But how can we determine the perfect pull request size?

With this number in mind, a good pull request should not have more than 250 lines of code changed

Source: small business programming

Break down large pull requests into smaller ones

Is understanding a big feature and breaking it into small pieces that make sense and can be merged into the codebase piece by piece without breaking anything.

Learning by doing

  • Create a model to save emails
  • Create a route to receive requests
  • Create a controller
  • Create a service to save it in the database (business logic)
  • Create a policy to handle access control
  • Create a subscribe component (frontend)
  • Create a button to call the subscribe component
  • Add the subscribe button in the interface

Single responsibility principle

Source: https://www.toptal.com/software/single-responsibility-principle

Pull requests that follow the SRP reduces the overhead caused by revising a code that attempts to solve several problems.

Title and description matter

What a good title and description looks like

The title of the PR should be self-explanatory

Make a useful description

  • Describe what was changed in the pull request.
  • Explain why this PR exists.
  • Make it clear how it does what it sets out to do. E.g., Does it change a column in the database? How is this being done? What happens to the old data?
  • Use screenshots to demonstrate what has changed.

Recap

Pull request size

Feature breaking

Single Responsibility Principle

Title

Description

--

--

Engineering Manager

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store