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. Would this pass code review where you are?

Would this pass code review where you are?

Scheduled Pinned Locked Moved The Lounge
csharpcomquestiondiscussioncode-review
46 Posts 34 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.
  • OriginalGriffO OriginalGriff

    I didn't write it, but ... the author thinks this is a good idea that should be allowed in C# code:

    getSeries()
    {

    if (flag == pass) goto ep;

    for i1 ...
    ...
    for i2 ...
    ...
    for i3 ...
    ...
    for i4 ...
    .
    .
    .
    for ...
    {
    ...
    return;
    ep;
    }
    }
    }
    }//last for

    }// end of getSeries()

    Me? I'm not a fan. Your thoughts - and remember this is the Lounge? :laugh:

    "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt AntiTwitter: @DalekDave is now a follower!

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

    OriginalGriff wrote:

    code review where you are

    On my current team, I'm the only one who writes "real code" -- and I definitely would not have written that. We've been required to do code reviews though... so we pretend to do code reviews of our SSIS packages. :confused:

    1 Reply Last reply
    0
    • OriginalGriffO OriginalGriff

      I didn't write it, but ... the author thinks this is a good idea that should be allowed in C# code:

      getSeries()
      {

      if (flag == pass) goto ep;

      for i1 ...
      ...
      for i2 ...
      ...
      for i3 ...
      ...
      for i4 ...
      .
      .
      .
      for ...
      {
      ...
      return;
      ep;
      }
      }
      }
      }//last for

      }// end of getSeries()

      Me? I'm not a fan. Your thoughts - and remember this is the Lounge? :laugh:

      "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt AntiTwitter: @DalekDave is now a follower!

      J Offline
      J Offline
      Jin Vincent Necesario
      wrote on last edited by
      #26

      Maybe a self code review or the code review was sent to a subordinate/junior guy or a force approval. :)

      Jim Rohn: "Don't wish it was easier, wish you were better". Subscribe to my blog @ https://jinnecesario.com/.

      1 Reply Last reply
      0
      • OriginalGriffO OriginalGriff

        I didn't write it, but ... the author thinks this is a good idea that should be allowed in C# code:

        getSeries()
        {

        if (flag == pass) goto ep;

        for i1 ...
        ...
        for i2 ...
        ...
        for i3 ...
        ...
        for i4 ...
        .
        .
        .
        for ...
        {
        ...
        return;
        ep;
        }
        }
        }
        }//last for

        }// end of getSeries()

        Me? I'm not a fan. Your thoughts - and remember this is the Lounge? :laugh:

        "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt AntiTwitter: @DalekDave is now a follower!

        Mike HankeyM Offline
        Mike HankeyM Offline
        Mike Hankey
        wrote on last edited by
        #27

        Isn't that the guy in QA that asked where to stick the goto? But I'm sure that's not where they told him to stick it.

        I'm not sure how many cookies it makes to be happy, but so far it's not 27. JaxCoder.com

        OriginalGriffO 1 Reply Last reply
        0
        • Mike HankeyM Mike Hankey

          Isn't that the guy in QA that asked where to stick the goto? But I'm sure that's not where they told him to stick it.

          I'm not sure how many cookies it makes to be happy, but so far it's not 27. JaxCoder.com

          OriginalGriffO Offline
          OriginalGriffO Offline
          OriginalGriff
          wrote on last edited by
          #28

          Yes - I'm trying to get him to see that I'm not the only one who looks at theat and sees Assembler code written in C compiled by a C++ compiler and never going to work in C# ... He thinks it's perfectly good code because it has worked since 2006. We all know that just because you can do something, it doesn't mean you should. I feel sorry for anyone who has to work for / with him - that company has to be the kiss of death for your career!

          "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt AntiTwitter: @DalekDave is now a follower!

          "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony
          "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt

          M 1 Reply Last reply
          0
          • 5 5teveH

            You need to tell the author he's in the wrong job. He needs to find something where logic and common sense isn't required. Management, maybe? ;)

            R Offline
            R Offline
            raddevus
            wrote on last edited by
            #29

            5teveH wrote:

            You need to tell the author he's in the wrong job.

            :thumbsup::thumbsup::thumbsup: :laugh:

            1 Reply Last reply
            0
            • Sander RosselS Sander Rossel

              It's this new cool style of programming named For-Oriented Programming, or FOP for short. I think I'll try it out on my next project :thumbsup:

              Best, Sander Azure Serverless Succinctly Migrating Applications to the Cloud with Azure arrgh.js - Bringing LINQ to JavaScript

              R Offline
              R Offline
              raddevus
              wrote on last edited by
              #30

              Sander Rossel wrote:

              For-Oriented Programming, or FOP

              :laugh:

              J 1 Reply Last reply
              0
              • OriginalGriffO OriginalGriff

                Yes - I'm trying to get him to see that I'm not the only one who looks at theat and sees Assembler code written in C compiled by a C++ compiler and never going to work in C# ... He thinks it's perfectly good code because it has worked since 2006. We all know that just because you can do something, it doesn't mean you should. I feel sorry for anyone who has to work for / with him - that company has to be the kiss of death for your career!

                "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt AntiTwitter: @DalekDave is now a follower!

                M Offline
                M Offline
                MarkTJohnson
                wrote on last edited by
                #31

                OriginalGriff wrote:

                We all know that just because you can do something, it doesn't mean you should.

                Make him watch Jurrasic Park. Again. Like Malcom McDowell in Clockwork Orange.

                I’ve given up trying to be calm. However, I am open to feeling slightly less agitated.

                1 Reply Last reply
                0
                • OriginalGriffO OriginalGriff

                  I didn't write it, but ... the author thinks this is a good idea that should be allowed in C# code:

                  getSeries()
                  {

                  if (flag == pass) goto ep;

                  for i1 ...
                  ...
                  for i2 ...
                  ...
                  for i3 ...
                  ...
                  for i4 ...
                  .
                  .
                  .
                  for ...
                  {
                  ...
                  return;
                  ep;
                  }
                  }
                  }
                  }//last for

                  }// end of getSeries()

                  Me? I'm not a fan. Your thoughts - and remember this is the Lounge? :laugh:

                  "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt AntiTwitter: @DalekDave is now a follower!

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

                  We don't do code reviews where I work. Go ahead, keep throwing up; I'll wait. 1. I don't like the goto. I know some folks like them for error exit handling when you're not using exceptions, but I'm not one of them. 2. If the ep symbol is intended to be a label, it's certainly poorly placed. 3. There's nothing inherently wrong in the numerous nested for loops. It depends upon their purpose. 3.1. If the nested loops are simple indices in multi-dimensional data performing a simple task, it might be the most concise way to accomplish that task. Adding layers of abstraction to remove the nesting might complicate the logic unnecessarily, especially if that's the only reason for adding the layer. 3.2. If 3.1 is not the case, the loops are certainly a code smell since they imply accessing multiple levels of detail from a single scope. 3.3. The iteration values i1, i2, etc. are poorly named. 4. I also don't like the return embedded in the loops. I don't have a problem using break or continue to exit a loop early, but that keeps the range of the 'goto' to the body of the loop, making control flow analysis simpler.

                  Software Zen: delete this;

                  1 Reply Last reply
                  0
                  • OriginalGriffO OriginalGriff

                    I didn't write it, but ... the author thinks this is a good idea that should be allowed in C# code:

                    getSeries()
                    {

                    if (flag == pass) goto ep;

                    for i1 ...
                    ...
                    for i2 ...
                    ...
                    for i3 ...
                    ...
                    for i4 ...
                    .
                    .
                    .
                    for ...
                    {
                    ...
                    return;
                    ep;
                    }
                    }
                    }
                    }//last for

                    }// end of getSeries()

                    Me? I'm not a fan. Your thoughts - and remember this is the Lounge? :laugh:

                    "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt AntiTwitter: @DalekDave is now a follower!

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

                    OriginalGriff wrote:

                    Your thoughts

                    The label 'ep' probably means exit point. The only thing I can think of is that the author is following the single-entry single-exit[^] code standard. I've worked on teams that tried to adhere to this policy. I've had some of my code rejected by reviewers with the reason of: "Refactor to single exit". That code is in your operating system. Best Wishes, -David Delaune

                    1 Reply Last reply
                    0
                    • OriginalGriffO OriginalGriff

                      I didn't write it, but ... the author thinks this is a good idea that should be allowed in C# code:

                      getSeries()
                      {

                      if (flag == pass) goto ep;

                      for i1 ...
                      ...
                      for i2 ...
                      ...
                      for i3 ...
                      ...
                      for i4 ...
                      .
                      .
                      .
                      for ...
                      {
                      ...
                      return;
                      ep;
                      }
                      }
                      }
                      }//last for

                      }// end of getSeries()

                      Me? I'm not a fan. Your thoughts - and remember this is the Lounge? :laugh:

                      "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt AntiTwitter: @DalekDave is now a follower!

                      R Offline
                      R Offline
                      Rick York
                      wrote on last edited by
                      #34

                      We don't have code reviews but I would have one with the group just to point out how horrendous that is.

                      "They have a consciousness, they have a life, they have a soul! Damn you! Let the rabbits wear glasses! Save our brothers! Can I get an amen?"

                      1 Reply Last reply
                      0
                      • OriginalGriffO OriginalGriff

                        I didn't write it, but ... the author thinks this is a good idea that should be allowed in C# code:

                        getSeries()
                        {

                        if (flag == pass) goto ep;

                        for i1 ...
                        ...
                        for i2 ...
                        ...
                        for i3 ...
                        ...
                        for i4 ...
                        .
                        .
                        .
                        for ...
                        {
                        ...
                        return;
                        ep;
                        }
                        }
                        }
                        }//last for

                        }// end of getSeries()

                        Me? I'm not a fan. Your thoughts - and remember this is the Lounge? :laugh:

                        "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt AntiTwitter: @DalekDave is now a follower!

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

                        Commenting the ending brace shows potential.

                        It was only in wine that he laid down no limit for himself, but he did not allow himself to be confused by it. ― Confucian Analects: Rules of Confucius about his food

                        1 Reply Last reply
                        0
                        • R raddevus

                          Sander Rossel wrote:

                          For-Oriented Programming, or FOP

                          :laugh:

                          J Offline
                          J Offline
                          jsc42
                          wrote on last edited by
                          #36

                          raddevus wrote:

                          Sander Rossel wrote:

                          For-Oriented Programming, or FOP

                          Or For Loop Oriented Programming - guaranteed to be a complete FLOP (Yes, I know FLOPS is already an acronym in computing for Floating Point Operations Per Second).

                          1 Reply Last reply
                          0
                          • 5 5teveH

                            You need to tell the author he's in the wrong job. He needs to find something where logic and common sense isn't required. Management, maybe? ;)

                            J Offline
                            J Offline
                            John Torjo
                            wrote on last edited by
                            #37

                            He would probably ace politics...

                            1 Reply Last reply
                            0
                            • OriginalGriffO OriginalGriff

                              I didn't write it, but ... the author thinks this is a good idea that should be allowed in C# code:

                              getSeries()
                              {

                              if (flag == pass) goto ep;

                              for i1 ...
                              ...
                              for i2 ...
                              ...
                              for i3 ...
                              ...
                              for i4 ...
                              .
                              .
                              .
                              for ...
                              {
                              ...
                              return;
                              ep;
                              }
                              }
                              }
                              }//last for

                              }// end of getSeries()

                              Me? I'm not a fan. Your thoughts - and remember this is the Lounge? :laugh:

                              "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt AntiTwitter: @DalekDave is now a follower!

                              D Offline
                              D Offline
                              Davyd McColl
                              wrote on last edited by
                              #38

                              No, simply for nesting / length. I'm sure well-named functions could be pulled out, which would decrease the cognitive load on the reader, especially someone new to the code, which includes the original author in about a month or two.

                              ------------------------------------------------ If you say that getting the money is the most important thing You will spend your life completely wasting your time You will be doing things you don't like doing In order to go on living That is, to go on doing things you don't like doing Which is stupid. - Alan Watts https://www.youtube.com/watch?v=-gXTZM\_uPMY

                              1 Reply Last reply
                              0
                              • OriginalGriffO OriginalGriff

                                I didn't write it, but ... the author thinks this is a good idea that should be allowed in C# code:

                                getSeries()
                                {

                                if (flag == pass) goto ep;

                                for i1 ...
                                ...
                                for i2 ...
                                ...
                                for i3 ...
                                ...
                                for i4 ...
                                .
                                .
                                .
                                for ...
                                {
                                ...
                                return;
                                ep;
                                }
                                }
                                }
                                }//last for

                                }// end of getSeries()

                                Me? I'm not a fan. Your thoughts - and remember this is the Lounge? :laugh:

                                "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt AntiTwitter: @DalekDave is now a follower!

                                M Offline
                                M Offline
                                Martin ISDN
                                wrote on last edited by
                                #39

                                Pascal, for instance, will not allow you to hyperspace into a scope like that. for good reason. the only useful scenario for this "technique" is where you have the expressions after the closing brace of the inner loops. that way either you execute all the looping which creates some multi dimensional computation or you jump with goto inside the most inner loop and execute a liner computation, once for every loop. but, in this case i fail to comprehend the reason for jumping at the tail of the loops. equally puzzled by the most inner return. this looks like is some kind of a trick interview question... it would be interesting to know what is the purpose of this "device"?

                                1 Reply Last reply
                                0
                                • OriginalGriffO OriginalGriff

                                  I didn't write it, but ... the author thinks this is a good idea that should be allowed in C# code:

                                  getSeries()
                                  {

                                  if (flag == pass) goto ep;

                                  for i1 ...
                                  ...
                                  for i2 ...
                                  ...
                                  for i3 ...
                                  ...
                                  for i4 ...
                                  .
                                  .
                                  .
                                  for ...
                                  {
                                  ...
                                  return;
                                  ep;
                                  }
                                  }
                                  }
                                  }//last for

                                  }// end of getSeries()

                                  Me? I'm not a fan. Your thoughts - and remember this is the Lounge? :laugh:

                                  "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt AntiTwitter: @DalekDave is now a follower!

                                  M Offline
                                  M Offline
                                  Myron Dombrowski
                                  wrote on last edited by
                                  #40

                                  In four words: nope.

                                  1 Reply Last reply
                                  0
                                  • OriginalGriffO OriginalGriff

                                    I didn't write it, but ... the author thinks this is a good idea that should be allowed in C# code:

                                    getSeries()
                                    {

                                    if (flag == pass) goto ep;

                                    for i1 ...
                                    ...
                                    for i2 ...
                                    ...
                                    for i3 ...
                                    ...
                                    for i4 ...
                                    .
                                    .
                                    .
                                    for ...
                                    {
                                    ...
                                    return;
                                    ep;
                                    }
                                    }
                                    }
                                    }//last for

                                    }// end of getSeries()

                                    Me? I'm not a fan. Your thoughts - and remember this is the Lounge? :laugh:

                                    "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt AntiTwitter: @DalekDave is now a follower!

                                    B Offline
                                    B Offline
                                    Bruce Patin
                                    wrote on last edited by
                                    #41

                                    That was my very first program in the 1960s. It was a FORTRAN loop to calculate Chess moves. My Dad punched it into cards and had it evaluated, and said it would take more years to compute than there are stars in the Universe.

                                    1 Reply Last reply
                                    0
                                    • OriginalGriffO OriginalGriff

                                      I didn't write it, but ... the author thinks this is a good idea that should be allowed in C# code:

                                      getSeries()
                                      {

                                      if (flag == pass) goto ep;

                                      for i1 ...
                                      ...
                                      for i2 ...
                                      ...
                                      for i3 ...
                                      ...
                                      for i4 ...
                                      .
                                      .
                                      .
                                      for ...
                                      {
                                      ...
                                      return;
                                      ep;
                                      }
                                      }
                                      }
                                      }//last for

                                      }// end of getSeries()

                                      Me? I'm not a fan. Your thoughts - and remember this is the Lounge? :laugh:

                                      "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt AntiTwitter: @DalekDave is now a follower!

                                      N Offline
                                      N Offline
                                      NightPen
                                      wrote on last edited by
                                      #42

                                      In my career, I actually had to review a piece of code similar to this. My approach was to turn the code review into a teaching moment. I had the developer explain the problem they were trying to solve, what solutions they considered and why they chose this one. The developer ended up reworking the code and produced a much-improved solution. More importantly, though the developer never sent code like this in for code review again.

                                      1 Reply Last reply
                                      0
                                      • OriginalGriffO OriginalGriff

                                        I didn't write it, but ... the author thinks this is a good idea that should be allowed in C# code:

                                        getSeries()
                                        {

                                        if (flag == pass) goto ep;

                                        for i1 ...
                                        ...
                                        for i2 ...
                                        ...
                                        for i3 ...
                                        ...
                                        for i4 ...
                                        .
                                        .
                                        .
                                        for ...
                                        {
                                        ...
                                        return;
                                        ep;
                                        }
                                        }
                                        }
                                        }//last for

                                        }// end of getSeries()

                                        Me? I'm not a fan. Your thoughts - and remember this is the Lounge? :laugh:

                                        "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony "Common sense is so rare these days, it should be classified as a super power" - Random T-shirt AntiTwitter: @DalekDave is now a follower!

                                        F Offline
                                        F Offline
                                        Fabio Franco
                                        wrote on last edited by
                                        #43

                                        Not sure what I find worse, the amount of nested for's or the use of goto.

                                        To alcohol! The cause of, and solution to, all of life's problems - Homer Simpson ---- Our heads are round so our thoughts can change direction - Francis Picabia

                                        1 Reply Last reply
                                        0
                                        • realJSOPR realJSOP

                                          Without knowing the range of the for loops, and how many there are, I wouldn't recommend recursion, because it might overflow the stack.

                                          ".45 ACP - because shooting twice is just silly" - JSOP, 2010
                                          -----
                                          You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010
                                          -----
                                          When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013

                                          F Offline
                                          F Offline
                                          Fabio Franco
                                          wrote on last edited by
                                          #44

                                          Are you being ironic? Or do you actually think it's better to use nested fors explicitly, instead of passing a depth limit as a parameter of a recursive function?

                                          To alcohol! The cause of, and solution to, all of life's problems - Homer Simpson ---- Our heads are round so our thoughts can change direction - Francis Picabia

                                          realJSOPR 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