in reply to Re: For Review: OOP DB Import
in thread For Review: OOP DB Import

Thanks, dash2, for your critique. If you haven't had a chance to look at my previous post, it might help explain some of my reasoning -- or it may not. :-)

1) It think Text::CSV_XS would be overkill for this data, which only takes two lines of code to parse.

2) You are absolutely right about the coupling between the two classes. I need to 'fish or cut bait.' I'm not really committed to either tight-coupling or de-coupling. I considered passing in an array ref containing the column names, but I think I'll go with your suggestion and build an 'insert all' method. (Of course, the 'insert' method is not entirely generic, since it executes a query prepared in the 'connect' method.)

3) There are several reasons I did not want to simply 'die' inside my methods -- for example, if I was processing multiple files and wanted to simply record any failures but continue processing with the next file. I could move the 'eval' outside of the object, but I felt like encapsulating these kinds of details was an OO advantage. But I would definitely like to discuss the pros and cons of various types of error-handling.

4) Any suggestions on what a 'debug' method should look like? It sounds like a great idea.

Thanks again for helping me rethink this.

Impossible Robot