If you are going to approach this properly then you I suggest that you need to consider the MVC or Model, View, Controller design. The functionality of your program can be split into these parts with a bit of thought and analysis.
The data your program operates on forms the model and provides methods to access, update and delete the information it contains. The controller is your main application. It provides all the glue logic for your app and also also looks after the interaction between the model and the views.
Finally, the view presents the user with their view of the program. However, your program can have as many of these as you like. Consider your program as having two views, command line and GUI. The underlying data and the basic logic is the same, the interaction with the user has changed.
In essence, you have decoupled your program model from your program display. The view then looks after the interaction between the user and the program, presents the info and makes calls (via the controller) to the model to get relevant data.
I suggest you look at the Observer pattern as a start point. Here (in very simplified terms) you can register objects to listen to events from another object. In context, you can register a view or views to listen to the model. When its state changes, it can notify the views. The view then grabs the info it requires and uses its own logic to display that to the user.
Hope that helps :)
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.