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

Dirty Code

Scheduled Pinned Locked Moved The Lounge
javaquestion
21 Posts 12 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.
  • D Dave Sexton

    Argh. I'm working on a piece of software that was written by a junior colleague not long after he started. It was meant to kinda "break him in" but no-one reviewed his code. Reading through it is a nightmare. I can fully appreciate that it's not his fault that no-one reviewed his code (even though they were supposed to) but what I don't get is that he's left his code littered with useless comments, commented out code that he didn't need and wrapped them in regions marked "To Delete". It's doing my head in. Why didn't he just delete them? They have no purpose & we use source control for a reason! I'm going to use it as an opportunity to try and grow him into a better coder (I know I sucked when I started too) instead of just throwing my toys outta the cot. I might check up on some of his more recent contributions too. No real point to this post, just needed to get it off my chest.

    But fortunately we have the nanny-state politicians who can step in to protect us poor stupid consumers, most of whom would not know a JVM from a frozen chicken. Bruce Pierson
    Because programming is an art, not a science. Marc Clifton
    I gave up when I couldn't spell "egg". Justine Allen

    D Offline
    D Offline
    Dave Parker
    wrote on last edited by
    #8

    I sometimes comment out small blocks of code - like a few lines, if I think its useful to refer back to, to see the way something used to work without relying on someone looking in version history to see. But in our project there are lots of large (several hundred line) functions which aren't called from anywhere. In many cases the function has been copied and pasted and there might be a V1, V2 and V3 version but all callers use the V3 one. It's messy, slows development down as there's more useless crap to wade through and I'm not allowed to remove / comment out such functions because they don't directly relate to a customer request.

    I R 2 Replies Last reply
    0
    • D Dave Sexton

      Ian Shlasko wrote:

      So when I look at the new code a year later when something needs to be tweaked, I won't think, "Well, that's a silly way to do it! This would be much more efficient!" and make the old mistake again.

      This I can understand and almost agree with. Problem in my case is that he's left truly redundant code.

      But fortunately we have the nanny-state politicians who can step in to protect us poor stupid consumers, most of whom would not know a JVM from a frozen chicken. Bruce Pierson
      Because programming is an art, not a science. Marc Clifton
      I gave up when I couldn't spell "egg". Justine Allen

      I Offline
      I Offline
      Ian Shlasko
      wrote on last edited by
      #9

      Dave Sexton wrote:

      Problem in my case is that he's left truly redundant code.

      Yeah, in that case, he needs some re-education... I'd say start with vocal instruction, and try to avoid the electroshock unless it's really serious.

      Proud to have finally moved to the A-Ark. Which one are you in? Author of Guardians of Xen (Sci-Fi/Fantasy novel)

      1 Reply Last reply
      0
      • D Dave Parker

        I sometimes comment out small blocks of code - like a few lines, if I think its useful to refer back to, to see the way something used to work without relying on someone looking in version history to see. But in our project there are lots of large (several hundred line) functions which aren't called from anywhere. In many cases the function has been copied and pasted and there might be a V1, V2 and V3 version but all callers use the V3 one. It's messy, slows development down as there's more useless crap to wade through and I'm not allowed to remove / comment out such functions because they don't directly relate to a customer request.

        I Offline
        I Offline
        Ian Shlasko
        wrote on last edited by
        #10

        Are you at least allowed to hide V1 and V2 in a #region and add [Obsolete] attributes (Assuming you're in .NET)?

        Proud to have finally moved to the A-Ark. Which one are you in? Author of Guardians of Xen (Sci-Fi/Fantasy novel)

        D 1 Reply Last reply
        0
        • I Ian Shlasko

          I sometimes do that, actually... When maintaining old code and replacing bits of it, I'll sometimes leave the old version in there and commented. It's not to keep a record in case we have to revert, but rather to let anyone reading the code know WHY the code was done a certain way. Kind of implies, "Yes, this would be the OBVIOUS solution, but we used to do it this way and it didn't work because ______" So when I look at the new code a year later when something needs to be tweaked, I won't think, "Well, that's a silly way to do it! This would be much more efficient!" and make the old mistake again.

          Proud to have finally moved to the A-Ark. Which one are you in? Author of Guardians of Xen (Sci-Fi/Fantasy novel)

          D Offline
          D Offline
          Dan Neely
          wrote on last edited by
          #11

          I don't know if I've ever left the non working code in place. Comments of the effect "Can't do X because it will break in edge case Y." is my standard practice.

          3x12=36 2x12=24 1x12=12 0x12=18

          1 Reply Last reply
          0
          • D Dave Parker

            I sometimes comment out small blocks of code - like a few lines, if I think its useful to refer back to, to see the way something used to work without relying on someone looking in version history to see. But in our project there are lots of large (several hundred line) functions which aren't called from anywhere. In many cases the function has been copied and pasted and there might be a V1, V2 and V3 version but all callers use the V3 one. It's messy, slows development down as there's more useless crap to wade through and I'm not allowed to remove / comment out such functions because they don't directly relate to a customer request.

            R Offline
            R Offline
            ragnaroknrol
            wrote on last edited by
            #12

            Dave Parker wrote:

            and I'm not allowed to remove / comment out such functions because they don't directly relate to a customer request.

            "Removed redundant and unnecessary functions due to customer request. Request: 'Programs runs slower than a snail taking depressants.' "

            modified on Thursday, December 10, 2009 10:52 AM

            D 1 Reply Last reply
            0
            • D Dario Solera

              keefb wrote:

              obviously didn't know what they are doing with WCF

              Every time I work with WCF I have the impression that I don't know what I am doing. The thing seems to work anyway. :~

              If you truly believe you need to pick a mobile phone that "says something" about your personality, don't bother. You don't have a personality. A mental illness, maybe - but not a personality. - Charlie Brooker My Photos/CP Flickr Group - ScrewTurn Wiki v3

              K Offline
              K Offline
              Keith Barrow
              wrote on last edited by
              #13

              :laugh: That sounds par for the course, it took me a long time to get it write. The stupid thing was after I did this, I spent a fair amount of time trying to get the original coders of my current project to implement the services properly. They've both gone and I've been parachuted in to plug the gap, from a large project that I pretty much desgined and built and was a success, in no small measure do to my efforts. That was a nice thank you which is why [partly] my job sucks today and every day (for the last 7 months). At least we are estimated to finish in 6 weeks, but this has been true since June. Still the jobs market will pick up soon :~

              CCC solved so far: 2 (including a Hard One!) 37!?!! - Randall, Clerks

              1 Reply Last reply
              0
              • D Dario Solera

                keefb wrote:

                obviously didn't know what they are doing with WCF

                Every time I work with WCF I have the impression that I don't know what I am doing. The thing seems to work anyway. :~

                If you truly believe you need to pick a mobile phone that "says something" about your personality, don't bother. You don't have a personality. A mental illness, maybe - but not a personality. - Charlie Brooker My Photos/CP Flickr Group - ScrewTurn Wiki v3

                J Offline
                J Offline
                Jim Crafton
                wrote on last edited by
                #14

                Dario Solera wrote:

                Every time I work with anything WCF web-app related I have the impression that I don't know what I am doing.

                Fixed that for you :)

                ¡El diablo está en mis pantalones! ¡Mire, mire! SELECT * FROM User WHERE Clue > 0 0 rows returned Save an Orange - Use the VCF! Personal 3D projects Just Say No to Web 2 Point Blow

                D 1 Reply Last reply
                0
                • J Jim Crafton

                  Dario Solera wrote:

                  Every time I work with anything WCF web-app related I have the impression that I don't know what I am doing.

                  Fixed that for you :)

                  ¡El diablo está en mis pantalones! ¡Mire, mire! SELECT * FROM User WHERE Clue > 0 0 rows returned Save an Orange - Use the VCF! Personal 3D projects Just Say No to Web 2 Point Blow

                  D Offline
                  D Offline
                  Dario Solera
                  wrote on last edited by
                  #15

                  I find web apps much easier to understand, generally. Maybe it's just because I've never really done desktop development. WCF is, well, obscure.

                  If you truly believe you need to pick a mobile phone that "says something" about your personality, don't bother. You don't have a personality. A mental illness, maybe - but not a personality. - Charlie Brooker My Photos/CP Flickr Group - ScrewTurn Wiki v3

                  1 Reply Last reply
                  0
                  • D Dave Sexton

                    Argh. I'm working on a piece of software that was written by a junior colleague not long after he started. It was meant to kinda "break him in" but no-one reviewed his code. Reading through it is a nightmare. I can fully appreciate that it's not his fault that no-one reviewed his code (even though they were supposed to) but what I don't get is that he's left his code littered with useless comments, commented out code that he didn't need and wrapped them in regions marked "To Delete". It's doing my head in. Why didn't he just delete them? They have no purpose & we use source control for a reason! I'm going to use it as an opportunity to try and grow him into a better coder (I know I sucked when I started too) instead of just throwing my toys outta the cot. I might check up on some of his more recent contributions too. No real point to this post, just needed to get it off my chest.

                    But fortunately we have the nanny-state politicians who can step in to protect us poor stupid consumers, most of whom would not know a JVM from a frozen chicken. Bruce Pierson
                    Because programming is an art, not a science. Marc Clifton
                    I gave up when I couldn't spell "egg". Justine Allen

                    R Offline
                    R Offline
                    R Giskard Reventlov
                    wrote on last edited by
                    #16

                    If I really feel I want to leave some old code in, just for reference or whatevr I decorate the method with [Obsolete("Don't use this crap", true)] otherwsie just cut out the dead wood - it'll all look a little alien in 6 months anyway.

                    me, me, me

                    1 Reply Last reply
                    0
                    • I Ian Shlasko

                      Are you at least allowed to hide V1 and V2 in a #region and add [Obsolete] attributes (Assuming you're in .NET)?

                      Proud to have finally moved to the A-Ark. Which one are you in? Author of Guardians of Xen (Sci-Fi/Fantasy novel)

                      D Offline
                      D Offline
                      Dave Parker
                      wrote on last edited by
                      #17

                      lol I wish - this is in wonderful VB6.

                      I 1 Reply Last reply
                      0
                      • R ragnaroknrol

                        Dave Parker wrote:

                        and I'm not allowed to remove / comment out such functions because they don't directly relate to a customer request.

                        "Removed redundant and unnecessary functions due to customer request. Request: 'Programs runs slower than a snail taking depressants.' "

                        modified on Thursday, December 10, 2009 10:52 AM

                        D Offline
                        D Offline
                        Dave Parker
                        wrote on last edited by
                        #18

                        lol though it wouldn't make any difference to speed could probably get away with that actually seeing as we get phoned up nearly every day from someone complaining the systems slow (generally because people there are running off loads of reports etc in the middle of the day).

                        1 Reply Last reply
                        0
                        • D Dave Parker

                          lol I wish - this is in wonderful VB6.

                          I Offline
                          I Offline
                          Ian Shlasko
                          wrote on last edited by
                          #19

                          Ouch... I feel your pain. I'm maintaining a 15-year-old VB6 app myself (Originally written as Excel macros, I think)

                          Proud to have finally moved to the A-Ark. Which one are you in? Author of Guardians of Xen (Sci-Fi/Fantasy novel)

                          1 Reply Last reply
                          0
                          • D Dave Sexton

                            Argh. I'm working on a piece of software that was written by a junior colleague not long after he started. It was meant to kinda "break him in" but no-one reviewed his code. Reading through it is a nightmare. I can fully appreciate that it's not his fault that no-one reviewed his code (even though they were supposed to) but what I don't get is that he's left his code littered with useless comments, commented out code that he didn't need and wrapped them in regions marked "To Delete". It's doing my head in. Why didn't he just delete them? They have no purpose & we use source control for a reason! I'm going to use it as an opportunity to try and grow him into a better coder (I know I sucked when I started too) instead of just throwing my toys outta the cot. I might check up on some of his more recent contributions too. No real point to this post, just needed to get it off my chest.

                            But fortunately we have the nanny-state politicians who can step in to protect us poor stupid consumers, most of whom would not know a JVM from a frozen chicken. Bruce Pierson
                            Because programming is an art, not a science. Marc Clifton
                            I gave up when I couldn't spell "egg". Justine Allen

                            A Offline
                            A Offline
                            AspDotNetDev
                            wrote on last edited by
                            #20

                            I only use the "TODO: Delete" technique when I'm really getting into something and making tons of changes... changes that I may change before I check in my code. But it's utterly worthless to leave that in there. And I never did like when others comment out a line of code and show it's altered form directly below it... just make the bloody change is what I say.

                            [Forum Guidelines]

                            1 Reply Last reply
                            0
                            • D Dave Sexton

                              Argh. I'm working on a piece of software that was written by a junior colleague not long after he started. It was meant to kinda "break him in" but no-one reviewed his code. Reading through it is a nightmare. I can fully appreciate that it's not his fault that no-one reviewed his code (even though they were supposed to) but what I don't get is that he's left his code littered with useless comments, commented out code that he didn't need and wrapped them in regions marked "To Delete". It's doing my head in. Why didn't he just delete them? They have no purpose & we use source control for a reason! I'm going to use it as an opportunity to try and grow him into a better coder (I know I sucked when I started too) instead of just throwing my toys outta the cot. I might check up on some of his more recent contributions too. No real point to this post, just needed to get it off my chest.

                              But fortunately we have the nanny-state politicians who can step in to protect us poor stupid consumers, most of whom would not know a JVM from a frozen chicken. Bruce Pierson
                              Because programming is an art, not a science. Marc Clifton
                              I gave up when I couldn't spell "egg". Justine Allen

                              R Offline
                              R Offline
                              Ravi Bhavnani
                              wrote on last edited by
                              #21

                              Dave Sexton wrote:

                              I can fully appreciate that it's not his fault that no-one reviewed his code (even though they were supposed to)

                              Kudos for recognizing the (process) problem!  Good will definitely come out of your experience.  :thumbsup: /ravi

                              My new year resolution: 2048 x 1536 Home | Articles | My .NET bits | Freeware ravib(at)ravib(dot)com

                              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