• (cs)

    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.

    VGhhdCBpcyBkb3VibGUgZW5jcnlwdGlvbi4=

  • Omnomnonymous (unregistered)

    Frist {Failed} Error: Max attempts reached! Skipping

  • Hooah (unregistered)

    This is a common thing to do on an embedded machine with no filesystem.

  • Warren (unregistered)

    I like the fact that the "Representative Line" page linked to doesn't include this article.

  • Some damn Yank (unregistered) in reply to The Enterpriser
    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?

  • Some damn Yank (unregistered) in reply to Warren
    Warren:
    I like the fact that the "Representative Line" page linked to doesn't include this article.
    That's because this isn't a Representative Line example, it's the first of a new series: Representative Property.

    CAPTCHA: sino. Yah, sino, it should be obvious if you read the title.

  • (cs)

    I love how MaxRetry always equals maxRetry but sometimes maxRetry does not equal MaxRetry (but if you ask again, it will). You just defeated the symmetry of the equality operator, thanks for playing. I'm sure Resharper doesn't take in account this perversion when innocently proposing to switch equality operators.

  • (cs)

    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. With a baseball bat.

  • VictorSierraGolf (unregistered) in reply to GFK

    I also love how 2+2 always equals 4 but sometimes equals 5...

  • Mister Cheese (unregistered) in reply to Some damn Yank
    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.

  • (cs) in reply to Hooah
    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.

  • (cs) in reply to Some damn Yank
    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?

    It isn't a lie. It is set to 5 each time it is read. This prevents outside use from having visibility of internal use.

    e.g. if I want to use this from within the method I could set via the property and then retrieve through the private member:

     
    //increase performance through larger maximum number of retries
    lock(this) { //make it thread safe
    MaxRetry = 20;
    performAction(yhbt,maxRetry); //whatever it is
    }
    

    This way no outside code is going to ever interfere with your retries, and they cannot abuse the property to steal importante cpu cycles

  • (cs) in reply to Steve The Cynic
    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

  • VeryBestDeveloperNumber1 (unregistered) in reply to @Deprecated
    @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.

    I program my toaster in visual basic.

  • (cs) in reply to The Enterpriser
    The Enterpriser:
    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?

    It isn't a lie. It is set to 5 each time it is read. This prevents outside use from having visibility of internal use.

    e.g. if I want to use this from within the method I could set via the property and then retrieve through the private member:

     
    //increase performance through larger maximum number of retries
    lock(this) { //make it thread safe
    MaxRetry = 20;
    performAction(yhbt,maxRetry); //whatever it is
    }
    

    This way no outside code is going to ever interfere with your retries, and they cannot abuse the property to steal importante cpu cycles

    You almost got me...

  • (cs) in reply to Mister Cheese
    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

  • (cs) in reply to Hooah
    Hooah:
    This is a common thing to do on an embedded machine with no filesystem.
    I can tell from your pixels that you're pretty stupid, so I guess I need to inform you that the thing you just posted, even when posted ironically, has been beyond lame for months. It's not even "Ha ha he posted something deliberately unfunny" funny anymore.
  • Out of Topic (unregistered) in reply to @Deprecated
    @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/) ?

  • Anonymous Cow-Herd (unregistered) in reply to XIU
    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?

  • Lowmack (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?

    You're right, and don't call me Shirley.

  • (cs) in reply to The Enterpriser

    If the idea is really just to make the internal value writeable but not readable, wouldn't it be easier to omit the get accessor?

  • ted (unregistered) in reply to Zylon
    Zylon:
    Hooah:
    This is a common thing to do on an embedded machine with no filesystem.
    I can tell from your pixels that you're pretty stupid, so I guess I need to inform you that the thing you just posted, even when posted ironically, has been beyond lame for months. It's not even "Ha ha he posted something deliberately unfunny" funny anymore.

    MaxRetry:

    In case you can't tell, this is a grown up place. The fact that you continue to insist on being a faggoty square clearly shows that you're too out of touch and too stupid to appreciate good humor.

    Go away and grow up.

    Sincerely, Go get fucked.

  • Cheese (unregistered) in reply to @Deprecated
    @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.

    Although there are faster alternatives, the .NET Micro Framework is used on quite a few machines with no file system. http://en.wikipedia.org/wiki/.NET_Micro_Framework

  • trtrwtf (unregistered) 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. With a baseball bat. By zunesis.

    FTFY

    Surely there's room for compromise here? I don't think our sick little friend will object. And zunesis won't mind, either.

  • (cs) in reply to Robajob
    Robajob:
    If the idea is really just to make the internal value writeable but not readable, wouldn't it be easier to omit the get accessor?
    If you really want to seal up a class, just have get accessors (who cares if you can read it, unless it's a ref type of course), and set the internal private value via ctor overload.
  • Cheese (unregistered) in reply to Robajob
    Robajob:
    If the idea is really just to make the internal value writeable but not readable, wouldn't it be easier to omit the get accessor?

    True, but maybe they wanted it to be serializable :)

  • Some damn Yank (unregistered) in reply to Lowmack
    Lowmack:
    Anonymous Cow-Herd:
    XIU:
    The code will set the field to 5 AND return 5
    Surely it sets the field to 5 and returns true?
    You're right, and don't call me Shirley.
    OK, first off he didn't call you "Shirley", he called Anonymous Cow-Herd "Shirley", and for all you know that's her name.

    Second, the more I look at this the more I realize this code isn't devious, it's evil.

    "What's the maximum number of retrys?" "True." "No, I need a number; what's the maximum number of retrys?" "True." "Your answer doesn't make any sense." "True." "OK, let's set maxRetry to 23. Now, what's the value of maxRetry?" "True."

  • zunesis (the one, the only, the well-hung, yada yada yada) (unregistered) in reply to trtrwtf
    trtrwtf:
    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. With a baseball bat. By zunesis.

    FTFY
    Surely there's room for compromise here? I don't think our sick little friend will object. And zunesis won't mind, either.
    What does it mean that my most irritating and despicable sockpuppet is also the most beloved around here?

  • (cs) 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?

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

  • (cs) in reply to C-Octothorpe
    C-Octothorpe:
    Robajob:
    If the idea is really just to make the internal value writeable but not readable, wouldn't it be easier to omit the get accessor?
    If you really want to seal up a class, just have get accessors (who cares if you can read it, unless it's a ref type of course), and set the internal private value via ctor overload.
    This is a lesson for people who want immutability.
  • E. Pesker (unregistered)

    I'm not sure I see the problem here.

    Clearly there was a bug in where under some condition this "maxRetries" (which i'm guessing was used to control logging or something) needed to be 5, and luckily that was only condition in which the getter was being called (probably just used to check that the value was indeed 5).

    So- this is really a quite elegant surgical fix here: it works, and doesn't hurt anything. Where's the wtf?

  • Some damn Yank (unregistered) in reply to Robajob
    Robajob:
    If the idea is really just to make the internal value writeable but not readable, wouldn't it be easier to omit the get accessor?
    I don't think the idea is to make it writeable but not readable. I think the idea was to limit the value to 5. But that's not what this code does. It sets maxRetry to 5 when you read it; you can write it to anything you like, which to me is the real WTF. In effect, there is no max. The fact that maxRetry is 1 until someone wants to know what it is, at which point you make it 5, is just a sidebar WTF.
  • (cs) in reply to Anonymous Cow-Herd

    = != ==. Also,

     {return maxRetry == 5}
    wouldn't compile because the MaxRetry property is an int and it would be trying to return a boolean.

  • (cs) in reply to Cheese
    Cheese:
    @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.

    Although there are faster alternatives, the .NET Micro Framework is used on quite a few machines with no file system. http://en.wikipedia.org/wiki/.NET_Micro_Framework

    Initial hardware released in 2010... so that's like 1 device out of 5.3 skillion other devices.

    So I stand by my original statement, which was: Hooah's post is lame.

  • (cs) in reply to E. Pesker
    E. Pesker:
    I'm not sure I see the problem here.

    Clearly there was a bug in where under some condition this "maxRetries" (which i'm guessing was used to control logging or something) needed to be 5, and luckily that was only condition in which the getter was being called (probably just used to check that the value was indeed 5).

    So- this is really a quite elegant surgical fix here: it works, and doesn't hurt anything. Where's the wtf?

    There's a lot of wtfs with this, but if you wanted to actually understand how this came to be - it (the "= 5") is probably just someone's quick debugging code which they forgot to remove. Without it, the code would be fine.

  • (cs) in reply to Robajob
    Robajob:
    = != ==. Also,
     {return maxRetry == 5}
    wouldn't compile because the MaxRetry property is an int and it would be trying to return a boolean.
    I didn't think assignment returned a boolean in C#...
  • (cs) in reply to Anonymous Cow-Herd
    Anonymous Cow-Herd:
    XIU:

    The code will set the field to 5 AND return 5

    Surely it sets the field to 5 and returns true?

    It returns '5'.

    Also, 'true' is not an int.

  • trtrwtf (unregistered) in reply to zunesis (the one, the only, the well-hung, yada yada yada)
    zunesis (the one:
    trtrwtf:
    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. With a baseball bat. By zunesis.

    FTFY
    Surely there's room for compromise here? I don't think our sick little friend will object. And zunesis won't mind, either.
    What does it mean that my most irritating and despicable sockpuppet is also the most beloved around here?

    In my case, it means I'm doing my best to defuse the shock value and take some of the fun out of it. Seems to be working.

  • zunesis (the one, the only, the well-hung, yada yada yada) (unregistered) in reply to trtrwtf
    trtrwtf:
    C-Octothorpe:
    Steve The Cynic:
    Sick. Whoever did this should be punished. Severely. With a baseball bat. By zunesis.
    FTFY
    Surely there's room for compromise here? I don't think our sick little friend will object. And zunesis won't mind, either.
    Indeed, I think the answer is pretty obvious - use the baseball bat, just don't simply swing it at him.
  • (cs) in reply to hoodaticus
    hoodaticus:
    Robajob:
    = != ==. Also,
     {return maxRetry == 5}
    wouldn't compile because the MaxRetry property is an int and it would be trying to return a boolean.
    I didn't think assignment returned a boolean in C#...
    He was trying to correct someone else who thought that
     {return maxRetry = 5}
    returns a bool.
  • spivonious (unregistered) in reply to The Enterpriser
    The Enterpriser:
    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?

    It isn't a lie. It is set to 5 each time it is read. This prevents outside use from having visibility of internal use.

    e.g. if I want to use this from within the method I could set via the property and then retrieve through the private member:

     
    //increase performance through larger maximum number of retries
    lock(this) { //make it thread safe
    MaxRetry = 20;
    performAction(yhbt,maxRetry); //whatever it is
    }
    

    This way no outside code is going to ever interfere with your retries, and they cannot abuse the property to steal importante cpu cycles

    Or you can just mark the setter as private and avoid this nonsense.

  • (cs) in reply to C-Octothorpe
    C-Octothorpe:
    hoodaticus:
    Robajob:
    = != ==. Also,
     {return maxRetry == 5}
    wouldn't compile because the MaxRetry property is an int and it would be trying to return a boolean.
    I didn't think assignment returned a boolean in C#...
    He was trying to correct someone else who thought that
     {return maxRetry = 5}
    returns a bool.
    The only part of that that I agree with is that assignment returns.

    Void.

  • (cs) in reply to hoodaticus
    hoodaticus:
    C-Octothorpe:
    hoodaticus:
    Robajob:
    = != ==. Also,
     {return maxRetry == 5}
    wouldn't compile because the MaxRetry property is an int and it would be trying to return a boolean.
    I didn't think assignment returned a boolean in C#...
    He was trying to correct someone else who thought that
     {return maxRetry = 5}
    returns a bool.
    The only part of that that I agree with is that assignment returns.

    Void.

    In this case
    {return maxRetry = 5}
    it returns a 5 and in this case
    {return maxRetry == 5}
    it returns a bool. Sorry, I'm not sure if I'm following (got 2 hour of sleep last night, again).

  • trtrwtf (unregistered) in reply to zunesis (the one, the only, the well-hung, yada yada yada)
    zunesis (the one:
    trtrwtf:
    C-Octothorpe:
    Steve The Cynic:
    Sick. Whoever did this should be punished. Severely. With a baseball bat. By zunesis.
    FTFY
    Surely there's room for compromise here? I don't think our sick little friend will object. And zunesis won't mind, either.
    Indeed, I think the answer is pretty obvious - use the baseball bat, just don't simply swing it at him.

    Congratulations. You have parsed an innuendo. Go, you.

    (Could someone please post a less boring WTF? I'm dying here)

  • (cs) in reply to C-Octothorpe
    C-Octothorpe:
    hoodaticus:
    C-Octothorpe:
    hoodaticus:
    Robajob:
    = != ==. Also,
     {return maxRetry == 5}
    wouldn't compile because the MaxRetry property is an int and it would be trying to return a boolean.
    I didn't think assignment returned a boolean in C#...
    He was trying to correct someone else who thought that
     {return maxRetry = 5}
    returns a bool.
    The only part of that that I agree with is that assignment returns.

    Void.

    In this case
    {return maxRetry = 5}
    it returns a 5 and in this case
    {return maxRetry == 5}
    it returns a bool. Sorry, I'm not sure if I'm following (got 2 hour of sleep last night, again).
    Well I'll be damned. I learn something new here every year. Apparently assignment returns the thing being assigned. Which I would know if M$ would let me overload the sucker.

  • someguy (unregistered)

    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.

  • zunesis (the one, the only, the well-hung, yada yada yada) (unregistered) in reply to trtrwtf
    trtrwtf:
    zunesis (the one:
    trtrwtf:
    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. With a baseball bat. By zunesis.

    FTFY
    Surely there's room for compromise here? I don't think our sick little friend will object. And zunesis won't mind, either.
    What does it mean that my most irritating and despicable sockpuppet is also the most beloved around here?
    In my case, it means I'm doing my best to defuse the shock value and take some of the fun out of it. Seems to be working.
    Well, if by "fun" you mean my dick and by "it" you mean your lovely pale ass, which is how I usually refer to things, then no, it's not happening.

  • c# guy (unregistered) in reply to hoodaticus
    hoodaticus:
    Robajob:
    = != ==. Also,
     {return maxRetry == 5}
    wouldn't compile because the MaxRetry property is an int and it would be trying to return a boolean.
    I didn't think assignment returned a boolean in C#...

    well it can do,

    e.g.

    bool b;

    return b = true;

  • Your Name (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?

    No, it returns FILE_NOT_FOUND.

  • zunesis (the one, the only, the well-hung, yada yada yada) (unregistered) in reply to trtrwtf
    trtrwtf:
    zunesis (the one:
    trtrwtf:
    C-Octothorpe:
    Steve The Cynic:
    Sick. Whoever did this should be punished. Severely. With a baseball bat. By zunesis.
    FTFY
    Surely there's room for compromise here? I don't think our sick little friend will object. And zunesis won't mind, either.
    Indeed, I think the answer is pretty obvious - use the baseball bat, just don't simply swing it at him...
    Congratulations. You got the jo...
    ...you abduct him and his family and restrain them. Make him choose whose ass gets the bat (he is not allowed to choose himself), tell him if he refuses, you'll do it to all of them.

    Who would he choose? His wife? His daughter? His son? An interesting scenario to consider, especially for those of us who do have kids.

    Make him choose one at a time, so you end up doing it to all of them anyway.

    (P.S. I'm sorry when I sometimes take the easy way out. Thank you for encouraging me to go the extra mile and think up something more refreshing. I couldn't do it without your support and constructive criticism, trtrwtf. Love, Zunesis(not that way, queer))

Leave a comment on “Representative Property: MaxRetry”

Log In or post as a guest

Replying to comment #355065:

« Return to Article