Stupid code
-
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/
-
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/
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.
-
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/
I've done that myself before. One of the reasons I like to use m_value and Value.
When it comes to pay the rent no matter what [...] I just blew a tranny [...] you do what you gotta do.
-
I've done that myself before. One of the reasons I like to use m_value and Value.
When it comes to pay the rent no matter what [...] I just blew a tranny [...] you do what you gotta do.
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/
-
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/
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...
-
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...
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/
-
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/
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.
-
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.
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.
-
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.
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;
-
I've done that myself before. One of the reasons I like to use m_value and Value.
When it comes to pay the rent no matter what [...] I just blew a tranny [...] you do what you gotta do.
Even Resharper advises you to use _value.