Reinventing the Wheel
What is it with software developers and their innate desire to reinvent the wheel at every opportunity? It drives me absolutely crazy when devs choose to roll their own implementations of standard structures instead of using the functionality already available in the .NET Framework.
Case in point - a coworker just emailed myself and others an "example of using generic collections". I was intrigued why an example of such a thing should be necessary in 2009, so I took a look.
To my horror I discovered that this supposed example of best practice included a hand-rolled implementation of the ICollection<T> interface, replicating entirely the functionality offered by Collection<T>. Already screaming inside at the futility of this exercise, I then noticed that this custom implementation was in fact using an instance of the non-generic .NET 1.1 ArrayList class for its underlying store. Ouchy!
Now, I know that the .NET framework is huge, and nobody can be expected to be au fait with everything it offers. BUT, I've said it before, and I'll say it again:
If ever you find yourself thinking "gosh, this is convoluted" or "if only there was an easier way..." then, in all likelihood, there is indeed an easier way, and you're making this far more complicated than they need be.
So, should you ever find yourself writing heaps of code to achieve what should be a common task, please, stop what you're doing and try the following:
- Search Google.
- Search the .NET Framework documentation on MSDN.
- Consult the .NET Framework Design Guidelines.
- Post a question on StackOverflow asking for the best way to achieve your goal.
- Swallow your pride and ask the guy or gal next to you.
Just don't spend all day wasting your time and the client's money reinventing the wheel and duplicating functionality that already exists in the framework.