Monday, February 21, 2011

Little victories make up the big victory

Hi guys!

This will be my first blog post, not directly related to problems, code snippets and etc. I hope I'll write more like these in the future!

Code refactoring
In our daily work we frequently do refactoring. Sometimes we do some pieces of code refactoring, which we enjoy as we see the code becoming better and better and we feel happy and satisfied about that. But sometimes, we have to refactor something bigger, some spaghetti code with much legacy in it.
I've encountered such case recently. I struggled with it for few days and was highly disappointed by my performance.

Don't underestimate your tasks
I was frustrated as nothing was working. I've taken a wrong decision to cut-off the whole project I wanted to refactor and rewrite it. Thinking it will be an easy job to do, I didn't pay much attention, neither estimated accurately all the functionality I had to cover.

What happened was that it turned out to be tougher than expected. I had erased everything old, the whole solution couldn't be build. I couldn't even cover all the functionality, yet. This all happened for few days in which I've been feeling miserable. It was a dead-end thing and I haven't felt that way for some time. I was close to resigning from this task, as the deadline was coming closer and I was becoming more and more heartless. But admitting that you have failed with a task is something hard to live with (at least for me).

Don't lose hope, change directions
Then, I decided to change completely my plan I've firstly tried to follow. I commented most of the code I haven't refactored yet and struggled with building the other code. I've spent few hours on this, but finally built the project (Victory 1). I've started testing and bug fixing (Victory 2..N). It was such a relief. This whole system was alive and beating again!

Get motivated, get the work done
I saw a light in the dark - this whole thing might start working. Fully motivated, I continued iteratively refactoring the remaining part of the project. This took me some time, but in the end, everything was fine and I was satisfied with my work.

The moral of this story is, that when firstly I got my project built successfully this was actually my first victory - and it felt great. When I started testing, bug-fixing and improving my code I achieved my next victories. From this time on the job was easy to do.

Small victories, make up the big victory
Sometimes, you need to get to the small victories as fast as possible, to have the power and motivation to continue until you win the battle.

Learn from your mistakes and don't repeat them
Next time, I'll certainly pay more attention to the details, estimate them and try to iteratively do things, not taking them all at once.

Keep tuned, for more stories of failures and successes!

2 comments:

Veselin Kolev said...

Very nice post, man!
I have had such experience recently. I had to do a very complex task (at least for me :-)). I have been working on it more than 1.5 month - 4 times starting the thing from the scratch. Going to work was hard - at the end of these days I didn’t have the chance to complete even a single task. It was like a nightmare. But at the end - everything happened and the task was defeated.
You already said the truth - one should never give up! And just should obey the old and well known rule – just divide and conquer.

Good luck!

cypressx said...

Hi Vesko!

Thanks for the comment and congrats for completing your task:) I think, such experiences make us stronger and help us actually "make a difference" when working in a team.

I'll be glad to hear what your task was, what challenges have you met and how you handled them.

Yosif