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. Other Discussions
  3. The Weird and The Wonderful
  4. Sigh

Sigh

Scheduled Pinned Locked Moved The Weird and The Wonderful
pythoncomcode-reviewlearning
10 Posts 7 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.
  • M Offline
    M Offline
    Marc Clifton
    wrote on last edited by
    #1

    for (int i = 0; i < foo.Length; i++)
    {
    addFlag = true;
    if (oldFoo != null)
    {
    for (int j = 0; j < oldFoo.Length; j++)
    {
    if (foo[i].Guid == oldFoo[j].Guid)
    {
    addFlag = false;
    }
    }
    }
    if (addFlag)
    {
    newFooList.Add(foo[i]);
    }
    }

    I should start holding code review classes with "WTF is wrong with this pyle of shyte". Marc

    V.A.P.O.R.ware - Visual Assisted Programming / Organizational Representation Learning to code with python is like learning to swim with those little arm floaties. It gives you undeserved confidence and will eventually drown you. - DangerBunny Artificial intelligence is the only remedy for natural stupidity. - CDP1802

    L K A P J 6 Replies Last reply
    0
    • M Marc Clifton

      for (int i = 0; i < foo.Length; i++)
      {
      addFlag = true;
      if (oldFoo != null)
      {
      for (int j = 0; j < oldFoo.Length; j++)
      {
      if (foo[i].Guid == oldFoo[j].Guid)
      {
      addFlag = false;
      }
      }
      }
      if (addFlag)
      {
      newFooList.Add(foo[i]);
      }
      }

      I should start holding code review classes with "WTF is wrong with this pyle of shyte". Marc

      V.A.P.O.R.ware - Visual Assisted Programming / Organizational Representation Learning to code with python is like learning to swim with those little arm floaties. It gives you undeserved confidence and will eventually drown you. - DangerBunny Artificial intelligence is the only remedy for natural stupidity. - CDP1802

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

      Marc Clifton wrote:

      I should start holding code review classes with "WTF is wrong with this pyle of shyte".

      Too much accolades, right? I also added another for-loop, since you were going through the items in the wrong order.

      for ( 0; d++)
      if (foo[i].Guid == oldFoo[j].Guid)
      addFlag = false;

      if (addFlag)
      newFooList.Add(foo[i]);
      }

      Semantically also incorrect, since "addFlag" is unknown at the start. The code should reflect that by using a nullable bool that is set to nothing. That way, you could determine (if an exception occurs) if the bool is unknown, true, or not very true. :rolleyes:

      Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^][](X-Clacks-Overhead: GNU Terry Pratchett)

      M B 2 Replies Last reply
      0
      • M Marc Clifton

        for (int i = 0; i < foo.Length; i++)
        {
        addFlag = true;
        if (oldFoo != null)
        {
        for (int j = 0; j < oldFoo.Length; j++)
        {
        if (foo[i].Guid == oldFoo[j].Guid)
        {
        addFlag = false;
        }
        }
        }
        if (addFlag)
        {
        newFooList.Add(foo[i]);
        }
        }

        I should start holding code review classes with "WTF is wrong with this pyle of shyte". Marc

        V.A.P.O.R.ware - Visual Assisted Programming / Organizational Representation Learning to code with python is like learning to swim with those little arm floaties. It gives you undeserved confidence and will eventually drown you. - DangerBunny Artificial intelligence is the only remedy for natural stupidity. - CDP1802

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

        Dont't blame the people, try to help them :-D If I Review some of my 30 year old code, a lot of time I'm asking me if I would know the guy who wrote this s**t :laugh: [Edit] The same happens also with code I wrote just before some days :-O

        M 1 Reply Last reply
        0
        • L Lost User

          Dont't blame the people, try to help them :-D If I Review some of my 30 year old code, a lot of time I'm asking me if I would know the guy who wrote this s**t :laugh: [Edit] The same happens also with code I wrote just before some days :-O

          M Offline
          M Offline
          Marc Clifton
          wrote on last edited by
          #4

          0x01AA wrote:

          Dont't blame the people, try to help them

          They're no longer here and were in India.

          0x01AA wrote:

          If I Review some of my 30 year old code, a lot of time I'm asking me if I would know the guy who wrote this s**t

          A client is still using code I wrote in C++ 25 years ago. I grimace every time I see DataMatrix, basically the .NET version of DataTable. Marc

          V.A.P.O.R.ware - Visual Assisted Programming / Organizational Representation Learning to code with python is like learning to swim with those little arm floaties. It gives you undeserved confidence and will eventually drown you. - DangerBunny Artificial intelligence is the only remedy for natural stupidity. - CDP1802

          1 Reply Last reply
          0
          • L Lost User

            Marc Clifton wrote:

            I should start holding code review classes with "WTF is wrong with this pyle of shyte".

            Too much accolades, right? I also added another for-loop, since you were going through the items in the wrong order.

            for ( 0; d++)
            if (foo[i].Guid == oldFoo[j].Guid)
            addFlag = false;

            if (addFlag)
            newFooList.Add(foo[i]);
            }

            Semantically also incorrect, since "addFlag" is unknown at the start. The code should reflect that by using a nullable bool that is set to nothing. That way, you could determine (if an exception occurs) if the bool is unknown, true, or not very true. :rolleyes:

            Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^][](X-Clacks-Overhead: GNU Terry Pratchett)

            M Offline
            M Offline
            Marc Clifton
            wrote on last edited by
            #5

            Eddy Vluggen wrote:

            for (int d = oldFoo.Length; d > 0; d++)

            There's at least 3 bugs in that one line! ;) Marc

            V.A.P.O.R.ware - Visual Assisted Programming / Organizational Representation Learning to code with python is like learning to swim with those little arm floaties. It gives you undeserved confidence and will eventually drown you. - DangerBunny Artificial intelligence is the only remedy for natural stupidity. - CDP1802

            1 Reply Last reply
            0
            • L Lost User

              Marc Clifton wrote:

              I should start holding code review classes with "WTF is wrong with this pyle of shyte".

              Too much accolades, right? I also added another for-loop, since you were going through the items in the wrong order.

              for ( 0; d++)
              if (foo[i].Guid == oldFoo[j].Guid)
              addFlag = false;

              if (addFlag)
              newFooList.Add(foo[i]);
              }

              Semantically also incorrect, since "addFlag" is unknown at the start. The code should reflect that by using a nullable bool that is set to nothing. That way, you could determine (if an exception occurs) if the bool is unknown, true, or not very true. :rolleyes:

              Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^][](X-Clacks-Overhead: GNU Terry Pratchett)

              B Offline
              B Offline
              Bernhard Hiller
              wrote on last edited by
              #6

              You can improve performance by adding a ";" after "for (int d = oldFoo.Length; d > 0; d++)". But I guess a smart guy like you introduced this possibility for exactly that purpose. Let's hope the compiler did not detect that and optimized it away... :-D

              1 Reply Last reply
              0
              • M Marc Clifton

                for (int i = 0; i < foo.Length; i++)
                {
                addFlag = true;
                if (oldFoo != null)
                {
                for (int j = 0; j < oldFoo.Length; j++)
                {
                if (foo[i].Guid == oldFoo[j].Guid)
                {
                addFlag = false;
                }
                }
                }
                if (addFlag)
                {
                newFooList.Add(foo[i]);
                }
                }

                I should start holding code review classes with "WTF is wrong with this pyle of shyte". Marc

                V.A.P.O.R.ware - Visual Assisted Programming / Organizational Representation Learning to code with python is like learning to swim with those little arm floaties. It gives you undeserved confidence and will eventually drown you. - DangerBunny Artificial intelligence is the only remedy for natural stupidity. - CDP1802

                K Offline
                K Offline
                KarstenK
                wrote on last edited by
                #7

                The answer is: YES "Share your wisdom and enlight the clueless". It is good for your karma :-O

                Press F1 for help or google it. Greetings from Germany

                1 Reply Last reply
                0
                • M Marc Clifton

                  for (int i = 0; i < foo.Length; i++)
                  {
                  addFlag = true;
                  if (oldFoo != null)
                  {
                  for (int j = 0; j < oldFoo.Length; j++)
                  {
                  if (foo[i].Guid == oldFoo[j].Guid)
                  {
                  addFlag = false;
                  }
                  }
                  }
                  if (addFlag)
                  {
                  newFooList.Add(foo[i]);
                  }
                  }

                  I should start holding code review classes with "WTF is wrong with this pyle of shyte". Marc

                  V.A.P.O.R.ware - Visual Assisted Programming / Organizational Representation Learning to code with python is like learning to swim with those little arm floaties. It gives you undeserved confidence and will eventually drown you. - DangerBunny Artificial intelligence is the only remedy for natural stupidity. - CDP1802

                  A Offline
                  A Offline
                  AnvilRanger
                  wrote on last edited by
                  #8

                  And the answer to your question would be, but I found it on stackoverflow.

                  1 Reply Last reply
                  0
                  • M Marc Clifton

                    for (int i = 0; i < foo.Length; i++)
                    {
                    addFlag = true;
                    if (oldFoo != null)
                    {
                    for (int j = 0; j < oldFoo.Length; j++)
                    {
                    if (foo[i].Guid == oldFoo[j].Guid)
                    {
                    addFlag = false;
                    }
                    }
                    }
                    if (addFlag)
                    {
                    newFooList.Add(foo[i]);
                    }
                    }

                    I should start holding code review classes with "WTF is wrong with this pyle of shyte". Marc

                    V.A.P.O.R.ware - Visual Assisted Programming / Organizational Representation Learning to code with python is like learning to swim with those little arm floaties. It gives you undeserved confidence and will eventually drown you. - DangerBunny Artificial intelligence is the only remedy for natural stupidity. - CDP1802

                    P Offline
                    P Offline
                    Plamen Dragiyski
                    wrote on last edited by
                    #9

                    You cannot see the deeper meaning here. It is not user-friendly to make it too efficient[^].

                    1 Reply Last reply
                    0
                    • M Marc Clifton

                      for (int i = 0; i < foo.Length; i++)
                      {
                      addFlag = true;
                      if (oldFoo != null)
                      {
                      for (int j = 0; j < oldFoo.Length; j++)
                      {
                      if (foo[i].Guid == oldFoo[j].Guid)
                      {
                      addFlag = false;
                      }
                      }
                      }
                      if (addFlag)
                      {
                      newFooList.Add(foo[i]);
                      }
                      }

                      I should start holding code review classes with "WTF is wrong with this pyle of shyte". Marc

                      V.A.P.O.R.ware - Visual Assisted Programming / Organizational Representation Learning to code with python is like learning to swim with those little arm floaties. It gives you undeserved confidence and will eventually drown you. - DangerBunny Artificial intelligence is the only remedy for natural stupidity. - CDP1802

                      J Offline
                      J Offline
                      JackPeacock
                      wrote on last edited by
                      #10

                      This is why we need faster and faster processors. Think of it as price support for Intel.

                      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