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 Offline
    D Offline
    Dave Sexton
    wrote on last edited by
    #1

    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

    C I K D R 7 Replies 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

      C Offline
      C Offline
      Chris Losinger
      wrote on last edited by
      #2

      Dave Sexton wrote:

      commented out code that he didn't need and wrapped them in regions marked "To Delete"

      i've worked many places where it was common to leave dead code in there forever... JUST IN CASE!!! the idea seemed to be that if you deleted it, people might not know to check SS old versions, to see if the code was in there, when the time came to put the code back to use.

      image processing toolkits | batch image processing

      D 1 Reply Last reply
      0
      • C Chris Losinger

        Dave Sexton wrote:

        commented out code that he didn't need and wrapped them in regions marked "To Delete"

        i've worked many places where it was common to leave dead code in there forever... JUST IN CASE!!! the idea seemed to be that if you deleted it, people might not know to check SS old versions, to see if the code was in there, when the time came to put the code back to use.

        image processing toolkits | batch image processing

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

        I have to admit that I have an urge to leave commented code there... I always use version control with decent log messages, still I'm always tempted to keep everything. :-O

        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

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

          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 D 2 Replies 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

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

            I feel your pain, we have a medium sized project that was written by a newbie to .NET (but with a few years of Java under his belt) & someone with 8 years of .netting. The theory was the experienced guy would bring along the new one, but the experienced coder seemed to have only used .net 1.1 and neither had proper adult supervision. Eventually, as the timescales slipped they stopped working together. Net result: Datasets everywhere, no sense of OO and plenty of Javaesque "GetProperty()" and "SetProperty(object val)" style methods with no actual properties. Neither had experience of application design and obviously didn't know what they are doing with WCF (until I sorted it, we could only have maximum of 10 users). I'm now expected to sort this cr*p out.

            Dave Sexton wrote:

            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.

            Good. Try refactoring some of his code in front of him so he get the idea, then let him drive and guide him to make the changes. Have some :beer::beer::beer: on me

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

            D 1 Reply Last reply
            0
            • K Keith Barrow

              I feel your pain, we have a medium sized project that was written by a newbie to .NET (but with a few years of Java under his belt) & someone with 8 years of .netting. The theory was the experienced guy would bring along the new one, but the experienced coder seemed to have only used .net 1.1 and neither had proper adult supervision. Eventually, as the timescales slipped they stopped working together. Net result: Datasets everywhere, no sense of OO and plenty of Javaesque "GetProperty()" and "SetProperty(object val)" style methods with no actual properties. Neither had experience of application design and obviously didn't know what they are doing with WCF (until I sorted it, we could only have maximum of 10 users). I'm now expected to sort this cr*p out.

              Dave Sexton wrote:

              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.

              Good. Try refactoring some of his code in front of him so he get the idea, then let him drive and guide him to make the changes. Have some :beer::beer::beer: on me

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

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

              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 J 2 Replies 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
                Dave Sexton
                wrote on last edited by
                #7

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

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