News for hackers. Stuff that matters.
Re:What is the most intrusive wart on your favourite program... by habs on Monday December 08, 2008 @06:32AM (#389748)
Java - I love Javadoc Tool. Don't really get to use it much now, but still love it.

c# - Constraints on typed params.

public T AssignLiteItem<T>(ArchivingItem archivingItem ) where T : Item {

T myITem = (T)typeof(T).GetConstructor(new System.Type[] {}).Invoke(new Object[] { });

myITem.ItemReference = new ItemReference(archivingItem.Id);

return myITem;

}

Re:What is the most intrusive wart on your favourite program... by mindviews on Monday December 08, 2008 @01:49PM (#390157)
Don't forget you can add an empty constructor constraint in c# generics.

public T AssignLiteItem<T>(ArchivingItem archivingItem ) where T : Item, new() {

T myITem = new T();

myITem.ItemReference = new ItemReference(archivingItem.Id);

return myITem;

}

I do wish the compiler handled constraints for arbitrary constructor signatures on generic types, however...

Re:What is the most intrusive wart on your favourite program... by habs on Tuesday December 09, 2008 @04:20PM (#391783)
Nice, I guess I can get rid of the reflection invocation of the T Type constructor. Should speed things up a bit. Cheers.