|Think about Loose Coupling|
Reusing code for Mysql and Mason Applicationby neilwatson (Curate)
|on Aug 06, 2004 at 15:28 UTC||Need Help??|
neilwatson has asked for the
wisdom of the Perl Monks concerning the following question:
I'm working on a Mason, Mysql inventory application. For any item, whose information may be in one or more tables, the user will have an option to view, edit or add a new item. I want avoid having three fully separate pieces of code that each fetch and then display. I think it would be easier to share some common code.
My idea was to have three separate components. One to view, one to edit, and one that gets the data (Mysql/DBI) that gives it back to the first two components.
Consider these simple, untested, examples:
Edit or add data:
Get data from database
Am I on the right track? If so, what kind of data structure should I create to pass the table data back and forth?
An even better idea would be to pass the SELECT statement to a generic get_data component that would return the table in some structure. Is that possible?