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
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.