http://www.perlmonks.org?node_id=543742

I've just uploaded Class::CGI 0.10 to the CPAN and it should hit mirrors soon. I've finished implementing better error handling and while enhancements to the module are anticipated, it's essentially feature complete. However, when I put out an RFC about this module, some folks hammered me for "reinventing the wheel". After all, numerous other modules, including the excellent Data::FormValidator, solve the problem that Class::CGI attempts to solve. So why would I reinvent a wheel? After all, I've warned other people not to do that. Doesn't that make me a hypocrite?

I've reinvented this wheel for the same reason I don't have Z-Rated tires on my car. Z-Rated tires are softer and more expensive than regular tires and they don't last as long. Why on earth would someone want to buy them? It's simple: because of how Z-Rated tires are designed, they grip the road better than regular tires and are excellent for cornering at higher speeds. I don't need them on my car, but a high performance car does need them. Reinventing this wheel is necessary because the car being driven needs different behavior.

To stretch the analogy further, you wouldn't want to put a car's tires on a motorcycle. Or imagine trying to put them on a train! You can't. Even though all of the tires solve the same basic problem, they do so in different ways. It's OK to reinvent a wheel if you have a particular itch which needs to be scratched. CGI::Simple, the module upon which Class::CGI is based, is an excellent example. It passes all of CGI.pm's tests for which CGI::Simple is implementing duplicate features, it omits the HTML generating code, it's faster and it doesn't try to provide the features in both an objective and functional interface.

So when you should you not reinvent the wheel? You should probably not do this if you can't demonstrate a clear difference in what you're offering or you don't have a good understanding of the problem you're trying to solve. Sure, it's OK to do this as an exercise to better understand the problem space you're working in, but most folks who reinvent the wheel seem to do so very badly. They turn out buggy code which doesn't offer the features that well-established alternatives provide.

Class::CGI may not fit your particular needs or coding style, but it's clean, easy to use and is markedly different in approach from the alternatives (which are listed in the "See Also" section of the docs). Don't dismis the module merely because I'm offering a Z-Rated alternative to what you're currently using.

Cheers,
Ovid

New address of my CGI Course.