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. Bug of the day

Bug of the day

Scheduled Pinned Locked Moved The Weird and The Wonderful
c++architecturehelp
12 Posts 9 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.
  • C Offline
    C Offline
    Chris Maunder
    wrote on last edited by
    #1

    public int MyValue { get; set; }

    public MyObject(int myValue, ...)
    {
    ...
    MyValue = MyValue;
    }

    :doh:

    cheers, Chris Maunder The Code Project | Co-founder Microsoft C++ MVP

    F RaviBeeR C C 4 Replies Last reply
    0
    • C Chris Maunder

      public int MyValue { get; set; }

      public MyObject(int myValue, ...)
      {
      ...
      MyValue = MyValue;
      }

      :doh:

      cheers, Chris Maunder The Code Project | Co-founder Microsoft C++ MVP

      F Offline
      F Offline
      fjdiewornncalwe
      wrote on last edited by
      #2

      And don't anybody say they haven't done this before... :)

      I wasn't, now I am, then I won't be anymore.

      1 Reply Last reply
      0
      • C Chris Maunder

        public int MyValue { get; set; }

        public MyObject(int myValue, ...)
        {
        ...
        MyValue = MyValue;
        }

        :doh:

        cheers, Chris Maunder The Code Project | Co-founder Microsoft C++ MVP

        RaviBeeR Offline
        RaviBeeR Offline
        RaviBee
        wrote on last edited by
        #3

        Another case of DWIM vs. DWIS. /ravi

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

        1 Reply Last reply
        0
        • C Chris Maunder

          public int MyValue { get; set; }

          public MyObject(int myValue, ...)
          {
          ...
          MyValue = MyValue;
          }

          :doh:

          cheers, Chris Maunder The Code Project | Co-founder Microsoft C++ MVP

          C Offline
          C Offline
          Christoph Keller
          wrote on last edited by
          #4

          bad one :) That's why I always let resharper generate the properties directly from the Ctor parameters. Never ever again ;) Best regards and happy coding, chris

          New Url Un-Shortener available: http://dotnetcorner.ch/tools/unshortener/ Check out my website http://dotnetcorner.ch/ and my blog http://blog.dotnetcorner.ch/

          1 Reply Last reply
          0
          • C Chris Maunder

            public int MyValue { get; set; }

            public MyObject(int myValue, ...)
            {
            ...
            MyValue = MyValue;
            }

            :doh:

            cheers, Chris Maunder The Code Project | Co-founder Microsoft C++ MVP

            C Offline
            C Offline
            Chris Meech
            wrote on last edited by
            #5

            Some languages would let you know about something called an unreferenced parameter. ;P

            Chris Meech I am Canadian. [heard in a local bar] In theory there is no difference between theory and practice. In practice there is. [Yogi Berra] posting about Crystal Reports here is like discussing gay marriage on a catholic church’s website.[Nishant Sivakumar]

            S 1 Reply Last reply
            0
            • C Chris Meech

              Some languages would let you know about something called an unreferenced parameter. ;P

              Chris Meech I am Canadian. [heard in a local bar] In theory there is no difference between theory and practice. In practice there is. [Yogi Berra] posting about Crystal Reports here is like discussing gay marriage on a catholic church’s website.[Nishant Sivakumar]

              S Offline
              S Offline
              Sentenryu
              wrote on last edited by
              #6

              Chris Meech wrote:

              Some languages would let you know about something called an unreferenced parameter.

              some will call you a idiot if you try to assign a variable to itself :-O

              I'm brazilian and english (well, human languages in general) aren't my best skill, so, sorry by my english. (if you want we can speak in C# or VB.Net =p)

              OriginalGriffO 1 Reply Last reply
              0
              • S Sentenryu

                Chris Meech wrote:

                Some languages would let you know about something called an unreferenced parameter.

                some will call you a idiot if you try to assign a variable to itself :-O

                I'm brazilian and english (well, human languages in general) aren't my best skill, so, sorry by my english. (if you want we can speak in C# or VB.Net =p)

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

                Which isn't what it's doing: they are just symantic sugar for

                SetProperty(GetProperty());

                And although it is a really bad idea, I have seen code where

                MyProperty = MyProperty;

                Has a effect. Nasty, but it can be done. (I even found myself coding it once, and had to quickly refactor a bunch of code to get rid of it)

                Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water

                "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

                S F B 3 Replies Last reply
                0
                • OriginalGriffO OriginalGriff

                  Which isn't what it's doing: they are just symantic sugar for

                  SetProperty(GetProperty());

                  And although it is a really bad idea, I have seen code where

                  MyProperty = MyProperty;

                  Has a effect. Nasty, but it can be done. (I even found myself coding it once, and had to quickly refactor a bunch of code to get rid of it)

                  Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water

                  S Offline
                  S Offline
                  Sentenryu
                  wrote on last edited by
                  #8

                  my bad, don't see it's a property... but even then, i already received warnings about assigning a property to himself... maybe it was one of the statical analysers we had here for a while. They usually were wrong about the code, so the architect took them away...

                  I'm brazilian and english (well, human languages in general) aren't my best skill, so, sorry by my english. (if you want we can speak in C# or VB.Net =p)

                  1 Reply Last reply
                  0
                  • OriginalGriffO OriginalGriff

                    Which isn't what it's doing: they are just symantic sugar for

                    SetProperty(GetProperty());

                    And although it is a really bad idea, I have seen code where

                    MyProperty = MyProperty;

                    Has a effect. Nasty, but it can be done. (I even found myself coding it once, and had to quickly refactor a bunch of code to get rid of it)

                    Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water

                    F Offline
                    F Offline
                    fjdiewornncalwe
                    wrote on last edited by
                    #9

                    OriginalGriff wrote:

                    Has a effect. Nasty, but it can be done.

                    The good old "Let's put a bunch of logic in a property setter" mentality. :) Seen that too.

                    I wasn't, now I am, then I won't be anymore.

                    S 1 Reply Last reply
                    0
                    • F fjdiewornncalwe

                      OriginalGriff wrote:

                      Has a effect. Nasty, but it can be done.

                      The good old "Let's put a bunch of logic in a property setter" mentality. :) Seen that too.

                      I wasn't, now I am, then I won't be anymore.

                      S Offline
                      S Offline
                      Sentenryu
                      wrote on last edited by
                      #10

                      That would make sense, but only if the logic is just to validate the value, and i can't think of a case where doing MyProp = MyProp should do something :doh: Converselly, i had to port a system, writen in vb 6, where all the properties had a explicit check for this, because otherwise this case would screw everything :doh: Oh that moments when you catch yourself thinking if the original coder had too much or too little cafeine in their blood...

                      I'm brazilian and english (well, human languages in general) aren't my best skill, so, sorry by my english. (if you want we can speak in C# or VB.Net =p)

                      1 Reply Last reply
                      0
                      • OriginalGriffO OriginalGriff

                        Which isn't what it's doing: they are just symantic sugar for

                        SetProperty(GetProperty());

                        And although it is a really bad idea, I have seen code where

                        MyProperty = MyProperty;

                        Has a effect. Nasty, but it can be done. (I even found myself coding it once, and had to quickly refactor a bunch of code to get rid of it)

                        Ideological Purity is no substitute for being able to stick your thumb down a pipe to stop the water

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

                        I have actually written that at some point. I can't remember exactly why but it was something like triggering the data binding notification process. The line got a comment to say why I was doing it, though!

                        J 1 Reply Last reply
                        0
                        • B BobJanova

                          I have actually written that at some point. I can't remember exactly why but it was something like triggering the data binding notification process. The line got a comment to say why I was doing it, though!

                          J Offline
                          J Offline
                          Jan Steyn
                          wrote on last edited by
                          #12

                          I always call a specific databinding method. Exactly because of the confusion it could cause, experienced first hand from code that I took over on one of my supported systems.

                          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