file converter design pattern

T

Tom Whittaker

I am creating an application that will allow the user to specify
different types of input files, and then my application reads in the
file, parses it, extracts rows and columns/fields, and stores the
contents in a mySQL table (my common format for all input data). I
never change the file I read in. I read it once and discard it.

For example, a file could be an Excel file or a database file.

I'm thinking about using the strategy pattern, or potentially the
template method pattern.

Does anyone have any insight into the best design pattern(s) to use
for this feature?
 
P

Pavel

Tom said:
I am creating an application that will allow the user to specify
different types of input files, and then my application reads in the
file, parses it, extracts rows and columns/fields, and stores the
contents in a mySQL table (my common format for all input data). I
never change the file I read in. I read it once and discard it.

For example, a file could be an Excel file or a database file.

I'm thinking about using the strategy pattern, or potentially the
template method pattern.

Does anyone have any insight into the best design pattern(s) to use
for this feature?
If many file formats you are going to implement will have similar logical model
(say, you would parse out raws in sequence and, within a row, fields in
sequence), you may want to consider Visitor or Builder patterns.

If I were given such a problem, however, I would not jump into the patterns from
the very beginning. I would implement first one or two formats ad-hoc and then
revisit to understand what could be scavenged for the next one. Then, I would
re-factor. This way I would grow abstractions organically and would avoid
wasting time via designing for the future that would not come.

Hope this will help,
-Pavel
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top