• (cs) in reply to Your Name
    Your Name:
    Anonymous Cow-Herd:
    XIU:
    Mister Cheese:
    Some damn Yank:
    The Enterpriser:
    This is actually very useful for when you want to make use of the set value from within the method whilst limiting out of scope use to '5'.

    I have seen very effective use of this pattern in the security industry. The strength of this lies in the way that the get is also secretly a setter too.

    So, let me get this straight. maxRetry is 1 internally, and someone outside can set it to whatever they want, but if they ask they're always told it's 5? What's the point of that? I guess what I'm missing here is what really happens (sorry, I'm a tester not a coder). Is maxRetry always 1, or do you really let it be set to something else? And if so, why do you lie and say it's 5?

    Is it more like maxRetry is set to 1 initially, you can set it to a new value, and when you read it once, it returns the value it's set to and then sets itself to 5?

    The health+safety executive advises people in ivory towers not to ride high horses.

    The code will set the field to 5 AND return 5

    Surely it sets the field to 5 and returns true?

    No, it returns FILE_NOT_FOUND.

    [image]

  • (cs) in reply to C-Octothorpe
    C-Octothorpe:
    Steve The Cynic:
    The amusing thing here is that when I read the article, there were already 5 comments...

    For the previous posters who clearly didn't get it... The single = operator is assignment, not equality, so every time you read the property, the assigned value is replaced by 5 (and then you see the 5 come out of the property).

    Sick. Whoever did this should be punished. Severely. By zunesis.

    FTFY
    +1

  • Ban Request (unregistered)

    Ban zunesis, please. Seriously.

  • Sea Sharp, Waves Hurt (unregistered) in reply to Lowmack
    XIU:
    Surely it sets the field to 5 and returns true?

    The result of an assignment in C# is as if you had chained the value assignment.

    int a = 3; int b = a = 5;

    b is 5.

    int a = 3; return a = 5;

    5 is returned.

  • zunesis (the one, the only, the well-hung, yada yada yada) (unregistered) in reply to Ban Request
    Ban Request:
    Ban zunesis, please. Seriously.

    But I have work to do:

    PedanticCurmudgeon:
    C-Octothorpe:
    Steve The Cynic:
    Sick. Whoever did this should be punished. Severely. By zunesis.
    FTFY
    +1
  • Hortical (unregistered) in reply to Ban Request
    Ban Request:
    Ban zunesis, please. Seriously.

    Agreed.

    The fact that I actually read the entirety of his last post significantly lowered my self-esteem. I no longer feel like anyone could ever love me or that I would deserve it.

    I would also like to thank everyone who encouraged him to get this bad.

  • (cs) in reply to Sea Sharp, Waves Hurt
    Sea Sharp:
    XIU:
    Surely it sets the field to 5 and returns true?

    The result of an assignment in C# is as if you had chained the value assignment.

    int a = 3; int b = a = 5;

    b is 5.

    int a = 3; return a = 5;

    5 is returned.

    As I just learned. All I knew is it wasn't a boolean anymore, so I assumed it was void.

  • (cs) in reply to Hortical
    Hortical:
    Ban Request:
    Ban zunesis, please. Seriously.

    Agreed.

    The fact that I actually read the entirety of his last post significantly lowered my self-esteem. I no longer feel like anyone could ever love me or that I would deserve it.

    So how much did zunesis charge to rid you of your delusions?

  • Frank (unregistered) in reply to Anonymous Cow-Herd
    Anonymous Cow-Herd:
    XIU:
    Mister Cheese:
    Some damn Yank:
    The Enterpriser:
    This is actually very useful for when you want to make use of the set value from within the method whilst limiting out of scope use to '5'.

    I have seen very effective use of this pattern in the security industry. The strength of this lies in the way that the get is also secretly a setter too.

    So, let me get this straight. maxRetry is 1 internally, and someone outside can set it to whatever they want, but if they ask they're always told it's 5? What's the point of that? I guess what I'm missing here is what really happens (sorry, I'm a tester not a coder). Is maxRetry always 1, or do you really let it be set to something else? And if so, why do you lie and say it's 5?

    Is it more like maxRetry is set to 1 initially, you can set it to a new value, and when you read it once, it returns the value it's set to and then sets itself to 5?

    The health+safety executive advises people in ivory towers not to ride high horses.

    The code will set the field to 5 AND return 5

    Surely it sets the field to 5 and returns true?

    The TRWTF is that it took the readers of this forum so many tries to get it right. sigh

  • (cs) in reply to Frank
    The TRWTF is that it took the readers of this forum so many tries to get it right. *sigh*
    That, and me confusing C#, C++, and C.

    Addendum (2011-07-27 13:58): And never realizing that C does operator chaining as well... I thought it returned true on all assignments.

  • (cs) in reply to Frank
    Frank:
    The TRWTF is that it took the readers of this forum so many tries to get it right. *sigh*
    Many people (of varying technical acumen) trying once each != One person trying many times

    But I'm sure you knew that...

  • Frank (unregistered) in reply to C-Octothorpe
    C-Octothorpe:
    Frank:
    The TRWTF is that it took the readers of this forum so many tries to get it right. *sigh*
    Many people (of varying technical acumen) trying once each != One person trying many times

    But I'm sure you knew that...

    But they were each building on what someone else had said previously, as indicated by the quotes and replies.

  • who else hates ipods? (unregistered) in reply to hoodaticus
    hoodaticus:
    Hortical:
    Ban Request:
    Ban zunesis, please. Seriously.

    Agreed.

    The fact that I actually read the entirety of his last post significantly lowered my self-esteem. I no longer feel like anyone could ever love me or that I would deserve it.

    So how much did zunesis charge to rid you of your delusions?
    Nothing - all my work is pro-boner.

    On a lighter note, I have thought up some more "punishment" methods:

    I Attach a penis-pump on the guy and force him to ejaculate on his mother's face until he dehydrates and dies. Do whatever you want with her.

    II When he gets home from work, have his family lined up on the front lawn doused in gasoline. Hide the garden hose and light them up. Make him watch as they scream and burn to death.

    III Take a dildo and cover the outside with low-grit sandpaper, grit facing out. 'nuff said.

    IV Kidnap with wife (if shes tall and fat enough) and peel off her skin. Wear it like a suit and impersonate her. Initiate lovemaking that night - imagine his surprise when it turns out his wife is a man!

    That's all for now.

  • (cs) in reply to zunesis (the one, the only, the well-hung, yada yada yada)
    zunesis (the one:
    Ban Request:
    Ban zunesis, please. Seriously.

    But I have work to do:

    PedanticCurmudgeon:
    C-Octothorpe:
    Steve The Cynic:
    Sick. Whoever did this should be punished. Severely. By zunesis.
    FTFY
    +1
    Yes, but you don't need to be online to do said work.
  • (cs) in reply to Frank
    Frank:
    C-Octothorpe:
    Frank:
    The TRWTF is that it took the readers of this forum so many tries to get it right. *sigh*
    Many people (of varying technical acumen) trying once each != One person trying many times

    But I'm sure you knew that...

    But they were each building on what someone else had said previously, as indicated by the quotes and replies.

    I'll give you that, but to me it seemed that the people trying initially to solve the WTF weren't all that experienced with C# syntax (judging by all the = vs == confusion)...

  • Machtyn (unregistered)

    Let's have some fun with this code:

    class BaitnSwitch() 
    {
     private int maxRetry = 1;
     public int MaxRetry
     {
        get { return maxRetry = 5; }
        set { maxRetry = value; }
     }
    
     public void BaitnSwitch()
     {
     }
    
     // should be obvious... but still
     // Exceeds retries if retry > maxRetry (return true)
     // Does not Exceed retries if retry <= maxRetry (return false)
     public bool ExceedRetries(int retry) 
     {
      return (retry > maxRetry);
     }
    }
    
    public int main{int argc, char* argv)
    {
      BaitnSwitch bns = new BaitnSwitch();
      Console.WriteLine(bns.ExceedRetries(2)) // returns true
      bns.MaxRetry = 8;
      Console.WriteLine(bns.ExceedRetries(6)) // returns false
      int retries = bns.MaxRetry;
      Console.WriteLine(bns.ExceedRetries(6)) // returns true
      return 0;
    }
    

    // I make no guarantees or warranties as to the compilability or accuracy of this post.

  • Hortical (unregistered) in reply to hoodaticus
    hoodaticus:
    [The TRWTF is] never realizing that C does operator chaining as well... I thought it returned true on all assignments.

    Perhaps it returns true for most assignments, so you never noticed.

  • Frank (unregistered) in reply to C-Octothorpe
    C-Octothorpe:
    Frank:
    C-Octothorpe:
    Frank:
    The TRWTF is that it took the readers of this forum so many tries to get it right. *sigh*
    Many people (of varying technical acumen) trying once each != One person trying many times

    But I'm sure you knew that...

    But they were each building on what someone else had said previously, as indicated by the quotes and replies.

    I'll give you that, but to me it seemed that the people trying initially to solve the WTF weren't all that experienced with C# syntax (judging by all the = vs == confusion)...
    So what gives it away as C# and not possibly C++? I've only worked with C++.

  • (cs) in reply to Frank
    Frank:
    C-Octothorpe:
    Frank:
    C-Octothorpe:
    Frank:
    The TRWTF is that it took the readers of this forum so many tries to get it right. *sigh*
    Many people (of varying technical acumen) trying once each != One person trying many times

    But I'm sure you knew that...

    But they were each building on what someone else had said previously, as indicated by the quotes and replies.

    I'll give you that, but to me it seemed that the people trying initially to solve the WTF weren't all that experienced with C# syntax (judging by all the = vs == confusion)...
    So what gives it away as C# and not possibly C++? I've only worked with C++.
    Well, I don't really have much experience with C++, but IIRC it doesn't natively support get/set properties, especially not in this particular syntax. This is C# syntactic sugar...

  • Frank (unregistered) in reply to C-Octothorpe
    C-Octothorpe:
    Frank:
    So what gives it away as C# and not possibly C++? I've only worked with C++.
    Well, I don't really have much experience with C++, but IIRC it doesn't natively support get/set properties, especially not in this particular syntax. This is C# syntactic sugar...
    Are you sure that's what's really happening here? Note maxRetry != MaxRetry. Kinda looks like maxRetry is a property and MaxRetry is a class (obviously the "class" keyword is omitted, but this is a fragment.)
  • Matthew (unregistered) in reply to someguy
    someguy:
    In order to prempt any more unnecessary arguing about what this code does:
    namespace PropertyTest2{
    	class Program{
    		private int maxRetry = 1;
    		public int MaxRetry{
    			get { return maxRetry = 5; }
    			set { maxRetry = value; }
    		}
    		public int GetMaxRetry(){return maxRetry;}
    		static void Main(string[] args){
    			Program p = new Program();
    			Console.WriteLine(p.GetMaxRetry());
    			Console.WriteLine(p.MaxRetry);
    			Console.WriteLine(p.GetMaxRetry());
    			p.MaxRetry = 2;
    			Console.WriteLine(p.GetMaxRetry());
    			Console.WriteLine(p.MaxRetry);
    			Console.WriteLine(p.GetMaxRetry());
    			Console.ReadKey();
    		}
    	}
    }

    Output:

    1 5 5 2 5 5

    Yes, it builds. No, the get of the property does not return true. No, it does not return the previous value.

    Thank you for posting this. It's pretty much the only comment worth reading. It's proof of what the function does, even though everyone is still arguing about it.

    It's called a "bait and switch" because if you do a "GetMaxRetry()" it will return the value of what it is, then set itself to 5. The assignment will be performed after the return.

    Take the following code:

    If (GetMaxRetry() < 3) {
       for (int c = 0; c < GetMaxRetry(); c++) {
          Retry();
       }
    }

    I imagine most would be pretty confused when that loop runs 5 times.

  • (cs) in reply to Frank
    Frank:
    C-Octothorpe:
    Frank:
    So what gives it away as C# and not possibly C++? I've only worked with C++.
    Well, I don't really have much experience with C++, but IIRC it doesn't natively support get/set properties, especially not in this particular syntax. This is C# syntactic sugar...
    Are you sure that's what's really happening here? Note maxRetry != MaxRetry. Kinda looks like maxRetry is a property and MaxRetry is a class (obviously the "class" keyword is omitted, but this is a fragment.)
    Um, MaxRetry isn't a class; it clearly shows that it's an integer, same as maxRetry, except that maxRetry is a private field, not a public property. Further to this is the fact that this is a defacto "standard" for writing properties in .Net objects (though I would usually put the private field below the property definition). Not sure where you're going with this, but I'm really not following.
  • Frank (unregistered) in reply to C-Octothorpe
    C-Octothorpe:
    Frank:
    C-Octothorpe:
    Frank:
    So what gives it away as C# and not possibly C++? I've only worked with C++.
    Well, I don't really have much experience with C++, but IIRC it doesn't natively support get/set properties, especially not in this particular syntax. This is C# syntactic sugar...
    Are you sure that's what's really happening here? Note maxRetry != MaxRetry. Kinda looks like maxRetry is a property and MaxRetry is a class (obviously the "class" keyword is omitted, but this is a fragment.)
    Um, MaxRetry isn't a class; it clearly shows that it's an integer, same as maxRetry, except that maxRetry is a private field, not a public property. Further to this is the fact that this is a defacto "standard" for writing properties in .Net objects (though I would usually put the private field below the property definition). Not sure where you're going with this, but I'm really not following.
    OK, I see now. This is clearly not C++ because as you note, the MaxRetry property has a getter and a setter. Having two properties with names which differ by capitalization of one letter surely results in less maintainable code. Kinda looks like the coder wanted a private property because that what the textbooks told him was good OOP, but the application actually needed a public property. Please, please tell me this is not standard practice in C#.
  • (cs) in reply to ted
    ted:
    Sincerely, Go get fucked.
    Wow... your parents had a pretty twisted sense of humor, naming you something like that. I'm sorry.
  • QuantumMechanicallyInclined (unregistered) in reply to Steve The Cynic

    No fair!

    You changed the outcome by reading it!

  • (cs) in reply to Hortical
    Hortical:
    hoodaticus:
    [The TRWTF is] never realizing that C does operator chaining as well... I thought it returned true on all assignments.

    Perhaps it returns true for most assignments, so you never noticed.

    Exactly. I must never have checked it on an assignment of zero/null.

  • (cs) in reply to Frank
    Frank:
    C-Octothorpe:
    Frank:
    The TRWTF is that it took the readers of this forum so many tries to get it right. *sigh*
    Many people (of varying technical acumen) trying once each != One person trying many times

    But I'm sure you knew that...

    But they were each building on what someone else had said previously, as indicated by the quotes and replies.

    Not really sure how that logic is working in your head since the very original thing you quoted (mine) states that it limits the out of scope use (i.e. access to the public member) as being 5, and also in the quote, that this is because the get method is also setting the value. So how many tries did it take? 1.

    The third thing you quoted also quite clearly stated that it would set and return the value 5.

  • Machtyn (unregistered) in reply to Frank
    Frank:
    OK, I see now. This is clearly not C++ because as you note, the MaxRetry property has a getter and a setter. Having two properties with names which differ by capitalization of one letter surely results in less maintainable code. Kinda looks like the coder wanted a private property because that what the textbooks told him was good OOP, but the application actually needed a public property. Please, please tell me this is not standard practice in C#.

    You can have:

    class example 
    {
      private int property1;
      private int property2;
      public int Property2
      {
         get { return property2; }
      }
      private int property3;
      public int Property3
      {
         set { 
               if value > someConst
                  property3 = someConst; // or whatever the spec calls for to handle invalid data
               else
                  property3 = value;
             } 
         get { return property3; }
      }
    
      // create instantiation function here
      // create other associated functions here
    }
    

    Unless I learned incorrectly, this is a fairly standard way of exposing properties publicly using the OOP model. Your style of variable naming can change (I've seen private int _Property1, then public int Property1 used in examples.)

  • (cs) in reply to Matthew
    Matthew:
    someguy:
    In order to prempt any more unnecessary arguing about what this code does:
    namespace PropertyTest2{
    	class Program{
    		private int maxRetry = 1;
    		public int MaxRetry{
    			get { return maxRetry = 5; }
    			set { maxRetry = value; }
    		}
    		public int GetMaxRetry(){return maxRetry;}
    		static void Main(string[] args){
    			Program p = new Program();
    			Console.WriteLine(p.GetMaxRetry());
    			Console.WriteLine(p.MaxRetry);
    			Console.WriteLine(p.GetMaxRetry());
    			p.MaxRetry = 2;
    			Console.WriteLine(p.GetMaxRetry());
    			Console.WriteLine(p.MaxRetry);
    			Console.WriteLine(p.GetMaxRetry());
    			Console.ReadKey();
    		}
    	}
    }

    Output:

    1 5 5 2 5 5

    Yes, it builds. No, the get of the property does not return true. No, it does not return the previous value.

    Thank you for posting this. It's pretty much the only comment worth reading. It's proof of what the function does, even though everyone is still arguing about it.

    It's called a "bait and switch" because if you do a "GetMaxRetry()" it will return the value of what it is, then set itself to 5. The assignment will be performed after the return.

    Take the following code:

    If (GetMaxRetry() < 3) {
       for (int c = 0; c < GetMaxRetry(); c++) {
          Retry();
       }
    }

    I imagine most would be pretty confused when that loop runs 5 times.

    disagree entirely.

    This wtf is about as simple as they come. You'd understand it after the first 2 weeks of a computing degree. There is only one person who didn't understand it and he/she was quickly corrected.

    The fact that you or anyone else thinks that we need coded example to explain what a property is in C# shows that you probably don't understand this very well yourself.

    Your post makes about as much sense as someone praising an explanation of the difference between an int and a string.

  • (cs) in reply to C-Octothorpe
    C-Octothorpe:
    Frank:
    C-Octothorpe:
    Frank:
    So what gives it away as C# and not possibly C++? I've only worked with C++.
    Well, I don't really have much experience with C++, but IIRC it doesn't natively support get/set properties, especially not in this particular syntax. This is C# syntactic sugar...
    Are you sure that's what's really happening here? Note maxRetry != MaxRetry. Kinda looks like maxRetry is a property and MaxRetry is a class (obviously the "class" keyword is omitted, but this is a fragment.)
    Um, MaxRetry isn't a class; it clearly shows that it's an integer, same as maxRetry, except that maxRetry is a private field, not a public property. Further to this is the fact that this is a defacto "standard" for writing properties in .Net objects (though I would usually put the private field below the property definition). Not sure where you're going with this, but I'm really not following.

    This.

    Today I have lost a lot of confidence in the ability of tdwtf readers. It looks like the coders have been chased away by the trolls.

  • (cs) in reply to Matthew
    Matthew:
    Thank you for posting this. It's pretty much the only comment worth reading. It's proof of what the function does, even though everyone is still arguing about it.

    It's called a "bait and switch" because if you do a "GetMaxRetry()" it will return the value of what it is, then set itself to 5. The assignment will be performed after the return.[/code] I imagine most would be pretty confused when that loop runs 5 times.

    Wow.

    Frank:
    OK, I see now. This is clearly not C++ because as you note, the MaxRetry property has a getter and a setter.
    How 'bout "the syntax is quite different from C++ in several ways"?
    • Use of "private <entity>" instead of "private:"
    • The fact that it has a property at all (using the C#/VB/Delphi definition)
    ~/temp $ cat property.cc 
    class C {
      public int property {
        get { return 0; }
        set { }
      };
    };
    
    ~/temp $ icc -fsyntax-only property.cc
    property.cc(2): error: expected a ":"
        public int property {
               ^
    
    property.cc(2): error: expected a ";"
        public int property {
                            ^
    
    property.cc(5): warning #12: parsing restarts here after previous syntax error
        };
         ^

    How long have you been a C++ programmer again?

  • someone (unregistered) in reply to The Enterpriser
    The Enterpriser:
    Matthew:
    someguy:
    In order to prempt any more unnecessary arguing about what this code does:

    Thank you for posting this. It's pretty much the only comment worth reading. It's proof of what the function does, even though everyone is still arguing about it.

    <goes on to misunderstand the code anyway>

    The fact that you or anyone else thinks that we need coded example to explain what a property is in C# shows that you probably don't understand this very well yourself.

    I don't appreciate this. My decision to post the code was inspired by other people demonstrating their lack of understanding and I didn't want the discussion to run any longer over something so simple - they often do and, this time even, still did, showing that it could be helpful.

  • (cs) in reply to someone
    someone:
    The Enterpriser:
    Matthew:
    someguy:
    In order to prempt any more unnecessary arguing about what this code does:

    Thank you for posting this. It's pretty much the only comment worth reading. It's proof of what the function does, even though everyone is still arguing about it.

    <goes on to misunderstand the code anyway>

    The fact that you or anyone else thinks that we need coded example to explain what a property is in C# shows that you probably don't understand this very well yourself.

    I don't appreciate this. My decision to post the code was inspired by other people demonstrating their lack of understanding and I didn't want the discussion to run any longer over something so simple - they often do and, this time even, still did, showing that it could be helpful.

    For the record, I stand by someone on this. The fact that Matthew singled out his post, said how awesome it was, and still got it wrong pretty much justifies thinking that "we need coded example to explain what a property is" in my mind. At least if you read "we" as "the forum" and not any particular person.

  • The Web is the Root of All Info (unregistered) in reply to Out of Topic
    Out of Topic:
    @Deprecated:
    Hooah:
    This is a common thing to do on an embedded machine with no filesystem.

    Clearly this is C#, which you would be hard pressed to find on that class of device.

    You haven't heard of the Netduino (http://netduino.com/) ?

    Or the DotNET 'Micro' version of the framework? http://www.microsoft.com/en-us/netmf/default.aspx

  • (cs) in reply to someone
    someone:
    The Enterpriser:
    Matthew:
    someguy:
    In order to prempt any more unnecessary arguing about what this code does:

    Thank you for posting this. It's pretty much the only comment worth reading. It's proof of what the function does, even though everyone is still arguing about it.

    <goes on to misunderstand the code anyway>

    The fact that you or anyone else thinks that we need coded example to explain what a property is in C# shows that you probably don't understand this very well yourself.

    I don't appreciate this. My decision to post the code was inspired by other people demonstrating their lack of understanding and I didn't want the discussion to run any longer over something so simple - they often do and, this time even, still did, showing that it could be helpful.

    And it really clarified for me the return value of assignment, which I thought returned true in C/C++ and void in C#.

  • Frank (unregistered) in reply to EvanED
    EvanED:
    How long have you been a C++ programmer again?
    Well, TBH I've spent the last month eye-ball-deep in assembler and C trying to get a bootloader to run on a custom board. So I haven't done any OOP in a while. And I tend to be able to store only one syntax at a time in my head. So I saw two things which are somewhat similar, and the differences didn't pop right out at me. Thanks for explaining the differences quite well, in spite of the insult at the end.
  • (cs) in reply to who else hates ipods?
    who else hates ipods?:
    hoodaticus:
    Hortical:
    Ban Request:
    Ban zunesis, please. Seriously.

    Agreed.

    The fact that I actually read the entirety of his last post significantly lowered my self-esteem. I no longer feel like anyone could ever love me or that I would deserve it.

    So how much did zunesis charge to rid you of your delusions?
    Nothing - all my work is pro-boner.

    On a lighter note, I have thought up some more "punishment" methods:

    I Attach a penis-pump on the guy and force him to ejaculate on his mother's face until he dehydrates and dies. Do whatever you want with her.

    II When he gets home from work, have his family lined up on the front lawn doused in gasoline. Hide the garden hose and light them up. Make him watch as they scream and burn to death.

    III Take a dildo and cover the outside with low-grit sandpaper, grit facing out. 'nuff said.

    IV Kidnap with wife (if shes tall and fat enough) and peel off her skin. Wear it like a suit and impersonate her. Initiate lovemaking that night - imagine his surprise when it turns out his wife is a man!

    That's all for now.

    Blimey, that's sick enough to be worthy of Viz.

  • Debbie Sweghart, Sr. Account Manager (unregistered) in reply to zunesis (the one, the only, the well-hung, yada yada yada)

    To the poster referring to himself as various forms of "Zunesis":

    "Zunesis" is a trademarked name of The Zunesis Company (http://www.zunesis.com).

    We find your statements here beyond deplorable. We are especially offended that you would use our name to post your horrifying depravity.

    If you do not stop making use of our registered trademarks, we will pursue legal action.

    Debbie Sweghart Sr. Account Manager

  • (cs) in reply to Frank
    Frank:
    EvanED:
    How long have you been a C++ programmer again?
    Well, TBH I've spent the last month eye-ball-deep in assembler and C trying to get a bootloader to run on a custom board. So I haven't done any OOP in a while. And I tend to be able to store only one syntax at a time in my head. So I saw two things which are somewhat similar, and the differences didn't pop right out at me. Thanks for explaining the differences quite well, in spite of the insult at the end.
    Sorry, I was a bit harsh there... some frustration with the rest of the thread bled into that. It's quite reasonable that someone who hasn't seen C# wouldn't even really get what was being done at all, because properties are a reasonably unique feature of that language. And if you've been off of C++ for a while (also reasonable), then that just seals the deal. So my apologies for that snap.
  • (cs) in reply to someone
    someone:
    The Enterpriser:
    Matthew:
    someguy:
    In order to prempt any more unnecessary arguing about what this code does:

    Thank you for posting this. It's pretty much the only comment worth reading. It's proof of what the function does, even though everyone is still arguing about it.

    <goes on to misunderstand the code anyway>

    The fact that you or anyone else thinks that we need coded example to explain what a property is in C# shows that you probably don't understand this very well yourself.

    I don't appreciate this. My decision to post the code was inspired by other people demonstrating their lack of understanding and I didn't want the discussion to run any longer over something so simple - they often do and, this time even, still did, showing that it could be helpful.

    I think it would have been faster to just link to something like this: http://www.amazon.com/Beginning-Programming-Dummies-Wally-Wang/dp/0764508350

    As far as I could see, there were about 2 people who didn't understand the code and about 10 people posting about how "no-one understands".

    I still maintain that anyone who feels a tutorial is required in order to explain how a property works, is far overestimating the complexity of a property.

  • passing through *whistle* (unregistered) in reply to Matt Westwood
    Matt Westwood:
    who else hates ipods?:
    <woah, not reposting that>

    Blimey, that's sick enough to be worthy of Viz.

    What's a "Viz"? I'm afraid to search for it.

  • (cs) in reply to Debbie Sweghart, Sr. Account Manager
    Debbie Sweghart:
    To the poster referring to himself as various forms of "Zunesis":

    "Zunesis" is a trademarked name of The Zunesis Company (http://www.zunesis.com).

    We find your statements here beyond deplorable. We are especially offended that you would use our name to post your horrifying depravity.

    If you do not stop making use of our registered trademarks, we will pursue legal action.

    Debbie Sweghart Sr. Account Manager

    Ha! I would've believed it had you not thrown in the trademarking BS...

    Well, good luck either way. I'm interested to see what zunesis' reaction will be.

  • anyman (unregistered) in reply to The Enterpriser
    The Enterpriser:
    I think it would have been faster to just link to something like this: http://www.amazon.com/Beginning-Programming-Dummies-Wally-Wang/dp/0764508350

    As far as I could see, there were about 2 people who didn't understand the code and about 10 people posting about how "no-one understands".

    I still maintain that anyone who feels a tutorial is required in order to explain how a property works, is far overestimating the complexity of a property.

    I can tell even just from your wording that nothing worthwhile will come from talking to you. You seem to have no interest in helping people to understand, thus avoiding WTFs, which I though was the point of this site.

    Go away now.

  • (cs) in reply to The Enterpriser
    The Enterpriser:
    As far as I could see, there were about 2 people who didn't understand the code and about 10 people posting about how "no-one understands".

    I still maintain that anyone who feels a tutorial is required in order to explain how a property works, is far overestimating the complexity of a property.

    Mister Cheese, Anonymous Cow-Herd,Some Damn Yank, hoodaticus, and probably Lowmack all had it explicitly wrong before someguy posted. And, I'll point out, all after Steve The Synic gave a correct explanation. (I feel bad calling out hoodaticus considering he actually stuck around to learn something.)

    And then of course there was Matthew's work of art later.

  • Omnomnonymous (unregistered) in reply to Debbie Sweghart, Sr. Account Manager

    I strongly doubt anyone would confuse his screen-name with your company, seeing as nobody has ever heard of you- so I don't think you have much of a legal leg to stand on. In fact, your threatening legal action over his completely unrelated screen-name creates a far more negative connotation of your company than anything zunesis said.

    Captcha: Vindico Lawsuits 'en vindico' never got us anywhere.

  • (cs) in reply to anyman
    anyman:
    The Enterpriser:
    I think it would have been faster to just link to something like this: http://www.amazon.com/Beginning-Programming-Dummies-Wally-Wang/dp/0764508350

    As far as I could see, there were about 2 people who didn't understand the code and about 10 people posting about how "no-one understands".

    I still maintain that anyone who feels a tutorial is required in order to explain how a property works, is far overestimating the complexity of a property.

    I can tell even just from your wording that nothing worthwhile will come from talking to you. You seem to have no interest in helping people to understand, thus avoiding WTFs, which I though was the point of this site.

    Go away now.

    Sure, so lets take this to the next level. We should get a primary school teacher in here to explain what all these long words mean. Then we should get your older brother in to tell you how to turn on your computer.

    We could treat everyone like complete morans and explain the most basic of concepts to everyone... or those morans could just stop commenting on things they know nothing about and could learn the basics in their own time.

    (Thanks to EvanED for clarifying that there are more people who probably shouldn't be here than I had initially thought.)

  • thesameguy (unregistered) in reply to The Enterpriser
    The Enterpriser:
    We *could* treat everyone like complete morans and explain the most basic of concepts to everyone... or those morans could just stop commenting on things they know nothing about and could learn the basics in their own time.

    (Thanks to EvanED for clarifying that there are more people who probably shouldn't be here than I had initially thought.)

    Who should be here and why?

  • Spearhavoc! (unregistered) in reply to hoodaticus
    hoodaticus:
    Anonymous Cow-Herd:
    XIU:
    Mister Cheese:
    Some damn Yank:
    The Enterpriser:
    This is actually very useful for when you want to make use of the set value from within the method whilst limiting out of scope use to '5'.

    I have seen very effective use of this pattern in the security industry. The strength of this lies in the way that the get is also secretly a setter too.

    So, let me get this straight. maxRetry is 1 internally, and someone outside can set it to whatever they want, but if they ask they're always told it's 5? What's the point of that? I guess what I'm missing here is what really happens (sorry, I'm a tester not a coder). Is maxRetry always 1, or do you really let it be set to something else? And if so, why do you lie and say it's 5?

    Is it more like maxRetry is set to 1 initially, you can set it to a new value, and when you read it once, it returns the value it's set to and then sets itself to 5?

    The health+safety executive advises people in ivory towers not to ride high horses.

    The code will set the field to 5 AND return 5

    Surely it sets the field to 5 and returns true?

    That's the C++ behavior. But I don't think it would compile in C#.

    Ooh, subtle troll there. :)

  • (cs) in reply to EvanED
    EvanED:
    The Enterpriser:
    As far as I could see, there were about 2 people who didn't understand the code and about 10 people posting about how "no-one understands".

    I still maintain that anyone who feels a tutorial is required in order to explain how a property works, is far overestimating the complexity of a property.

    Mister Cheese, Anonymous Cow-Herd,Some Damn Yank, hoodaticus, and probably Lowmack all had it explicitly wrong before someguy posted. And, I'll point out, all after Steve The Synic gave a correct explanation. (I feel bad calling out hoodaticus considering he actually stuck around to learn something.)

    And then of course there was Matthew's work of art later.

    Don't feel bad - I may have gotten the return value of the assignment operator wrong, but I'm probably mistaken about a lot of other things I couldn't care less about as well.

  • (cs) in reply to thesameguy
    thesameguy:
    The Enterpriser:
    We *could* treat everyone like complete morans and explain the most basic of concepts to everyone... or those morans could just stop commenting on things they know nothing about and could learn the basics in their own time.

    (Thanks to EvanED for clarifying that there are more people who probably shouldn't be here than I had initially thought.)

    Who should be here and why?

    Anyone can be here, but unless you know at least the very basics of programming, you will not find much enjoyment in the codeSODs. I thought that would be common sense.

    Such people should be somewhere else learning 'Hello World' and the like. That way, when they come here, we will not have people trying to educate them on programming101.

Leave a comment on “Representative Property: MaxRetry”

Log In or post as a guest

Replying to comment #:

« Return to Article