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. Isn't it fun when you write something and look back months later and wonder how you did it?

Isn't it fun when you write something and look back months later and wonder how you did it?

Scheduled Pinned Locked Moved The Lounge
csharpalgorithmsquestionannouncement
40 Posts 24 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.
  • H honey the codewitch

    I was looking at some of my old code - Glory, a GLR parser generator for .NET - and I'm amazed A) I was able to pick it up and start maintaining it right away despite me having written it in February B) I understand how it works, but I still don't understand how I did it. The code is amazing. What it does is just... The complexity of code like my XbnfConvert.cs file just floors me. It's very very clever to boot. I must have been in one heck of a zone. I don't know if I could do it again. It makes me happy to know I can write code like this. Or at least I can sometimes. At the same time, it kind of worries me that the code feels like it was maybe written by a better version of myself. Does this happen to others, or am I just a lunatic?

    Real programmers use butterflies

    S Offline
    S Offline
    Stefan_Lang
    wrote on last edited by
    #31

    I've made it a habit to explain every non-trivial part of my code in detail, using very_long_expressive_names, and multiline comments to explain how I arrived at the algorithm or formula. I do that for my future self, most of all, but occasionally my coworkers benefit from it, too. For that reason, most of the time, it is my future me who thanks my past self for spending that extra time when I have to look at that code months or years later! With a sufficient level of explanation, that work looks a lot less like magic, so I typically end up with 'what the hell was I thinking?' more often than 'boy, what a brilliant idea' ;)

    GOTOs are a bit like wire coat hangers: they tend to breed in the darkness, such that where there once were few, eventually there are many, and the program's architecture collapses beneath them. (Fran Poretto)

    H 1 Reply Last reply
    0
    • B BryanFazekas

      On occasion, the requirements are convoluted and there is no simple way to do it. Implementing a system that complies with a law that has been repeatedly amended for years or decades is case in point. I write comments explaining what is being done and why -- this helps greatly in picking things back up later.

      D Offline
      D Offline
      dandy72
      wrote on last edited by
      #32

      Agreed. This is why I ended with:

      Quote:

      These two goals are sometimes at odds with each other

      ...as sometimes it's just impossible to refactor and not break anything. Easy-to-read code is worthless if it doesn't do what it's supposed to.

      1 Reply Last reply
      0
      • H honey the codewitch

        I was looking at some of my old code - Glory, a GLR parser generator for .NET - and I'm amazed A) I was able to pick it up and start maintaining it right away despite me having written it in February B) I understand how it works, but I still don't understand how I did it. The code is amazing. What it does is just... The complexity of code like my XbnfConvert.cs file just floors me. It's very very clever to boot. I must have been in one heck of a zone. I don't know if I could do it again. It makes me happy to know I can write code like this. Or at least I can sometimes. At the same time, it kind of worries me that the code feels like it was maybe written by a better version of myself. Does this happen to others, or am I just a lunatic?

        Real programmers use butterflies

        M Offline
        M Offline
        Matt McGuire
        wrote on last edited by
        #33

        the zone is a real thing. I've also produced some amazing things in a short amount of time when in the zone. I still have some of that code running 20 years later But the opposite happens once in awhile, and I'm like WTF did I write? it works, but it shouldn't.

        1 Reply Last reply
        0
        • S Stefan_Lang

          I've made it a habit to explain every non-trivial part of my code in detail, using very_long_expressive_names, and multiline comments to explain how I arrived at the algorithm or formula. I do that for my future self, most of all, but occasionally my coworkers benefit from it, too. For that reason, most of the time, it is my future me who thanks my past self for spending that extra time when I have to look at that code months or years later! With a sufficient level of explanation, that work looks a lot less like magic, so I typically end up with 'what the hell was I thinking?' more often than 'boy, what a brilliant idea' ;)

          GOTOs are a bit like wire coat hangers: they tend to breed in the darkness, such that where there once were few, eventually there are many, and the program's architecture collapses beneath them. (Fran Poretto)

          H Offline
          H Offline
          honey the codewitch
          wrote on last edited by
          #34

          I have been able to maintain the thing after picking it up 7 months later, so I'm able to understand it.

          Real programmers use butterflies

          1 Reply Last reply
          0
          • B BobbyStrain

            What is a web/desktop?

            F Offline
            F Offline
            Forogar
            wrote on last edited by
            #35

            It is a desktop program that uses the same web-service calls as the web-based program uses for a start. As I said, it's a hybrid program.

            - I would love to change the world, but they won’t give me the source code.

            1 Reply Last reply
            0
            • H honey the codewitch

              I was looking at some of my old code - Glory, a GLR parser generator for .NET - and I'm amazed A) I was able to pick it up and start maintaining it right away despite me having written it in February B) I understand how it works, but I still don't understand how I did it. The code is amazing. What it does is just... The complexity of code like my XbnfConvert.cs file just floors me. It's very very clever to boot. I must have been in one heck of a zone. I don't know if I could do it again. It makes me happy to know I can write code like this. Or at least I can sometimes. At the same time, it kind of worries me that the code feels like it was maybe written by a better version of myself. Does this happen to others, or am I just a lunatic?

              Real programmers use butterflies

              J Offline
              J Offline
              JP Reyes
              wrote on last edited by
              #36

              No it's not fun for me, especially since most of the code I revisit was done more than 7 years ago, was in C++ or assembler and if I don't remember everything based on the comments, then it was badly commented. Considering the uncountable number of hacks that went into game engines of that period, astonishment is quite frequent but it's also like going back and judging yourself from experience (you've since figured out more elegant algorithms or hacks)

              1 Reply Last reply
              0
              • R rnbergren

                rarely do I look back at my old code and am amazed. More likely I am cussing myself because I was an idiot and if I would have only looked at it differently I could have saved myself so much time. But there was that one time at 3am drunk coding. Still not sure why it works or how but it does. Also, not sure what it does either.

                To err is human to really mess up you need a computer

                B Offline
                B Offline
                Bogatitus
                wrote on last edited by
                #37

                This is great, I thought I was alone. I watched someone using one of my tools once. He would start it and due to the size of the project it would take about 20-30 minutes to complete. He was literally just playing with his phone for 3/4's of his day instead of doing other things. I got so angry I literally rewrote the whole thing an entirely different way while consuming an entire bottle of scotch. I woke up with no recollection of what I had done, but it worked and that same task only took 30 seconds! Years later I did unravel what I did and still don't understand how I made something relatively nice while hammered drunk. Clearly my first implementation was not a good one, but in my defense it wasn't meant to be run on excessively large data sets at the time.

                R 1 Reply Last reply
                0
                • B Bogatitus

                  This is great, I thought I was alone. I watched someone using one of my tools once. He would start it and due to the size of the project it would take about 20-30 minutes to complete. He was literally just playing with his phone for 3/4's of his day instead of doing other things. I got so angry I literally rewrote the whole thing an entirely different way while consuming an entire bottle of scotch. I woke up with no recollection of what I had done, but it worked and that same task only took 30 seconds! Years later I did unravel what I did and still don't understand how I made something relatively nice while hammered drunk. Clearly my first implementation was not a good one, but in my defense it wasn't meant to be run on excessively large data sets at the time.

                  R Offline
                  R Offline
                  rnbergren
                  wrote on last edited by
                  #38

                  I knew I wasn't the only one.

                  To err is human to really mess up you need a computer

                  1 Reply Last reply
                  0
                  • H honey the codewitch

                    I feel I need to clarify that I don't have a low opinion of coders in the trenches. I used to be one. That said, my code I post here isn't bizdev code, or even team developed. I code for the situation I'm in. My professional business software source doesn't look like the source I code in my free time where I can make it look and perform how *I* want to. It takes me less work to do it my way and I find the freedom of it liberating. I think it's weird that you consider my code more CS than engineering, since I've never taken a CS course in my life. :) I learned in the field.

                    Real programmers use butterflies

                    G Offline
                    G Offline
                    Gary R Wheeler
                    wrote on last edited by
                    #39

                    honey the codewitch wrote:

                    I think it's weird that you consider my code more CS than engineering

                    My bad. I'm stereotyping your code based on the subject matter: parsers and the surrounding ecosystem. That area of expertise has always seemed to be dominated by academics, in my experience. I occasionally do work on the side from my M-F/8-4 job. One job was for a university professor who used graduate students as slave labor. They needed a multithreaded app to setup and control some hardware they were developing for sale outside the university. There was quite the culture shock when I started submitting code to them. They were used to using and writing code that started with the bare minimum necessary to perform some function, and then layered error handling and UI on top. The notion of architecting a solution in advance that kept these considerations in mind was utterly foreign to them. The more noteworthy job was software to run a prototype machine. An intern at the company had written hardware control primitives that were quite good. A scientist wrote code that performed the detailed mathematics required to execute the machine's actual function. The scientist was a good mathematician, but a terrible programmer. I was hired to write a test bed application to let the company demonstrate the hardware to their customer. I wrote UI and integrated the intern's hardware primitives in short order. Integrating the mathematics was a disaster. I routinely set the warning level on my compilers at maximum just ensure that the stupid mistakes are caught. The scientist's code wouldn't compile clean, even at warning level zero. Lots of ill-advised pointer arithmetic, a global misunderstanding of type casting, random switching between float vs. double, a firm belief that array indices in C started at 1 (see the pointer arithmetic), and so on. I tried to work around the problems for a while, but finally gave up. The scientist wouldn't give me a copy of his design notes for the mathematics, so I finally went to the head of the project for them. Between those notes and reverse-engineering his code, I was able to replace the mad scientist code with something a lot more robust. Interestingly this was one time in my career where my courses in numerical methods in college really came in handy. I replaced some of the scientist's integration and differentiation code with other algorithms to address precision issues. I even found some operational e

                    H 1 Reply Last reply
                    0
                    • G Gary R Wheeler

                      honey the codewitch wrote:

                      I think it's weird that you consider my code more CS than engineering

                      My bad. I'm stereotyping your code based on the subject matter: parsers and the surrounding ecosystem. That area of expertise has always seemed to be dominated by academics, in my experience. I occasionally do work on the side from my M-F/8-4 job. One job was for a university professor who used graduate students as slave labor. They needed a multithreaded app to setup and control some hardware they were developing for sale outside the university. There was quite the culture shock when I started submitting code to them. They were used to using and writing code that started with the bare minimum necessary to perform some function, and then layered error handling and UI on top. The notion of architecting a solution in advance that kept these considerations in mind was utterly foreign to them. The more noteworthy job was software to run a prototype machine. An intern at the company had written hardware control primitives that were quite good. A scientist wrote code that performed the detailed mathematics required to execute the machine's actual function. The scientist was a good mathematician, but a terrible programmer. I was hired to write a test bed application to let the company demonstrate the hardware to their customer. I wrote UI and integrated the intern's hardware primitives in short order. Integrating the mathematics was a disaster. I routinely set the warning level on my compilers at maximum just ensure that the stupid mistakes are caught. The scientist's code wouldn't compile clean, even at warning level zero. Lots of ill-advised pointer arithmetic, a global misunderstanding of type casting, random switching between float vs. double, a firm belief that array indices in C started at 1 (see the pointer arithmetic), and so on. I tried to work around the problems for a while, but finally gave up. The scientist wouldn't give me a copy of his design notes for the mathematics, so I finally went to the head of the project for them. Between those notes and reverse-engineering his code, I was able to replace the mad scientist code with something a lot more robust. Interestingly this was one time in my career where my courses in numerical methods in college really came in handy. I replaced some of the scientist's integration and differentiation code with other algorithms to address precision issues. I even found some operational e

                      H Offline
                      H Offline
                      honey the codewitch
                      wrote on last edited by
                      #40

                      Gary R. Wheeler wrote:

                      I'm stereotyping your code based on the subject matter: parsers and the surrounding ecosystem. That area of expertise has always seemed to be dominated by academics, in my experience.

                      It is, but only because I never went to school for software development, so now that I have time, I'm picking up on the CS fundamentals I never learned. It's not to make my code more academic, but it's to round out my knowledge.

                      Gary R. Wheeler wrote:

                      The scientist wouldn't give me a copy of his design notes for the mathematics, so I finally went to the head of the project for them. Between those notes and reverse-engineering his code, I was able to replace the mad scientist code with something a lot more robust.

                      That doesn't surprise me actually. This might be my failing in assuming code produced by academics has no place in production, but that's where I'm at and how I feel. We may even share that opinion. Still, I don't want to be too hard on them, and I think being able to give your algorithms formal mathematical treatment has its place, especially with really complicated algorithms.

                      Real programmers use butterflies

                      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