Integrated and Collaborative Code Reviewing with Beanstalk

Originally published at: http://www.sitepoint.com/integrated-collaborative-code-reviewing-beanstalk/

This article was sponsored by Beanstalk. Thank you for supporting the sponsors that make SitePoint possible.

Do you perform code reviews in your team? It’s a useful technique to find bugs quickly and improve the quality of your code. Simply put, the process works like this: A developer will present a code example to their team or superiors, explain what they have written, and then receive feedback on how they could improve their code. That sounds easy, but in reality it can often be complicated, time-consuming and difficult to take on.

But today I’m going to talk about Beanstalk, a platform that can help to incorporate a code review process into your workflow, seamlessly making it a part of your coding habits.

Let’s first have a look at the common code review techniques used by development teams and highlight where there’s room for improvement, before moving on to talk about how Beanstalk can help.

Code Review Tools and Techniques

There are many benefits to reviewing code. Some of the more important ones are as follows:

  1. Bugs are identified and eliminated quickly.
  2. Team members always know what’s going on in the team.
  3. Reviewed code is more readable.
  4. Various optimisations may be done in code review, improving speed.

Let’s look at how code review is usually done. Often teams adopt one or more of the following techniques to review code:

  1. Pair programming : Two programmers sit at the same workstation and write code together, with one typing out the code and the other offering suggestions. While this seems like a good solution, it comes with some problems. For example, sometimes the senior member in a team can take over and do most of the work, defeating the purpose of the pair programming.
  2. Over the shoulder review : Usually a senior member looks over the developer’s shoulder while the latter explains what they’ve done. This is a quick, lightweight, ad hoc technique to perform code review, and that may work for small teams and projects. But as your project grows and your team expands, it’s just not possible to do over the shoulder reviews effectively.
  3. Email : Here the version control system sends code to reviewers via email. Usually this is done once a new commit is pushed to the repo. But things can quickly get messy with this technique. It requires you to keep track of multiple email chains to review code and suggest changes. Also, because it uses email it’s also difficult for other team members to know what is going on in the review.
  4. Code review meetings : The developer schedules a specific meeting dedicated to code review, with one or more reviewers reviewing the code. Issues are noted as a part of the process. Once the developer addresses those issues, the reviewers are notified. Of course, as with any meeting, scheduling and executing a code review can be tricky and time consuming.

So those are some existing ways of managing code review, which each have their problems. Let’s have a look at a better way.

Introducing Beanstalk

Beanstalk is a code hosting solution for development teams. Once you signup you can start creating repositories (repos) to host your code. In case you’re not aware, a “repo” is a storage space for your code. You can create a new repo by clicking on the “Create a repository” button in your Beanstalk dashboard. You can also create “branches” for fixing bugs or developing new features. We’ll discuss branches more later on.

Beanstalk promotes a three-step process to ship your code :

  1. Commit your code
  2. Review with the team via Code Review
  3. Deploy the final reviewed code

This is a useful way to release your code because code review is built in as an essential step in the development workflow. This means the code quality will be improved and bugs eliminated earlier. Developers can update their code based on a comment or issue, make their changes and then get feedback from reviewers.

Code Hosting and Committing

To start using Beanstalk’s code review tools you’ll first need to host your code. This process is very simple. If you don’t have a Beanstalk account yet, go ahead and create one.

Once you’ve created an account you can go to the “repositories” tab to create a new repository. You can create both git- and subversion-based repos, but we’ll be using git for this example. In case you are new to git, here’s an article to help you get up to speed.

Creating a repo is easy. Once you click on the “Create a repository” button you’ll be presented with a wizard. It’ll ask you to choose a title and repo type (git, subversion or another.) Once you fill in the details your repo will be ready.

Here’s a screenshot of the repo creation wizard.

I created a simple git repository to demonstrate the process. My repositories tab looks like this:

Once your repo is ready, you’ll get a URL (mine is https://sitepointdemo.git.beanstalkapp.com/simple-nodejs-repo.git). You can use this URL to push ‘commits’ into your repository.

Again, if you’re unfamiliar with source control, think of commits as snapshots of your code at a particular point in time. Once you’ve committed some changes, you can always revert back to that point in the future.

Now your new repo is ready you can start committing the changes. If you have your source code on your machine you can commit locally and push those to your Beanstalk repo.

Every repo has one or more ‘branches’. The normal workflow involves a master branch for production. Every feature and bug fix should start in a new branch and be submitted for code review once it’s completed. Once the review is complete and issues are resolved, the branch can be merged back into the master branch and its changes applied to the production code.

The ‘branches’ tab, shown in the screenshot below, lists different branches in your repo. You can also create new branches and delete existing ones.

For more information on working with branches check out this tutorial.

Now you have the basics in mind, let’s create our first code review.

Read more on SitePoint.

1 Like

This topic was automatically closed 91 days after the last reply. New replies are no longer allowed.