Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. The Lounge
  3. What was I thinking?

What was I thinking?

Scheduled Pinned Locked Moved The Lounge
cssperformancequestioncode-review
15 Posts 13 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    Steve Driessens
    wrote on last edited by
    #1

    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

    C T J M J 9 Replies Last reply
    0
    • S Steve Driessens

      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

      T Offline
      T Offline
      Tom Archer
      wrote on last edited by
      #2

      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?!" :((

      C 1 Reply Last reply
      0
      • S Steve Driessens

        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

        C Offline
        C Offline
        Christian Graus
        wrote on last edited by
        #3

        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"

        1 Reply Last reply
        0
        • S Steve Driessens

          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

          J Offline
          J Offline
          Jonathan Gilligan
          wrote on last edited by
          #4

          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!

          1 Reply Last reply
          0
          • S Steve Driessens

            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

            M Offline
            M Offline
            Michael A Barnhart
            wrote on last edited by
            #5

            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 :)

            1 Reply Last reply
            0
            • S Steve Driessens

              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

              J Offline
              J Offline
              James R Twine
              wrote on last edited by
              #6

              > 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.

              1 Reply Last reply
              0
              • S Steve Driessens

                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

                M Offline
                M Offline
                Matt Philmon
                wrote on last edited by
                #7

                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...

                realJSOPR 1 Reply Last reply
                0
                • M Matt Philmon

                  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...

                  realJSOPR Offline
                  realJSOPR Offline
                  realJSOP
                  wrote on last edited by
                  #8

                  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. :)

                  1 Reply Last reply
                  0
                  • T Tom Archer

                    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?!" :((

                    C Offline
                    C Offline
                    Chris Maunder
                    wrote on last edited by
                    #9

                    *phew*! I was thinking the same thing but thought 'better not tell - they'll think I'm getting old and decrepit' :) cheers, Chris Maunder

                    J 1 Reply Last reply
                    0
                    • S Steve Driessens

                      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

                      R Offline
                      R Offline
                      Richard Melton
                      wrote on last edited by
                      #10

                      I looked at code that I just got up and running and think the same thing.........

                      1 Reply Last reply
                      0
                      • S Steve Driessens

                        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

                        A Offline
                        A Offline
                        Ajit Jadhav
                        wrote on last edited by
                        #11

                        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)

                        1 Reply Last reply
                        0
                        • S Steve Driessens

                          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

                          A Offline
                          A Offline
                          Alvaro Mendez
                          wrote on last edited by
                          #12

                          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...

                          C 1 Reply Last reply
                          0
                          • A Alvaro Mendez

                            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...

                            C Offline
                            C Offline
                            Christian Graus
                            wrote on last edited by
                            #13

                            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"

                            A 1 Reply Last reply
                            0
                            • C Christian Graus

                              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"

                              A Offline
                              A Offline
                              Alvaro Mendez
                              wrote on last edited by
                              #14

                              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

                              1 Reply Last reply
                              0
                              • C Chris Maunder

                                *phew*! I was thinking the same thing but thought 'better not tell - they'll think I'm getting old and decrepit' :) cheers, Chris Maunder

                                J Offline
                                J Offline
                                jkgh
                                wrote on last edited by
                                #15

                                Sounds wierd I know but I know I'm getting better when I can still look at my old code and laugh at what I wrote. ATL Student :rolleyes:

                                1 Reply Last reply
                                0
                                Reply
                                • Reply as topic
                                Log in to reply
                                • Oldest to Newest
                                • Newest to Oldest
                                • Most Votes


                                • Login

                                • Don't have an account? Register

                                • Login or register to search.
                                • First post
                                  Last post
                                0
                                • Categories
                                • Recent
                                • Tags
                                • Popular
                                • World
                                • Users
                                • Groups