Ankush Bansal
Posts
-
Can you please answer my question on MVVM -
Whats wrong with this code???This would fail if obj is double... :-\
-
Whats wrong with this code???Well in theory not... but our middleware doesn't support uint and float so for us (practically) they are bad.
-
Whats wrong with this code???Yes!! Actually the question was raised by the same colleague when I told him its wrong.... :-D
-
Whats wrong with this code???I was assigned a QA bug today and I found this horror code written by my colleague :mad:...
private static double ConvertToDouble(object obj, out bool good)
{
if (obj is double || obj is int)
{
good = true;
return (double)obj;
}good = false; return double.NaN; }
This code exploded in to
Exception type: InvalidCastException
Message: Specified cast is not valid.
[System.InvalidCastException] -
A morning dreamMy eyes were paining, as I coded per requirements, I shouted for it was crowded, and he gifted me diamonds, please read full poem at http://bansalankush.blogspot.in/2011/09/morning-dream.html[^]
-
What about this gem?I missed to recognize that.... have my vote of 5 for "eye for detail" lol :)
-
got another codebase to work on... its full of surprises!!!What if I tell you he is an experienced C# developer:cool:
-
got another codebase to work on... its full of surprises!!!Someone told me that String.Copy is faster than raw assignment... So
_field = string.Copy(s.Field);
might actually perform better than
_field = s.Field
Is he crazy or am I mad to not have known this?? :~ :doh:
-
What about this gem?some might actually do. I know a person who says worlds ending soon, so lets not design!! :wtf:
-
got another codebase to work on... its full of surprises!!!Yeah... original dev didn't took chances, but fore sure I have to. I'll kick on his a** next time i see him.
-
got another codebase to work on... its full of surprises!!!public class Field
{private readonly string _field;
private readonly string _table;Field()
{}public Field(Field s)
{
_table = string.Copy(s.Table);
_field = string.Copy(s.Field);
}}
string.Copy for what?:mad:
-
What about this gem?array = new T[1];
array[array.Length - 1] = handler;is
array[0]
not allowed in c#?
-
ArrayList.Contains() isn't bool?"virtual bool" so anyone can override to make it float. :-D :thumbsup:
-
Scope failNow I am starting to believe that world is moving to .net, :thumbsup: God save JAVA :laugh:
-
Scope failMy vote of 5, to accept your mistake. Newton's unspecified law: No code in world is bug free!
-
ArrayList.Contains() isn't bool?Just saw this legacy gem
if(myArrayList.Contains(something)==true || myArrayList.Count>0)
{
if(myArrayList.Contains(something)==false)
{
default=something;
}
else
{
default=myArrayList[0];
}
}this is for C#.net.
-
Reflection OptimizationWow!!!
obj.GetType().GetProperty(_propertyInfo.Name)
LOL :-D But it might be useful, if you want to set a value on a different type that has a property with same name!! otherwise :mad:
-
return value optimizationyes indeed :laugh::rose:
-
return value optimizationRahul Rajat Singh wrote:
"it might break something" (WT Elephant?)
Yes it might break original coder's heart :laugh: I once saw this in production code: :laugh:
bool func(bool check)
{
if(check)
{
if(check)
{
//Double check to be 100% sure
}
}
}