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. Stupid code

Stupid code

Scheduled Pinned Locked Moved The Weird and The Wonderful
phpcomtestingbeta-testinghelp
10 Posts 8 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.
  • Z Offline
    Z Offline
    zenwalker1985
    wrote on last edited by
    #1

    Long back i saw this code chunk which was causing alot of issue once a while, unfortunately that code did not had proper logs/comments/exception catching mechanisms involved. So we did had to spend atleast half a day to find it..

    class MyClass
    {
    static int value = 10;
    static int Value { get { return Value; } }
    }

    At first it was a bit difficult to find where stackoverflow exception was occuring and then i was wondering what made the original developer do this stupid way and released with out even testing.

    My Blog -> https://adventurouszen.wordpress.com/

    R A G F 4 Replies Last reply
    0
    • Z zenwalker1985

      Long back i saw this code chunk which was causing alot of issue once a while, unfortunately that code did not had proper logs/comments/exception catching mechanisms involved. So we did had to spend atleast half a day to find it..

      class MyClass
      {
      static int value = 10;
      static int Value { get { return Value; } }
      }

      At first it was a bit difficult to find where stackoverflow exception was occuring and then i was wondering what made the original developer do this stupid way and released with out even testing.

      My Blog -> https://adventurouszen.wordpress.com/

      R Offline
      R Offline
      Robert Rohde
      wrote on last edited by
      #2

      I don't know if this also applies to static properties but I had once a similar case in a normal instance property. The main issue for me was that Visual Studio (I think it was 2003) crashed when I tried to debug code where this class was used. Why? Because the debugger tried to show the Value in the Watch-window and couldn't handle the StackOverflowException.

      1 Reply Last reply
      0
      • Z zenwalker1985

        Long back i saw this code chunk which was causing alot of issue once a while, unfortunately that code did not had proper logs/comments/exception catching mechanisms involved. So we did had to spend atleast half a day to find it..

        class MyClass
        {
        static int value = 10;
        static int Value { get { return Value; } }
        }

        At first it was a bit difficult to find where stackoverflow exception was occuring and then i was wondering what made the original developer do this stupid way and released with out even testing.

        My Blog -> https://adventurouszen.wordpress.com/

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

        I've done that myself before. One of the reasons I like to use m_value and Value.

        gavindon wrote:

        When it comes to pay the rent no matter what [...] I just blew a tranny [...] you do what you gotta do.

        Z J 2 Replies Last reply
        0
        • A AspDotNetDev

          I've done that myself before. One of the reasons I like to use m_value and Value.

          gavindon wrote:

          When it comes to pay the rent no matter what [...] I just blew a tranny [...] you do what you gotta do.

          Z Offline
          Z Offline
          zenwalker1985
          wrote on last edited by
          #4

          true and every mistake teaches us a lesson and this is one of those which changed my naming convention style of fields.

          My Blog -> https://adventurouszen.wordpress.com/

          1 Reply Last reply
          0
          • Z zenwalker1985

            Long back i saw this code chunk which was causing alot of issue once a while, unfortunately that code did not had proper logs/comments/exception catching mechanisms involved. So we did had to spend atleast half a day to find it..

            class MyClass
            {
            static int value = 10;
            static int Value { get { return Value; } }
            }

            At first it was a bit difficult to find where stackoverflow exception was occuring and then i was wondering what made the original developer do this stupid way and released with out even testing.

            My Blog -> https://adventurouszen.wordpress.com/

            G Offline
            G Offline
            gumi_r msn com
            wrote on last edited by
            #5

            Pretty normal mistake although its kind of weird how it made it into release unless this bit of code is only run when some very obscure corner case or feature is hit... I'm sure there is some good reason ($$$) why the C# team haven't implemented it but I still wonder why the compiler doesn't throw a warning in such cases...

            Z 1 Reply Last reply
            0
            • G gumi_r msn com

              Pretty normal mistake although its kind of weird how it made it into release unless this bit of code is only run when some very obscure corner case or feature is hit... I'm sure there is some good reason ($$$) why the C# team haven't implemented it but I still wonder why the compiler doesn't throw a warning in such cases...

              Z Offline
              Z Offline
              zenwalker1985
              wrote on last edited by
              #6

              well thats where one good programmer needs to improve his coding practices. Other wise such normal mistakes keep happening. Yep its true that it went to a production code. Lets not depend fully over compiler, even programmers have to be a bit more smart too ;)

              My Blog -> https://adventurouszen.wordpress.com/

              1 Reply Last reply
              0
              • Z zenwalker1985

                Long back i saw this code chunk which was causing alot of issue once a while, unfortunately that code did not had proper logs/comments/exception catching mechanisms involved. So we did had to spend atleast half a day to find it..

                class MyClass
                {
                static int value = 10;
                static int Value { get { return Value; } }
                }

                At first it was a bit difficult to find where stackoverflow exception was occuring and then i was wondering what made the original developer do this stupid way and released with out even testing.

                My Blog -> https://adventurouszen.wordpress.com/

                F Offline
                F Offline
                Fueled By Decaff
                wrote on last edited by
                #7

                This often happens if you type the method before declaring the variable.

                return value;

                will get corrected by the ide to:

                return Value;

                when the ; is typed. That does not excuse the original developer for not checking it. It is also looks far too compressed to me having the entire property on one line, although that is a matter of formatting standards, I guess.

                B 1 Reply Last reply
                0
                • F Fueled By Decaff

                  This often happens if you type the method before declaring the variable.

                  return value;

                  will get corrected by the ide to:

                  return Value;

                  when the ; is typed. That does not excuse the original developer for not checking it. It is also looks far too compressed to me having the entire property on one line, although that is a matter of formatting standards, I guess.

                  B Offline
                  B Offline
                  BobJanova
                  wrote on last edited by
                  #8

                  This is true and extremely annoying. If I wanted a capital I'd have typed it as such, damn you! I like one line properties if they are doing something simple (as most are); it means there is more screen space available to see actual code. I'm generally in favour of condensing things as much as reasonably practical for that reason, and particularly dislike the C# standard for braces which wastes a ridiculous number of lines.

                  G 1 Reply Last reply
                  0
                  • B BobJanova

                    This is true and extremely annoying. If I wanted a capital I'd have typed it as such, damn you! I like one line properties if they are doing something simple (as most are); it means there is more screen space available to see actual code. I'm generally in favour of condensing things as much as reasonably practical for that reason, and particularly dislike the C# standard for braces which wastes a ridiculous number of lines.

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

                    I'll use one-line properties if they're automatic: public Type Value { set; get; }, but otherwise they are:

                    public Type Value
                    {
                    set
                    {
                    _Value = value;
                    }

                    get
                    {
                    return _Value;
                    }
                    }

                    private Type _Value;

                    Software Zen: delete this;

                    1 Reply Last reply
                    0
                    • A AspDotNetDev

                      I've done that myself before. One of the reasons I like to use m_value and Value.

                      gavindon wrote:

                      When it comes to pay the rent no matter what [...] I just blew a tranny [...] you do what you gotta do.

                      J Offline
                      J Offline
                      James Lonero
                      wrote on last edited by
                      #10

                      Even Resharper advises you to use _value.

                      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