What was I thinking?
-
Recent threads on hard to maintain code got me thinking: Have any of you looked at code that you wrote in the past and wondered "What the hell was I thinking when I wrote that?" I'm in the middle of updating one of our apps and decided to see if I could improve the speed of one particular area of the program. The original code was written about five years ago and it's always worked reliably, just way too slow. I have no idea of what I must have been smoking at the time, but the code is a joke. After a 20 minute re-write it runs about 10 times faster with a lot less code to boot! I was 35 at the time, so I can't even blame it on being young and stupid. :-) So, am I alone, or does anybody else here find bits of dodgy old code and wonder what evil spirits posessed you when you wrote it? Steve
> Have any of you looked at code that you wrote in the past and wondered "What > the hell was I thinking when I wrote that?" Yep! I found an some old printouts of a "Galaxian"-type game that I wrote a while ago. But I can take the defense of "young and stupid": It was my first year of college, and I was just starting to really get into C++ coding. Peace! -=- James.
-
Recent threads on hard to maintain code got me thinking: Have any of you looked at code that you wrote in the past and wondered "What the hell was I thinking when I wrote that?" I'm in the middle of updating one of our apps and decided to see if I could improve the speed of one particular area of the program. The original code was written about five years ago and it's always worked reliably, just way too slow. I have no idea of what I must have been smoking at the time, but the code is a joke. After a 20 minute re-write it runs about 10 times faster with a lot less code to boot! I was 35 at the time, so I can't even blame it on being young and stupid. :-) So, am I alone, or does anybody else here find bits of dodgy old code and wonder what evil spirits posessed you when you wrote it? Steve
It pretty much happens every time I have to go back and fix a bug, add functionality, or make general improvements to an application I have already released. Invariably I learn so many new things from each new project I lead/code I always end up doing it differently the next time and wondering what in the world I was thinking the last time...
-
It pretty much happens every time I have to go back and fix a bug, add functionality, or make general improvements to an application I have already released. Invariably I learn so many new things from each new project I lead/code I always end up doing it differently the next time and wondering what in the world I was thinking the last time...
Here's a concept for you... I remember looking back (5 years ago) at code that was 10 years old and thinking that, and now, I look back at code no more than a few hours old, and think the same thing. At the present rate, I should be able to identify bad code that I will write sometime in the future before I actually write it. :)
-
Actually, I'm the opposite! I look at code I wrote a few years ago and think "Damn! I used to be really good. What the hell happened to me?!" :((
*phew*! I was thinking the same thing but thought 'better not tell - they'll think I'm getting old and decrepit' :) cheers, Chris Maunder
-
Recent threads on hard to maintain code got me thinking: Have any of you looked at code that you wrote in the past and wondered "What the hell was I thinking when I wrote that?" I'm in the middle of updating one of our apps and decided to see if I could improve the speed of one particular area of the program. The original code was written about five years ago and it's always worked reliably, just way too slow. I have no idea of what I must have been smoking at the time, but the code is a joke. After a 20 minute re-write it runs about 10 times faster with a lot less code to boot! I was 35 at the time, so I can't even blame it on being young and stupid. :-) So, am I alone, or does anybody else here find bits of dodgy old code and wonder what evil spirits posessed you when you wrote it? Steve
I looked at code that I just got up and running and think the same thing.........
-
Recent threads on hard to maintain code got me thinking: Have any of you looked at code that you wrote in the past and wondered "What the hell was I thinking when I wrote that?" I'm in the middle of updating one of our apps and decided to see if I could improve the speed of one particular area of the program. The original code was written about five years ago and it's always worked reliably, just way too slow. I have no idea of what I must have been smoking at the time, but the code is a joke. After a 20 minute re-write it runs about 10 times faster with a lot less code to boot! I was 35 at the time, so I can't even blame it on being young and stupid. :-) So, am I alone, or does anybody else here find bits of dodgy old code and wonder what evil spirits posessed you when you wrote it? Steve
Unfortunately, as a contract programmer, I don't have the luxury to be able to look back at my code again once the contract ends. So, I have to produce the best that is possible in the present tense, and have to rest my professional reputation right on that. But for the code I write at home, there have been times when I have said to myself, "Wow! I had come so close to that even then!" That is so, typically, for epochal code (written before the current epoch as per Moore's law). For ancient code (by definition, a moving period going back in time for about 1.5+ times Moore's period), I am just amused by what all things I had to deal with. ------- Nature, to be commanded, must be obeyed. (Francis Bacon) Nature, to be apprehended, must be obeyed. (Ayn Rand)
-
Recent threads on hard to maintain code got me thinking: Have any of you looked at code that you wrote in the past and wondered "What the hell was I thinking when I wrote that?" I'm in the middle of updating one of our apps and decided to see if I could improve the speed of one particular area of the program. The original code was written about five years ago and it's always worked reliably, just way too slow. I have no idea of what I must have been smoking at the time, but the code is a joke. After a 20 minute re-write it runs about 10 times faster with a lot less code to boot! I was 35 at the time, so I can't even blame it on being young and stupid. :-) So, am I alone, or does anybody else here find bits of dodgy old code and wonder what evil spirits posessed you when you wrote it? Steve
You know, I must be a weird or something, 'cause I don't have that problem. When I go back to old code, I always say, "Wow, that's good stuff!". It's when I go other people's code that I say, "How can this guy be paid to write code like this on a daily basis?". For the past 8 years I've disciplined myself to write efficient, well organized, and well documented code. Once I understood how important it is do so, I started doing it and haven't gone back since. Now, if I could only convince some of my co-workers to do the same, life would be a lot better...
-
You know, I must be a weird or something, 'cause I don't have that problem. When I go back to old code, I always say, "Wow, that's good stuff!". It's when I go other people's code that I say, "How can this guy be paid to write code like this on a daily basis?". For the past 8 years I've disciplined myself to write efficient, well organized, and well documented code. Once I understood how important it is do so, I started doing it and haven't gone back since. Now, if I could only convince some of my co-workers to do the same, life would be a lot better...
No offence, but I can't help but feel if I thought the code I wrote last year was all good stuff, I would not have progressed. Don't get me wrong, some of it is *damn* cool:), but in the details, there is often something I could have done better/more elegantly. Christian #include "std_disclaimer.h"
-
No offence, but I can't help but feel if I thought the code I wrote last year was all good stuff, I would not have progressed. Don't get me wrong, some of it is *damn* cool:), but in the details, there is often something I could have done better/more elegantly. Christian #include "std_disclaimer.h"
I suppose you're right. If I were to comb through line by line, I'd surely find spots where I could have worded a comment more clearly or maybe named a function differently. The times when I go back to make something substancially better it's because I've actually planned for it beforehand. In other words, I say, "OK I'm gonna do it this way now but I should revisit it later since it's quite possible that it can be done better." Just recently it happened with a new class I created called CDouble. I did it for the sole purpose of wrapping the double type. I made it a standalone class but I thought to myself, "Hmmm, this should probably be implemented by deriving from a template class so I can use it for other primitive types like int or short". And that's exactly what I did. Some time after I had the CDouble class working in my code, I took a break to go back and implement it using a template class which allowed me to create other type wrappers such as CInt, CUInt, CShort, etc. Bottom line, I don't go back to my code and say "man, what possessed me to write something so abominable?". Those days are over, thank God. Regards, Alvaro
-
*phew*! I was thinking the same thing but thought 'better not tell - they'll think I'm getting old and decrepit' :) cheers, Chris Maunder