Monday, November 17, 2014

Today I learned: Code Quality depends on Reviews.

My Code will be better if I know, it will be reviewed. Here I said it.

If you compared my code I wrote today, for basically myself only, to the code I wrote some months ago for someone else, you will find great differences.

I don't think that I'm either much smarter or dumber than this summer, but if you saw my code, it would be a huge quality difference.

In one code nearly comments every line, what it does and why it does this and how the result of each statement will be used in future, what's the meaning of each variable and so forth, the other code was just hacked to get it to work. It has wonderful statements like

var parentElement = jQuery(this).parent().parent().parent().parent();

Code like this makes me cringe. It shows me, that I write horrible code, at times.

On the other hand, the code I wrote for someone else some months ago, I knew he would be dependent on understanding every detail of my code. And I knew, that he is no profound coder himself. So I made the code as simple and documenting as possible. No little, dirty hacks that are kinda clever, run 2% faster than normal implementations, but are a mess to debug. Everything was well explained and well documented. That was maybe the best code I have ever written, yet.

So, from now on, knowing that someone might read my code will help me to write better code.

One more reason for me, to write more open source code.

No comments:

Post a Comment