Photo by Charles on Unsplash

tl;dr

Review your own code after some time, or another task.


Some time ago I had an idea. What if I could do a code review for my own code? Of course It would be nonsense to do it just after code was written. But what about day or two later?

This idea appears probably in the time, when I was the only backend developer in my team (holidays or something…). In such situation creating too much code and making too much tasks could be worse, than doing nothing. Checking this code would take all of my teammates’ time, I’ll have to make some fixes to at least some of them. And even, when the rest of team will be present, they will do CRs of my code and what could I do then? Writing more code equals more CRs. Infinite loop 😉 In such situations slack time would be better option imho.

So, I thought about some ways to be more efficient in such conditions. And self code reviews appears.

The idea is simple: you write code, leave it to review and take another task. After finishing second task you come back to previous one. This context switch should allow you spot bugs and problems in it. It’s almost like other person look at it. It’s just not real other person, but other YOU. This next task changed you a little, changed your context, and when you come back to previous one you can threat it like someone’s else code.

I didn’t tested it. In work environment it would be quite difficult. But maybe not? I mean, you couldn’t really finish the task this way, other person should always look at you code. But I think, that you could check it yourself after some time, especially when CR take longer time. Maybe you’ll find something you didn’t think about? Some edge case appears? Or maybe tests didn’t cover all cases they should? Many times I was reviewing my code on GitHub and spot some places to improve, which I didn’t noticed before.

Anything increasing code quality is a good idea.

It could also be useful in your pet projects, when you don’t have anyone who could review you code and ideas. Self CR looks like something worth considering.