Bug of the day
-
public int MyValue { get; set; }
public MyObject(int myValue, ...)
{
...
MyValue = MyValue;
}:doh:
cheers, Chris Maunder The Code Project | Co-founder Microsoft C++ MVP
And don't anybody say they haven't done this before... :)
I wasn't, now I am, then I won't be anymore.
-
public int MyValue { get; set; }
public MyObject(int myValue, ...)
{
...
MyValue = MyValue;
}:doh:
cheers, Chris Maunder The Code Project | Co-founder Microsoft C++ MVP
-
public int MyValue { get; set; }
public MyObject(int myValue, ...)
{
...
MyValue = MyValue;
}:doh:
cheers, Chris Maunder The Code Project | Co-founder Microsoft C++ MVP
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/
-
public int MyValue { get; set; }
public MyObject(int myValue, ...)
{
...
MyValue = MyValue;
}:doh:
cheers, Chris Maunder The Code Project | Co-founder Microsoft C++ MVP
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]
-
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]
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)
-
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)
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
-
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
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)
-
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
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.
-
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.
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)
-
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 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!