Excellent usage Of ComapareTo+Equals methods!!
The Weird and The Wonderful
1
Posts
1
Posters
0
Views
1
Watching
-
#region InterfaceImplementation(s) public int CompareTo(Project other) { return this.Description.CompareTo(other.Description); } //use of a very unorthodox Equals+CompareTo methods //the project should be unique if either bla or tra is blah 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