|
lol, arguments in code comments.
|
|
|
|
|
Here, here might need this: ?
cheers,
Chris Maunder
CodeProject.com : C++ MVP
|
|
|
|
|
Even more surprising is that it appeared convinced this was true even though the compiler gives an unreachable code warning and tell you that the check will always return true. But he probably didn't notice it hidden amongst the other 200 warnings. Sigh.
|
|
|
|
|
By the way, C# compiler (with optimization option 'on') generates these IL instructions for set accessor:
ldarg.0
ldarg.1
stfld bool <reference_to_local_field>
ret ;
so, at the C# level it whould be:
this._<reference_to_local_field> = value; ;
So, this construction is obviously needless
modified on Monday, January 19, 2009 1:56 AM
|
|
|
|
|
A colleague says perhaps this guy just plain didn't trust that said field would be checked actually *in* the serialization code...not that anyone would want to risk an exception getting thrown for serializing a bool anyway.
Since when were bool variables ever null ? Besides isn't that equivalent to false , or am I not a "C# Expert?"
-Brian
Sincerely Yours,
Brian Hart
|
|
|
|
|
public bool SelectedByDefault{ get; set; }
why not like above ?
|
|
|
|
|
Clearly, that would be _way_ too easy!
Just because the code works, it doesn't mean that it is good code.
modified on Friday, March 20, 2009 4:41 PM
|
|
|
|
|
Rotted Frog wrote: because serialisation can assign a null to a bool
Isn't the bool variable default initialized to false?
|
|
|
|
|
I think the worst projects to take over are those similar to the one I'm currently stuck with :
It's a relatively small & simple... in theory.
What complicates it is the fact that it's been through serveral developers already , is in a mix of C# and VB, uses various versions of the framework, is reliant on heaps of 3rd party DLL's, uses a 3rd party data access and business logic layer classes that are enormous & difficult to understand, there are no business requirements documents for it, it has no technical spec, the database uses a mix of naming conventions... I could go on.
Oh, and if that wasn't enough, the developer that was working on it is AWOL so no support from there...
|
|
|
|
|
So it's about par for the course?
|
|
|
|
|
Yeah, you have to get into those projects early, before all that happens.
|
|
|
|
|
before all that happens so that you can make it happen
|
|
|
|
|
Shhh... I didn't want to say it so blatanty.
|
|
|
|
|
LOL
I'm thinking of changing my job description to Salvage Consultant
|
|
|
|
|
Been there, done that (Except DB part).
I had a privilege to work on project where people were assigned as some sort of punishment... and they "promoted" me to tech lead on it!
At least it's experience!
|
|
|
|
|
I had a project like this where no lie the Project Manager quit 2 weeks before startup to join the Peace Corp. Never a good sign... Needless to say startup was not in 2 weeks.
|
|
|
|
|
Just go ahead and delete all the source code and start from scratch. While you're at it, tell your boss that you're not a mind-reader.
"What annoys me more than anything is someone hearing what my Ph.D. is and then asking me if I believe in Creationism."
Sincerely Yours,
Brian Hart
|
|
|
|
|
I have one right now that I am responsible for. It is the biggest pile of trash ever written. It was done in .net 1.1 by people who had absolutely no clue what they were doing. Every method is about three lines of code to debug just one little piece of functionality you end up with 25 files open by the time you have steeped through it.
And even though this application processes near 500K transactions in each batch every thing is done via datasets with record level processing. It is slower than hell. Even though it it is one web application the project is broken out into 12 projects and there are about 10 config files that need to be changed to move the application. This program is so bad, that I can't even describe how horrible the code is. On a positive note we are supposed to purchasing something to replace it and then I'll only be supporting applications that I wrote.
|
|
|
|
|
I've fell into the same trap; but the original web application was built in ASP and I had to convert it to ASP .NET web app.
plus on top of that the share holder is a jerk.
Dig deep and stick through it, it'll only make you a better developer. I'm at the end of this conversion and I have learned a lot.
Hang in there!
-Noir
|
|
|
|
|
The following code was found in someone's web template. Hope you enjoy the best logic.
if(dt != null)
{
if(dt.Rows.Count != 0)
{
if(dt.Rows[0]["Number"].ToString() == "1")
{
return true;
}
else
{
return false;
}
}
else
{
return false;
}
}
else
{
return false;
}
|
|
|
|
|
Zzzzz...
Half (or nearly) the posts on this forum are like that.
|
|
|
|
|
Oddly enough, I just got rid of some code that looked a bit like that...
bool InitRoutine()
{
bool failed=false;
ValType val;
HRESULT ans = GetValue1(val);
if (ans==S_OK)
{
globalVal1 = val;
}
else
{
failed = failed || true;
}
ans = GetValue2(val);
if (ans==S_OK)
{
globalVal2 = val;
}
else
{
failed = failed || true;
}
ans = GetValue3(val);
if (ans==S_OK)
{
globalVal3 = val;
}
else
{
failed = failed || true;
}
ans = GetValue4(val);
if (ans==S_OK)
{
globalVal4 = val;
}
else
{
failed = failed || true;
}
return !failed;
}
|
|
|
|
|
Ah a follower of the 'there must be only one return statement per method cult'.
I'll be more enthusiastic about encouraging thinking outside the box when there's evidence of any thinking going on inside it. - pTerryBizSquawk
|
|
|
|
|
A misguided one, gives the rest of us a bad name.
Though I don't see where any other return s would go.
|
|
|
|
|
Err ! Was that guy thinking to leave the company while writing this code ?
|
|
|
|