[ Content | View menu ]

Ask Questions

Mark Mzyk | January 25, 2008

Today at work the issue of refactoring some code came up. I was given the green light to refactor it so long as I thought I could do it relatively quickly, in a half day or so. This code isn’t the worst code in the application, but it certainly isn’t winning any beauty contests any time soon. Well, it might win one of those women-less beauty pageants, but then, those are never about beauty anyway. This code lies right at the heart of the application; a lot depends on it. There’s only so much that can be done to clean it up in a short amount of time, but it’s better than just abandoning it to the streets and waiting for it to become a delinquent.

Before I started ripping it apart, I turned to my coworker and began asking his opinion on what he would do. He’s been doing this for years. Sometime in the next six months or so I’ll pass one year of field experience. I must have sounded like a babbling baby.

“Wait, so I’m going to need to modify the interface to do that?”

“Oh, so I’ll create the object in this class, then pass that class into the object I’ve just created?”

Somehow, I managed to ask questions for about five minutes. Somehow, my coworker kept his patience after a long day and answered my questions. And at the end, I had a firm understanding of the best way to refactor the code.

Had I not asked questions, several things would have resulted. I would have ripped open the code and left blood everywhere, then wondered where I put the string to stitch it back up. Then when I did finally find the string, I’d probably have stitched it together in a state not much better than when I found it.

But I did asked questions. I learned how best to refactor the code from someone who has done it before. Also, by asking questions the thought process was played out verbally. It was reinforced, so the next time I encounter a similar situation I’ll have a starting point to proceed from.

Sometimes it pays to not keep your mouth shut.

On that note, what questions do you have? Feel free to leave one in the comments or use the contact page to drop me a line. You’ll learn by asking and I’ll learn by answering. The day I become too stuck up to answer questions is the day I become a hypocrite. I don’t want to be a hypocrite. I can’t imagine it’s fun.