February 23, 2020
April 1, 2020
I review my code on GitHub every day
I review my code on Github every day.
Does it sound strange? I've heard such opinions.
Let me explain why I do this.
Whenever I create a pull request with my code, I'm the first person who does a code review.
I use GitHub to do code reviews. The UI/UX is very nice and I'm used to it. It's clear, simple and readable.
When I make changes in a code, they are located in different files and usually it's a lot of changes. I can display the diff of each file, see the commit, add TODO message, etc., but a long time ago, I realized that reviewing the code on GitHub is different than doing it in my code editor.
Code review mode #
GitHub allows me to look at the code from a different perspective. Instead of "coding mode", it's a "code review mode". I can see all my changes on a single page and it's a totally different way of reading the code.
Additional verification #
It happens that I forget about something and I see it during the code review. It's like an additional verification of what I want to do.
Comments for myself #
I can leave comments for myself. I know I can add
TODO comment to the code but on GitHub, it's something different. All contributors can see your comments and can interact with them. GitHub contains some kind of history, even when I do the suggested solution, the comment is still there.
Comments for others #
I can leave comments for others. It can be an explanation why it works like this (only when it's not necessary to add it to the code!) or a question to someone to take a closer look at the code or solution.
Reduce the code review time #
It can reduce the time when the pull request is in code review. Usually, people don't review the code immediately after the pull request is created. It's normal, no one wants to interrupt their current task. Let's say the first developer will do the code review in 8 hours. You need another 8 hours to review the comments and make requested changes. What if you could notice your omissions and improve the code before someone else does? It could reduce the code review time by 16 hours or more. It's a lot. You can deliver a new feature or a fix much faster and focus on the next tasks. Fewer tasks in progress are good for the entire team.
Notes to my code #
I can leave notes to my code. I often make draft pull requests. When I have to make a lot of changes in the code, I'm not waiting until I'm done to create a pull request. I make a pull request and push changes from time to time. It gives me the opportunity to do a code review and notice possible improvements earlier. I can fix something right away or leave a note and fix it later (during the next code review). It may happen that someone else notices something that will affect our further work. The sooner, the better, right?
Does it work? #
I've been doing code review this way for years and I'm not going to stop. It's a part of my coding flow.
I often see pull requests where someone accidentally added something or made a stupid mistake because they haven't noticed it in the code before. I often think that people don't look through their pull requests and this is strange to me. It can save a lot of time.
I encourage you to try it.