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
-
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
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?!" :((
-
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're alone. :) Seriously, I periodically look back through parts of our project, especially ones from when I first started, and rewrite functions while simultaneously banging my head against the monitor and cursing my own stupidity. I think the thing is, if you're any good in this business, you constantly study to improve your skills, so unless that has not worked, you're bound to go back and realise there was a better way to do things. Christian #include "std_disclaimer.h"
-
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
Doing this is part of the discipline. If you call it "Refactoring," you'll feel less stupid when you do it. Frederick Brooks had this kind of thing in mind when he wrote about "Plan to throw one away" in The Mythical Man Month. What you don't want to get caught up in is refactoring code that may be crufty but is not on the critical path. It it accounts for less than 10% of your CPU time, don't even think of rewriting it, no matter how elegantly, unless there are reliability issues!
-
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
Ah to be 40 again:) No the world goes on. At 35 I was only allowed to write in Fortran. I was not stupid just still had a lot to learn. The code I wrote just a few years ago was usually driven by memory limits. Now that is not the case so the factors that are important have changed with the industry. Quiz: Any one remember the WANG 300 (I even had the 2K memory expansion that was 1/2 the size of a desk) Sorry I must be rambling :)
-
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