Refactoring someone else’s code

I needed some code to do a function for my work. I found a .NET dll that costs $49 dollars. Well, after looking at it in reflector (which I always do to get a better idea of the architecture), I decided to refactor it.

I could have just used it.

I could have just made it work and had my boss purchase it.

I had already started on something similar when I decided to search the net for code already made, after all, why rewrite the wheel.

Well, the code was OK. You know when you look at someone’s code and you can always tell how much programming a person knows.

This person/people were only beginner/mid level programmers, and they were selling code with no visible programming patterns, had spelling mistakes, many duplications and more. So I used reflector to extract the source code.

Mostly what the code did, was a bunch of classes with properties, and two class that would concatenate the properties to a string, do a http post, and retrieve/parse the xml result to another class named Result.

Fine. So I refactored it, spending 4 hours or so on it. I added a factory pattern to distinguish between the two “gateway” objects that had almost the same code. I added an interface for the gateway. I added a base class for most of the generic properties for the classes, and left only the ones that were different from the base class.

At the end of the day, I got let go from work due to the economy, so did about 1/3 of the company, so I never got to implement this code in a project.

At this point, I would say 70-80% of the code I re-wrote. So the question remains, do I now own the code? or do they still retain rights to it?

At this point, it really only saved me a couple hours of typing in property declarations. What do you think?



kick it on DotNetKicks.com
14. January 2009 19:07 by Rick | Comments (3) | Permalink

Comments

About Rick

Rick lives in North Las Vegas. He loves his wife, kids, dog, motorcycle, music and programming. There ain't nothing else. Oh yeah, mountain dew!



Programming interests are geared towards multimedia. Platforms are asp.net, windows forms, and WPF.

Calendar

<<  March 2010  >>
MoTuWeThFrSaSu
22232425262728
1234567
891011121314
15161718192021
22232425262728
2930311234

View posts in large calendar

RecentComments

Comment RSS