Using Pull Requests to Improve Code Quality, Process, and Skills
Everyone makes mistakes. But mistakes in your code can be disastrous.
You have to reconcile this conundrum in order to build a successful web or mobile application.
One of the ways we keep human error from affecting deployed code at SmartLogic is through the simple method of pull requests. But pull requests do more than just help us catch mistakes: they also improve code quality in general, create a process that reduces stress for everyone, and build our application developers’ skills.
Throughout the years, we’ve found that not only are pull requests great for educating inexperienced people, but also that pull requests can help even the most experienced people learn. Often, in the pull request process, we’ll find out that the first way we developed something wasn’t the best way—thus code quality and our team’s shared knowledge increases beyond merely catching errors.
Read on for our breakdown of exactly how we use pull requests, complete with a handy example.
What is a pull request?
The way we do it, a pull request is a step in the software development process in which two people have to review and approve a new branch of code, typically consisting of one or more features or bug fixes, before it goes live. We use GitHub to make this easy, but you could likely work this into your process with a variety of tools.
Note that pull requests don’t have to be approved by exactly two people. You could have just one person approve a request, especially if your people are very experienced. That’s risky though—humans introduce mistakes, no matter how intelligent, detail-oriented, and experienced they are. Or, if you have a small team, you can have everyone on your team look at every single pull request. Find the right balance between efficiency and effectiveness for your team. Two people is that Goldilocks number for our team.
Another important consideration is that, for us, the client can see everything in GitHub. Meaning if we have a mistake in our code, the client will find out about it. But they'll also see that our system to catch mistakes works. Plus, they might learn something too.
Example:
Analysis:
Because of the pull request system, we stopped the page from going live without redirects. Additionally, more people on our team than just Ryan learned about Jekyll, the blog-aware static site generator we used for the site.
Conclusion:
When you are using agile and lean development methods to build your web or mobile application, you’re moving fast. Don’t let your software development process turn into a scene out of Speed. Building pull requests into your process means a stabler product, better code, and a team that’s continuously becoming smarter. If you have more than one developer on your product, pull requests are a no-brainer.
Does your team use pull requests? How do you ensure your code structure is top notch?
Check out our other articles on improving code quality:
Benchmark Ruby Code with R, rsruby and better-benchmark
__