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. Seriously?

Seriously?

Scheduled Pinned Locked Moved The Lounge
csharppythoncsscomquestion
30 Posts 20 Posters 1 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.
  • R Ravi Bhavnani

    I like the optimistic (and useless) initialization of port in this snippet. :)

    int port = 4401;
        Int32.TryParse(strPort, out port);
        peer.EndPoint = new IPEndPoint(address, port);

    /ravi

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

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

    I'm fine with that. When debugging, you might want to skip over the call to TryParse yet have a valid value in Port.

    R Sander RosselS 2 Replies Last reply
    0
    • P PIEBALDconsult

      I'm fine with that. When debugging, you might want to skip over the call to TryParse yet have a valid value in Port.

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

      PIEBALDconsult wrote:

      When debugging, you might want to skip over the call to TryParse yet have a valid value in Port.

      In that case I would #if DEBUG it. The way it's written implies the developer assumes port will have the value 4401 if the Int32.TryParse() fails. /ravi

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

      P 1 Reply Last reply
      0
      • R Ravi Bhavnani

        PIEBALDconsult wrote:

        When debugging, you might want to skip over the call to TryParse yet have a valid value in Port.

        In that case I would #if DEBUG it. The way it's written implies the developer assumes port will have the value 4401 if the Int32.TryParse() fails. /ravi

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

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

        Ravi Bhavnani wrote:

        implies the developer assumes

        I disagree.

        1 Reply Last reply
        0
        • K kmoorevs

          Is it a Spanish compiler? :laugh:

          "Go forth into the source" - Neal Morse

          N Offline
          N Offline
          Nelek
          wrote on last edited by
          #12

          kmoorevs wrote:

          Is it a Spanish compiler?

          And why should that be funny?

          M.D.V. ;) If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about? Help me to understand what I'm saying, and I'll explain it better to you Rating helpful answers is nice, but saying thanks can be even nicer.

          I 1 Reply Last reply
          0
          • M Marc Clifton

            public int Lenght
            {
            get { return this.Lenght; }
            }

            [Code from here](https://github.com/AdunanzA/Evolution-DHT/blob/master/Evolution.Dht/Kademlia/BucketList.cs) :sigh: :doh: :rolleyes: :omg: :wtf: X| :thumbsdown: Maybe that's how I should sign posts. :laugh:

            Latest Article - Class-less Coding - Minimalist C# and Why F# and Function Programming Has Some Advantages 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

            W Offline
            W Offline
            W Balboos GHB
            wrote on last edited by
            #13

            Well, since that's the wrong spelling for 'length' it's safe to assume it will only be called by an error - so if it recalls itself until it crashes, nothing's really been lost, anyway. Thus, the balance is restored in this, the best of all possible worlds.

            Ravings en masse^

            "The difference between genius and stupidity is that genius has its limits." - Albert Einstein

            "If you are searching for perfection in others, then you seek disappointment. If you are seek perfection in yourself, then you will find failure." - Balboos HaGadol Mar 2010

            C 1 Reply Last reply
            0
            • P PIEBALDconsult

              I'm fine with that. When debugging, you might want to skip over the call to TryParse yet have a valid value in Port.

              Sander RosselS Offline
              Sander RosselS Offline
              Sander Rossel
              wrote on last edited by
              #14

              You can manually set values for variables while debugging C#, so initialization isn't necessary (but convenient nonetheless, although I'd remove it when done debugging) :)

              Best, Sander arrgh.js - Bringing LINQ to JavaScript SQL Server for C# Developers Succinctly Object-Oriented Programming in C# Succinctly

              P 1 Reply Last reply
              0
              • M Marc Clifton

                public int Lenght
                {
                get { return this.Lenght; }
                }

                [Code from here](https://github.com/AdunanzA/Evolution-DHT/blob/master/Evolution.Dht/Kademlia/BucketList.cs) :sigh: :doh: :rolleyes: :omg: :wtf: X| :thumbsdown: Maybe that's how I should sign posts. :laugh:

                Latest Article - Class-less Coding - Minimalist C# and Why F# and Function Programming Has Some Advantages 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

                Sander RosselS Offline
                Sander RosselS Offline
                Sander Rossel
                wrote on last edited by
                #15

                BucketList: 1. Learn how to write code. 2. Improve this code. 3. Climb the Mount Everest.

                Best, Sander arrgh.js - Bringing LINQ to JavaScript SQL Server for C# Developers Succinctly Object-Oriented Programming in C# Succinctly

                P 1 Reply Last reply
                0
                • Sander RosselS Sander Rossel

                  You can manually set values for variables while debugging C#, so initialization isn't necessary (but convenient nonetheless, although I'd remove it when done debugging) :)

                  Best, Sander arrgh.js - Bringing LINQ to JavaScript SQL Server for C# Developers Succinctly Object-Oriented Programming in C# Succinctly

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

                  Sure, but why not simply code the value you want?

                  1 Reply Last reply
                  0
                  • Sander RosselS Sander Rossel

                    BucketList: 1. Learn how to write code. 2. Improve this code. 3. Climb the Mount Everest.

                    Best, Sander arrgh.js - Bringing LINQ to JavaScript SQL Server for C# Developers Succinctly Object-Oriented Programming in C# Succinctly

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

                    4. Stay there, not bothering anybody.

                    Sander RosselS 1 Reply Last reply
                    0
                    • P PIEBALDconsult

                      4. Stay there, not bothering anybody.

                      Sander RosselS Offline
                      Sander RosselS Offline
                      Sander Rossel
                      wrote on last edited by
                      #18

                      A lot of people should add that to their list :laugh:

                      Best, Sander arrgh.js - Bringing LINQ to JavaScript SQL Server for C# Developers Succinctly Object-Oriented Programming in C# Succinctly

                      1 Reply Last reply
                      0
                      • J Jochen Arndt

                        That was my first thought: It should generate a stack overflow (regardless of the language). I'm not so skillfull with C# but recent C++ compilers will throw a warning for such code. And I guess the C# compiler will do that too (both with higher warning level). Then they did not even test their code but compile it also with a low warning level.

                        realJSOPR Offline
                        realJSOPR Offline
                        realJSOP
                        wrote on last edited by
                        #19

                        This usually happens by accident when they implement the property before defining the accompanying field. It's happened to me a couple of times. I compile at the highest warning level and VS2013 doesn't catch this error at compile time.A "self-referencing property" compile-time warning would be nice to have.

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

                        1 Reply Last reply
                        0
                        • M Marc Clifton

                          public int Lenght
                          {
                          get { return this.Lenght; }
                          }

                          [Code from here](https://github.com/AdunanzA/Evolution-DHT/blob/master/Evolution.Dht/Kademlia/BucketList.cs) :sigh: :doh: :rolleyes: :omg: :wtf: X| :thumbsdown: Maybe that's how I should sign posts. :laugh:

                          Latest Article - Class-less Coding - Minimalist C# and Why F# and Function Programming Has Some Advantages 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
                          #20

                          isnt that a recursive call which should crash the stack :confused:

                          Press F1 for help or google it. Greetings from Germany

                          M 1 Reply Last reply
                          0
                          • K KarstenK

                            isnt that a recursive call which should crash the stack :confused:

                            Press F1 for help or google it. Greetings from Germany

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

                            KarstenK wrote:

                            isnt that a recursive call which should crash the stack

                            Exactly.

                            Latest Article - Class-less Coding - Minimalist C# and Why F# and Function Programming Has Some Advantages 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
                            • N Nelek

                              kmoorevs wrote:

                              Is it a Spanish compiler?

                              And why should that be funny?

                              M.D.V. ;) If something has a solution... Why do we have to worry about?. If it has no solution... For what reason do we have to worry about? Help me to understand what I'm saying, and I'll explain it better to you Rating helpful answers is nice, but saying thanks can be even nicer.

                              I Offline
                              I Offline
                              iskSYS
                              wrote on last edited by
                              #22

                              There was a video by Veritasium, on how Spanish needs more or less double the words in order to convey the same amount of information, compared to English. Relate the video to the fact that the 'get length' appeared to have been written twice, you get a joke. Well it's funny now that I had to explain everything but nonetheless, nice effort kmoorevs.

                              1 Reply Last reply
                              0
                              • W W Balboos GHB

                                Well, since that's the wrong spelling for 'length' it's safe to assume it will only be called by an error - so if it recalls itself until it crashes, nothing's really been lost, anyway. Thus, the balance is restored in this, the best of all possible worlds.

                                Ravings en masse^

                                "The difference between genius and stupidity is that genius has its limits." - Albert Einstein

                                "If you are searching for perfection in others, then you seek disappointment. If you are seek perfection in yourself, then you will find failure." - Balboos HaGadol Mar 2010

                                C Offline
                                C Offline
                                Clumpco
                                wrote on last edited by
                                #23

                                I suspect that the code comes from a keyboard dyslexic like myself. Since he/she regularly mis-types lenght (see?) they though it would be a good idea to cater for it... unofrtuantely they misspselt it in the function too.

                                M 1 Reply Last reply
                                0
                                • M Marc Clifton

                                  public int Lenght
                                  {
                                  get { return this.Lenght; }
                                  }

                                  [Code from here](https://github.com/AdunanzA/Evolution-DHT/blob/master/Evolution.Dht/Kademlia/BucketList.cs) :sigh: :doh: :rolleyes: :omg: :wtf: X| :thumbsdown: Maybe that's how I should sign posts. :laugh:

                                  Latest Article - Class-less Coding - Minimalist C# and Why F# and Function Programming Has Some Advantages 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

                                  G Offline
                                  G Offline
                                  GKP1992
                                  wrote on last edited by
                                  #24

                                  Marc Clifton wrote:

                                  :sigh: :doh: :rolleyes: :OMG: :WTF: X| :thumbsdown:

                                  That is a lot of emotions to be felt at once. Are you alright? ;P

                                  I am not the one who knocks. I never knock. In fact, I hate knocking.

                                  1 Reply Last reply
                                  0
                                  • OriginalGriffO OriginalGriff

                                    It's not about patterns, it's about stupid code: that won't return, it will overflow the stack. Shows the level of testing they did on the rest of the code as well. :sigh:

                                    Bad command or file name. Bad, bad command! Sit! Stay! Staaaay... AntiTwitter: @DalekDave is now a follower!

                                    H Offline
                                    H Offline
                                    Harrison Pratt
                                    wrote on last edited by
                                    #25

                                    What else would expect from a coder who can't spell 'length' ?

                                    OriginalGriffO 1 Reply Last reply
                                    0
                                    • H Harrison Pratt

                                      What else would expect from a coder who can't spell 'length' ?

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

                                      This is why I use a VS extension: Spell Checker - Visual Studio Marketplace[^] it marks up my strings and comments, if not my variable names!

                                      Bad command or file name. Bad, bad command! Sit! Stay! Staaaay... 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

                                      1 Reply Last reply
                                      0
                                      • M Marc Clifton

                                        public int Lenght
                                        {
                                        get { return this.Lenght; }
                                        }

                                        [Code from here](https://github.com/AdunanzA/Evolution-DHT/blob/master/Evolution.Dht/Kademlia/BucketList.cs) :sigh: :doh: :rolleyes: :omg: :wtf: X| :thumbsdown: Maybe that's how I should sign posts. :laugh:

                                        Latest Article - Class-less Coding - Minimalist C# and Why F# and Function Programming Has Some Advantages 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

                                        B Offline
                                        B Offline
                                        BoomRShine
                                        wrote on last edited by
                                        #27

                                        How would this even work, given that "Lenght" is misspelled in both places?

                                        1 Reply Last reply
                                        0
                                        • L Lost User

                                          And what is "Seriously?" the Problem? I would skip such minor things. Bruno :confused: The longer I'm here the more I have a Feeling that programmers discuss about how to Programm, and because of endless discussions about pattern and this and that they are not able to do their Job ;)

                                          T Offline
                                          T Offline
                                          thezip001
                                          wrote on last edited by
                                          #28

                                          That was the first stupidity I saw the misspelling.

                                          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