Are you proud of your code?

Are you proud of the code you produce? I’m pretty sure most professional developers would answer “Yes, of course!” (probably even angrily)

While it’s probably true that, in general, you are proud of your code, you might be lying to yourself.

Imagine this scenario. Your manager comes to you and says, tomorrow morning, you have to present the last task you completed to the rest of the company – you have to go through your code and talk about the reasons you had for doing it the way you did. You have until tomorrow to prepare for it, and you are allowed to update your code before you show it off.

Are you so satisfied with what you wrote that you wouldn’t change a thing?

Oh, you would? Why? You just angrily told me that you were proud of it, and now it isn’t even good enough to show off. Why is that?

“Well [insert random excuse here]. It doesn’t reflect the general level of my code.”

Ok, then. Let’s just skip that one and say that you can pick any of the last four tasks you did before that – under the same conditions: You are allowed to update the code before showing it off.

Would you be able to pick any of them and not change a thing?

If you’re able to pick one, then fine. But does that really mean that you are proud of what you produce? In general I mean. Shouldn’t you be able to pick any task you have done, and show it off proudly without a single change?

We should be able to take pride in our work. And that requires us to be critical and not accept anything that is not good enough for us to show off to others with a moments notice.

This is why code reviews are such a good practice. Of course there is the benefit that other people will point out where you can improve your work, but an even more important part of it, is that you are producing code that you know others will look at and give you feedback on, and that will force you to do things more thoroughly and better.

Why is it that if we know that someone will look at our code and give us feedback, we really want to do our best, but on a day to day basis, that is not the case. Even though other people will inevitably look at our code, and probably even have to work with it.

The only difference is that they will not formally give you feedback on it, they will just get annoyed with you when they find out you were the one who wrote it.

A software craftsman should in my opinion always do his best, even if he knows no one will ever see the code. He has a need to always do his best.

I’m not saying that everyone can be perfect all the time. I’m saying everyone should do their best all the time, and always try to find ways to do it better. There is nothing wrong with asking for help if you are stuck even though you did your best.

I try my best all the time, but I often get stuck anyway. When I do, I ask the guys that I (in my mind) have appointed my mentors, for help. Several times I have told them that they don’t have to help me, if I get annoying with all my questions. Every time I have said that, they have told me that they enjoy helping me, because it’s completely clear that I want to learn from them. It’s always fun to teach people that are eager to learn. And it’s always great to learn from people that enjoy sharing their knowledge.

Look for that kind of people in your company if you want to better yourself. It is extremely motivating to learn from people you look up to!

In time, you will get good enough to be genuinely proud of your code – I’m sure I will get there one day!

Mikkel Secher

Mikkel Secher