It's pretty cliche that reinventing the wheel is evil. Of course, if there's a good canned solution, I agree. The question, though, is how far to you go to avoid reinventing the wheel when there is no optimal existing wheel? Here are some cases:
- The existing wheel is in a different language than you're using or want to use. You'd have to switch languages or write a bunch of crufty glue code to use it.
- The existing wheel only does approximately what you want and you'd have to resort to some kludgery to make it do exactly what you want. For example, maybe the existing wheel is a standalone program and you need a library. You might be able to fake it using a bunch of shell() commands, but that's a massive kludge. Another example is if the existing wheel is something mathematical and only does exactly what you want after you apply a bunch of transformations to the input that may be unnecessarily slow or lose precision.
- You just plain hate the API or UI of the existing wheel at a subjective level.
- The existing wheel is a huge library that is designed like a Swiss army knife, is very complex to use, and adds a massive dependency to your codebase, when all you need is a tiny subset of the functionality.
- The existing wheel is implemented in poorly documented spaghetti code, and you'd practically have to reverse engineer it if you ever needed to make even the slightest modification, or possibly even to figure out how to use it.