|
#region InterfaceImplementation(s)
public int CompareTo(Project other)
{
return this.Description.CompareTo(other.Description);
}
public bool Equals(Project other)
{
return this.PN.Equals(other.PN);
}
#endregion
I kid you not. This is eaxctly as my former collegue left it. Including the comments.
A further look in the code(where the calss is actualy used) he did something like
if(BinnarySearch(currentProj)!=0){
{ if ListOfItems.Contains(currentproject) return true;
else return false;}
else return true;}
Instead of doing something like(pseudo kindof only):
if((descriptionComparer==0) || (PN_Comparer==0)) {return 0;}
else if(descriptionComparer<0){return -1;}
else{return 1;}
inside the CompareTo method. Why??? I guess, that he thought that it will be faster in most cases.
As a note, neither myself or my famous former collegue are programmers per say.
We're just lazy suns of ... and we did all kind of "apps" to limit the number of
phones and/or mails geared toward us from the users.
modified on Sunday, May 2, 2010 9:18 PM
|
|
|
|
|
SELECT Actions = REVERSE(RTRIM(REVERSE(@Plan)))
Copied verbatim from production code (including the code comment).
|
|
|
|
|
Well, obviously right-trimming is more efficient than left-trimming.
|
|
|
|
|
LOL, I couldn't think of why they would possibly do that, but a misguided attempt at optimization seems feasible.
|
|
|
|
|
Almost certainly.
If you are doing a search, then LTRIM(my_col) LIKE 'A%' may be much slower than RTRIM(my_col) LIKE 'A%'. That's because the second query can use an index on my_col, whereas the first one can't.
So, from there someone might wrongly conclude that the LTRIM operation itself is slower than RTRIM, and avoid using LTRIM in all cases. It's not the LTRIM operation per se that's a problem, it's the fact that it precludes the use of indexes during searches.
|
|
|
|
|
Test App : MFC dialog typed (unmanaged)
Code:
char szModel1 [256] = { "REQ$-$$$$-$$$$-$$$$-$$$$-$$$$" };
size_t sizeModel1 = strlen ( szModel1 );
char szModel2 [256] = { "REQ?-????-????-????-????-????" };
size_t sizeModel2 = strlen ( szModel2 );
Result on debugger on VC2003 & VC2005, I don't test it on 2008 & 2010 if some one can try...
+ szModel1 0x0012fc10 "REQ$-$$$$-$$$$-$$$$-$$$$-$$$$" char [256]
+ szModel2 0x0012fafc "REQ?-??~??~??~??~????" char [256]
sizeModel1 29 unsigned int
sizeModel2 21 unsigned int
The content and the size of the string is bad with "??-" sequence...
Strange
...
|
|
|
|
|
|
really it is the good old trigraphs
i dont know if they abandoned them in C++0X, but at THAT time, they WERE useful
nowadays, they are annoying :<
look at this[^] for example =D
|
|
|
|
|
I came across this class today - RenderingEventArgs .
This is part of the Silverlight System.Windows.Media namespace.
When I tried to use it, intellisense gave me a message "Do not use".
If you go to its definition, all thta the code comment tells me is "Do not use".
Now that's interesting.
Anyone else came across any class / namespace MS provides that says "Do not use".
|
|
|
|
|
Wouldn't have classed that as a message for Coding Horrors, but more a question for the Lounge?
The .net framework documentation is full of classes and methods that have 'Not to be used directly from user code, internal use only' or words to that effect.
|
|
|
|
|
daveauld wrote: Wouldn't have classed that as a message for Coding Horrors, but more a question for the Lounge?
I was debating where to it, thought perhaps this was safer.
|
|
|
|
|
It looks to me like the "Do not press" red button
I have no smart signature yet...
|
|
|
|
|
Abhinav S wrote: Anyone else came across any class / namespace MS provides that says "Do not use".
The whole of VB? At least it should .
Dalek Dave: There are many words that some find offensive, Homosexuality, Alcoholism, Religion, Visual Basic, Manchester United, Butter.
Pete o'Hanlon: If it wasn't insulting tools, I'd say you were dumber than a bag of spanners.
|
|
|
|
|
Ahhhhhhhhhhh bite me.
Sorry, just a VB.NET user starting the day out in a bad mood already. Nothing personal
|
|
|
|
|
No problem, can't expect to make a statement like that without comment from the VBers knocking around
Dalek Dave: There are many words that some find offensive, Homosexuality, Alcoholism, Religion, Visual Basic, Manchester United, Butter.
Pete o'Hanlon: If it wasn't insulting tools, I'd say you were dumber than a bag of spanners.
|
|
|
|
|
Lots of places; especially where a class/method has been deprecated in favour of a newer version.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
Should they not say 'Deprecated' instead.
"Do not use" makes me want to use it.
|
|
|
|
|
If a can of gasoline had a picture with a lit match with an X through it, would that mean you would want to throw a lit match in the can.
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]
|
|
|
|
|
I think there is an ObsoleteAttribute to handle this situation, isn't it ?
|
|
|
|
|
|
Cool - thanks.
I somehow missed this link earlier.
|
|
|
|
|
So in other words, instead of a "Do not use" comment, it really should say, "Don't forget to cast".
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]
|
|
|
|
|
|
Here is a code sample from Q&A. Obviously a beginner (so I won't say where or who to spare the OP's blushes) but "How not to do it: convert from ascii to an array of bits":
array< array< int >^ >^ chartobin(array^arr,int length,int imgsize1)
{
int ascii;
array< array< int >^ >^ messag= gcnew array< array< int >^ >(imgsize1);
for(int i=0;i<imgsize1;i++)>
{
messag[i] = gcnew array(8);
}
for(int x= 0;x<length;x++)>
{
ascii =(int) arr[x];
int* binary_reverse = new int [9];
int* binary = new int [9];
int y = 0;
while(ascii != 1)
{
if(ascii % 2 == 0)
{
binary_reverse[y] = 0;
}
else if(ascii % 2 == 1)
{
binary_reverse[y] = 1;
}
ascii /= 2;
y++;
}
if(ascii == 1)
{
binary_reverse[y] = 1;
y++;
}
if(y < 8)
{
for(; y < 8; y++)
{
binary_reverse[y] = 0;
}
}
for(int z = 0; z < 8; z++)
{
binary[z] = binary_reverse[7 - z];
if(binary[z]==0)
{
binary[z]=-1;
}
}
for(int z = 0; z < 8; z++)
{
messag[x][z]=binary[z];
}
delete [] binary_reverse;
delete [] binary;
}
return messag;
}
You should never use standby on an elephant. It always crashes when you lift the ears. - Mark Wallace
C/C++ (I dont see a huge difference between them, and the 'benefits' of C++ are questionable, who needs inheritance when you have copy and paste) - fat_boy
|
|
|
|
|
Yes a bit of a horror, but, yes there is a but, without knowing what was the driver for this question or what the OP was upto, they might have been forced to do it this way, particularly if they are on a programming course etc.
I am currently doing a degree with the OU, and it is all based around Java. The question papers etc, sometimes tell you must do some things a certain way and not use other methods (or built in libraries/extensions etc.
The last paper I was doing was based around threads, it had the 'main' thread, and 3 other worker threads. We had to use semaphores/countdown latches etc. to ensure the workers were finished before the main thread did something, rather than a simple join.
|
|
|
|