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. Where do you draw the line on cleaning up someone elses code

Where do you draw the line on cleaning up someone elses code

Scheduled Pinned Locked Moved The Lounge
collaborationtoolsquestion
28 Posts 18 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 Dan Neely

    Beyond a certain point you cross over from something being obviously crap, to "I like style X better than style Y"; at which point the main thing you're doing becomes adding noise to your source control diffs? Does it matter if other devs are still working on it, or if it's all you now? Does having a tool like Resharper, whose utility in finding stuff the compiler warnings miss is badly degraded if it's spazzing out over style issues, affect where you draw the line? What if only part of the team has the tool?

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

    S Offline
    S Offline
    S Houghtelin
    wrote on last edited by
    #2

    Dan Neely wrote:

    Where do you draw the line?

    You draw the line through all of their code and start over from scratch. :)

    It was broke, so I fixed it.

    1 Reply Last reply
    0
    • D Dan Neely

      Beyond a certain point you cross over from something being obviously crap, to "I like style X better than style Y"; at which point the main thing you're doing becomes adding noise to your source control diffs? Does it matter if other devs are still working on it, or if it's all you now? Does having a tool like Resharper, whose utility in finding stuff the compiler warnings miss is badly degraded if it's spazzing out over style issues, affect where you draw the line? What if only part of the team has the tool?

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

      J Offline
      J Offline
      Jeremy Hutchinson
      wrote on last edited by
      #3

      I generally don't mess with style unless it is totally messed up. In which case I check-out, reformat the whole document, check in with the comment that all I did was reformat. Then on with code changes. As a general rule though all code should be formatted in the default style within VS. The real formatting issues here are in the SQL stored procedures where we seem to have many distinctly different styles to the point where you can tell who wrote what by the way it's formatted. I've tried to get people to standardize on any of the formats, but have so far received no support on that. If only there was a tool that did as good of a job formatting SQL as VS does with C# code.

      D T U 3 Replies Last reply
      0
      • D Dan Neely

        Beyond a certain point you cross over from something being obviously crap, to "I like style X better than style Y"; at which point the main thing you're doing becomes adding noise to your source control diffs? Does it matter if other devs are still working on it, or if it's all you now? Does having a tool like Resharper, whose utility in finding stuff the compiler warnings miss is badly degraded if it's spazzing out over style issues, affect where you draw the line? What if only part of the team has the tool?

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

        F Offline
        F Offline
        Flynn Arrowstarr Regular Schmoe
        wrote on last edited by
        #4

        In a professional setting, you should use your company's coding standards to draw the line. If they don't have one, work with the team to develop one you like. As a hobbyist, I tend to use the SharpDevelop Guidelines (PDF)[^]. About the only thing I change is I always put a brace on a newline instead of only on classes and interfaces. So, my typical if/then statement would be:

        if (a + b)
        {
            // code block;
        }

        instead of:

        if (a + b) {
            // code block;
        }

        Sometimes I slip back to Hungarian notation for controls and variables, but I usually catch myself early enough to adjust the source accordingly. :-\ Flynn

        D T 2 Replies Last reply
        0
        • D Dan Neely

          Beyond a certain point you cross over from something being obviously crap, to "I like style X better than style Y"; at which point the main thing you're doing becomes adding noise to your source control diffs? Does it matter if other devs are still working on it, or if it's all you now? Does having a tool like Resharper, whose utility in finding stuff the compiler warnings miss is badly degraded if it's spazzing out over style issues, affect where you draw the line? What if only part of the team has the tool?

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

          T Offline
          T Offline
          thrakazog
          wrote on last edited by
          #5

          If I can read the code and understand it whatever style is fine. I don't care about casing or variable names. I've seen some people blow a gasket over naming conventions and such. To me it's just not that important. What the code is doing matters. How it looks, not so much.

          A P 2 Replies Last reply
          0
          • T thrakazog

            If I can read the code and understand it whatever style is fine. I don't care about casing or variable names. I've seen some people blow a gasket over naming conventions and such. To me it's just not that important. What the code is doing matters. How it looks, not so much.

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

            See my new signature. :)

            Martin Fowler wrote:

            Any fool can write code that a computer can understand. Good programmers write code that humans can understand.

            1 Reply Last reply
            0
            • F Flynn Arrowstarr Regular Schmoe

              In a professional setting, you should use your company's coding standards to draw the line. If they don't have one, work with the team to develop one you like. As a hobbyist, I tend to use the SharpDevelop Guidelines (PDF)[^]. About the only thing I change is I always put a brace on a newline instead of only on classes and interfaces. So, my typical if/then statement would be:

              if (a + b)
              {
                  // code block;
              }

              instead of:

              if (a + b) {
                  // code block;
              }

              Sometimes I slip back to Hungarian notation for controls and variables, but I usually catch myself early enough to adjust the source accordingly. :-\ Flynn

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

              Flynn Arrowstarr / Regular Schmoe wrote:

              In a professional setting, you should use your company's coding standards to draw the line. If they don't have one, work with the team to develop one you like.

              :laugh: :laugh: :laugh: I'd like to introduce you to my friend Bugfree the flying pig; he shares a cube (specifically a space adjacent to the back wall) with me and is, among other things, in charge of the coding standard development project. The first draft is expected on the 32nd of never. :sigh:

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

              F 1 Reply Last reply
              0
              • D Dan Neely

                Flynn Arrowstarr / Regular Schmoe wrote:

                In a professional setting, you should use your company's coding standards to draw the line. If they don't have one, work with the team to develop one you like.

                :laugh: :laugh: :laugh: I'd like to introduce you to my friend Bugfree the flying pig; he shares a cube (specifically a space adjacent to the back wall) with me and is, among other things, in charge of the coding standard development project. The first draft is expected on the 32nd of never. :sigh:

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

                F Offline
                F Offline
                Flynn Arrowstarr Regular Schmoe
                wrote on last edited by
                #8

                I hear you. That's why I'm glad I only code for me. I can keep to my standards and not want to strangle the people around me. :laugh: Flynn

                D 1 Reply Last reply
                0
                • J Jeremy Hutchinson

                  I generally don't mess with style unless it is totally messed up. In which case I check-out, reformat the whole document, check in with the comment that all I did was reformat. Then on with code changes. As a general rule though all code should be formatted in the default style within VS. The real formatting issues here are in the SQL stored procedures where we seem to have many distinctly different styles to the point where you can tell who wrote what by the way it's formatted. I've tried to get people to standardize on any of the formats, but have so far received no support on that. If only there was a tool that did as good of a job formatting SQL as VS does with C# code.

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

                  Yeah, were I to force a standard I'd probably go with resharpers (combined with getting all .net devs a copy of it); the only place I'm aware of it not matching with what VS does automatically in C# is that it wants to eat the _ in event handlers. It does add default styles for various other things (public/private/etc members); and points out chunks of unneeded code (this., superfluous casts, unneeded .ToString() calls, the verbose event handler attaching method needed in older versions of .net, etc). Stuff like that is where most of the potential changes would come from. Enforcing a consistent style across code makes it easier to read, and while not entirely what I'd've picked all the defaults are reasonable, but the initial implementation pass can easily result in a checkin with enough changes that automatically diffing past it becomes nearly impossible. One example from a file I'm doing documentation on atm is ~300 suggested changes in ~2500 lines of code (closer to 2000 if refactored to use the autoproperties not available when it was originally written). That's only from the warning (yellow) list, there're a number of lesser code cleanup items (green) but I don't know how to get a total count. Even spread across multiple checkins (remove redundant code, renames, code simplification/cleanup) something like that becomes a real mess in history.

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

                  1 Reply Last reply
                  0
                  • F Flynn Arrowstarr Regular Schmoe

                    I hear you. That's why I'm glad I only code for me. I can keep to my standards and not want to strangle the people around me. :laugh: Flynn

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

                    A decent chunk of the stuff resharper is picking on in my current code base is stuff that made perfect sense when I was writing in .net 1.1. eg intelisence didn't kick in for members unless you typed this.; so my old code is blanketed in that verbose idiom. What I'd really like would be a diff tool that would let me flag checkins to be ignored by default and be smart enough to display real code changes when crossing it. I suspect that doing so would be impossible in non-trivial cases however.

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

                    F A 2 Replies Last reply
                    0
                    • D Dan Neely

                      A decent chunk of the stuff resharper is picking on in my current code base is stuff that made perfect sense when I was writing in .net 1.1. eg intelisence didn't kick in for members unless you typed this.; so my old code is blanketed in that verbose idiom. What I'd really like would be a diff tool that would let me flag checkins to be ignored by default and be smart enough to display real code changes when crossing it. I suspect that doing so would be impossible in non-trivial cases however.

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

                      F Offline
                      F Offline
                      Flynn Arrowstarr Regular Schmoe
                      wrote on last edited by
                      #11

                      Dan Neely wrote:

                      What I'd really like would be a diff tool that would let me flag checkins to be ignored by default and be smart enough to display real code changes when crossing it. I suspect that doing so would be impossible in non-trivial cases however.

                      I suspect you may be right. Flynn

                      1 Reply Last reply
                      0
                      • F Flynn Arrowstarr Regular Schmoe

                        In a professional setting, you should use your company's coding standards to draw the line. If they don't have one, work with the team to develop one you like. As a hobbyist, I tend to use the SharpDevelop Guidelines (PDF)[^]. About the only thing I change is I always put a brace on a newline instead of only on classes and interfaces. So, my typical if/then statement would be:

                        if (a + b)
                        {
                            // code block;
                        }

                        instead of:

                        if (a + b) {
                            // code block;
                        }

                        Sometimes I slip back to Hungarian notation for controls and variables, but I usually catch myself early enough to adjust the source accordingly. :-\ Flynn

                        T Offline
                        T Offline
                        Tom Delany
                        wrote on last edited by
                        #12

                        I have a co-worker who formats all his code like this:

                        if (a && b) {
                        // Code goes here
                        printf("Do something.");
                        }

                        (Notice the closing brace.) It drives me absolutely batty! :mad:

                        WE ARE DYSLEXIC OF BORG. Refutance is systile. Your a$$ will be laminated. There are 10 kinds of people in the world: People who know binary and people who don't.

                        S 1 Reply Last reply
                        0
                        • J Jeremy Hutchinson

                          I generally don't mess with style unless it is totally messed up. In which case I check-out, reformat the whole document, check in with the comment that all I did was reformat. Then on with code changes. As a general rule though all code should be formatted in the default style within VS. The real formatting issues here are in the SQL stored procedures where we seem to have many distinctly different styles to the point where you can tell who wrote what by the way it's formatted. I've tried to get people to standardize on any of the formats, but have so far received no support on that. If only there was a tool that did as good of a job formatting SQL as VS does with C# code.

                          T Offline
                          T Offline
                          Tom Delany
                          wrote on last edited by
                          #13

                          Jeremy Hutchinson wrote:

                          As a general rule though all code should be formatted in the default style within VS.

                          Amen! :thumbsup:

                          WE ARE DYSLEXIC OF BORG. Refutance is systile. Your a$$ will be laminated. There are 10 kinds of people in the world: People who know binary and people who don't.

                          1 Reply Last reply
                          0
                          • T thrakazog

                            If I can read the code and understand it whatever style is fine. I don't care about casing or variable names. I've seen some people blow a gasket over naming conventions and such. To me it's just not that important. What the code is doing matters. How it looks, not so much.

                            P Offline
                            P Offline
                            PIEBALDconsult
                            wrote on last edited by
                            #14

                            I'll second that; I've been maintaining a puddle of pooh (in VB.net no less) for the last year. I try to only fix bugs, not style.

                            1 Reply Last reply
                            0
                            • D Dan Neely

                              A decent chunk of the stuff resharper is picking on in my current code base is stuff that made perfect sense when I was writing in .net 1.1. eg intelisence didn't kick in for members unless you typed this.; so my old code is blanketed in that verbose idiom. What I'd really like would be a diff tool that would let me flag checkins to be ignored by default and be smart enough to display real code changes when crossing it. I suspect that doing so would be impossible in non-trivial cases however.

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

                              A Offline
                              A Offline
                              adudley256
                              wrote on last edited by
                              #15

                              Maybe it could compile the code, and run through some variables and expected output for the changed methods. If the outputs change from known input/output set that was ran 'last time' the code was checked in, then the code has changed, otherwise the code just 'looks different'. hmm, an actual reason to bother with unit testing...... ---------------------------------------------------------------------- Get super cheap unlimited backup for 5 computers with this 'special' link: http://www.lushbackup.com?refid=matesrates[^]

                              U 1 Reply Last reply
                              0
                              • T Tom Delany

                                I have a co-worker who formats all his code like this:

                                if (a && b) {
                                // Code goes here
                                printf("Do something.");
                                }

                                (Notice the closing brace.) It drives me absolutely batty! :mad:

                                WE ARE DYSLEXIC OF BORG. Refutance is systile. Your a$$ will be laminated. There are 10 kinds of people in the world: People who know binary and people who don't.

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

                                You're lucky. The code I'm facing most often looks like this:

                                if ((((condition1 || condition2) && condition3) ||
                                condition4 || (condition5 && condition6 || condition7))
                                && (condition8 || condition9)) || condition10)) {
                                //some code
                                //some 2473 more if blocks or loops with similarly obfuscated conditions)
                                // some 12853 more lines of code
                                }

                                Whether or not the closing brace is aligned correctly does not matter at all, becasue having to scroll over several 1000 lines of code utterly and completely eliminate all purpose from formatting rules.

                                1 Reply Last reply
                                0
                                • D Dan Neely

                                  Beyond a certain point you cross over from something being obviously crap, to "I like style X better than style Y"; at which point the main thing you're doing becomes adding noise to your source control diffs? Does it matter if other devs are still working on it, or if it's all you now? Does having a tool like Resharper, whose utility in finding stuff the compiler warnings miss is badly degraded if it's spazzing out over style issues, affect where you draw the line? What if only part of the team has the tool?

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

                                  G Offline
                                  G Offline
                                  Gary Wheeler
                                  wrote on last edited by
                                  #17

                                  When the crap level goes past my knees, I switch from mucking out the stall myself to kicking the ass of the person responsible. If I'm already annoyed that day, it may happen sooner.

                                  Software Zen: delete this;

                                  1 Reply Last reply
                                  0
                                  • D Dan Neely

                                    Beyond a certain point you cross over from something being obviously crap, to "I like style X better than style Y"; at which point the main thing you're doing becomes adding noise to your source control diffs? Does it matter if other devs are still working on it, or if it's all you now? Does having a tool like Resharper, whose utility in finding stuff the compiler warnings miss is badly degraded if it's spazzing out over style issues, affect where you draw the line? What if only part of the team has the tool?

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

                                    R Offline
                                    R Offline
                                    R Erasmus
                                    wrote on last edited by
                                    #18

                                    Right at the start... Log a project level bug, mention the files that are affected. And the general reason... e.g. not according to coding standard, or whatever.

                                    "Program testing can be used to show the presence of bugs, but never to show their absence." << please vote!! >>

                                    1 Reply Last reply
                                    0
                                    • D Dan Neely

                                      Beyond a certain point you cross over from something being obviously crap, to "I like style X better than style Y"; at which point the main thing you're doing becomes adding noise to your source control diffs? Does it matter if other devs are still working on it, or if it's all you now? Does having a tool like Resharper, whose utility in finding stuff the compiler warnings miss is badly degraded if it's spazzing out over style issues, affect where you draw the line? What if only part of the team has the tool?

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

                                      L Offline
                                      L Offline
                                      Lost User
                                      wrote on last edited by
                                      #19

                                      Rewriting someone elses code without being specifically asked to do so is bad :)

                                      1 Reply Last reply
                                      0
                                      • D Dan Neely

                                        Beyond a certain point you cross over from something being obviously crap, to "I like style X better than style Y"; at which point the main thing you're doing becomes adding noise to your source control diffs? Does it matter if other devs are still working on it, or if it's all you now? Does having a tool like Resharper, whose utility in finding stuff the compiler warnings miss is badly degraded if it's spazzing out over style issues, affect where you draw the line? What if only part of the team has the tool?

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

                                        B Offline
                                        B Offline
                                        BrainiacV
                                        wrote on last edited by
                                        #20

                                        If the fix is simple, I generally leave it alone, but if it is not trivial, then I reformat it to make it readable. The previous programmer may have created a house of cards, if you break it, all eyes are on you. So I want the code in a form I can verify for myself that it has a chance of working and be easy to fix if it turns out there was for than madness to the previous programmer's method.

                                        Psychosis at 10 Film at 11

                                        1 Reply Last reply
                                        0
                                        • D Dan Neely

                                          Beyond a certain point you cross over from something being obviously crap, to "I like style X better than style Y"; at which point the main thing you're doing becomes adding noise to your source control diffs? Does it matter if other devs are still working on it, or if it's all you now? Does having a tool like Resharper, whose utility in finding stuff the compiler warnings miss is badly degraded if it's spazzing out over style issues, affect where you draw the line? What if only part of the team has the tool?

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

                                          P Offline
                                          P Offline
                                          patbob
                                          wrote on last edited by
                                          #21

                                          Stylistic opinions don't warrant code changes unless the entire team agrees. A team of one, or someone with the authority to dictate what they team wants, will find it easy to get agreement. If the team wants some tool to work well, and it has stylistic requirements, then they are agreeing to adhere to its stylistic requirements.

                                          patbob

                                          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