Refactoring is evil - Journal of CTar - GameDev.net

Refactoring is evil

posted in Journal of CTar
Published November 20, 2005
Advertisement
Five days ago I chose to refactor my file system, since it was actually only a prototype, and it would be a PITA to make any changes to later.

Now, five days after I started refactoring, I have finally gotten my code to compile once again. At one point I had 4000< errors for 3500> lines of code(not including comments, whitespace etc.), it was some recursive template stuff. I'm a little disappointed since before refactoring I had over 3500 LOC(lines of code), now I only have 2865 LOC[crying] which doesn't sound as good, I had hoped I would cross the 5000 LOC barrier sometime next week, but that isn't going to happen because I had to refactor even though I haven't gained any new functionality.

I had actually planned to refactor my logging system too, but I think I will work on a memory manager first since I don't want to drop below 2500 LOC.

Everything was much easier when I was just learning C++ and just added code to my main function without ever removing a single line. Also copy-pasting instead of creating general-purpose functions could helped a lot to "improve" the number of LOC.

Well everything isn't bad, I have just gotten Introduction to algorithms, 2nd edition which I hope is a good book. It will probably give me even less time to work on my engine, but it will probably pay off later when I choose the right algorithms and don't have to spend weaks optimizing the wrong sort algorithm.
0 likes 2 comments

Comments

Monkeyget
When you refactore code it's a good idea to change the things one at a time and "always" be in a state where you can compile and run your code.
November 23, 2005 11:51 AM
CTar
<excuse>
I know, but sometimes when you start to refactor your code you find out how many things needs to be done and sometimes (not that I recommend it) I change a lot of code without a compile, this will sometimes lead to having to change other parts of the code and suddenly you have 100 errors because of something stupid.
</excuse>

But, yes it was a bad approach.
November 24, 2005 07:01 AM
You must log in to join the conversation.
Don't have a GameDev.net account? Sign up!
Profile
Author
Advertisement
Advertisement