I've certainly done this : written a load of code to do some operation, then discovered that the language already had that functionality built in. An early case i remember is writing a function to reverse a string in VB6, then stumbling across StrReverse a week later. What's your worst example of this?
Creating a function in VB6 to create a string with a number of spaces.
I later found that I could simply do:
Dim str As String
str = String(10)
We once tried to create a method to shuffle a Collection in Java :)
EDIT: corrected "sort" to "shuffle"
Copying arrays, only to later find that you have System.arraycopy()
.
One of my co-worker once tried to write a full-featured XML parser in c# ...
I once tried to write HTML editor in jscript as my employer did not want to buy one in or use an open source one.
In one inspired period during my first programming job I decided it would be a good idea to write a thread pool to deal with a number of items of work in parallel in C#. Armed with a list of jobs to process and a maximum number of threads I could use I set to work.
My downfall came when I decided that keeping the thread pool going with while (true) and no sleep was a good idea. A sentiment not shared by my fellow developers, especially since I ran the service on our main database server. I think it took two minutes before someone spotted things 'had got a little slow' on the box.
Needless to say I now think of 'the threadpool incident' and look around for things someone else has written before deciding I need to reinvent the wheel.
I once implemented several sorting algorithms in Java only to have my boss tell me about Java's sorting classes.
A couple of jobs ago a co-worker didn't trust SQL's JOIN so he set about writing one himself...