|Think about Loose Coupling|
Eliminating conditional code for GUI and text-mode operationby gnosti (Hermit)
|on Dec 07, 2007 at 06:52 UTC||Need Help??|
gnosti has asked for the
wisdom of the Perl Monks concerning the following question:
I have a program which processes data and produces outputs. I have concepts like Track and Track_Group, and templates for converting them into the chain configurations used by a sound engine to mix, route and process audio signals.
Right now all my code (except the GUI widgets part) is procedural, using hashes and arrays to store data. I am implementing two operating modes:
* A Tk GUI event loop
* A command-line parse-and-execute loop
My code, already close to 4k lines, is sprouting such conditionals as:
At the moment I have only about ten of these statements. Should I think about trying to eliminate them? What are my alternatives?
This is a concern as I am considering an incremental move over to a OO style and higher levels of abstraction. How might OO design or some other abstraction help me support this dual-interface ability?