The best way to design, IMHO, is to build your program to follow the pattern set by your data; for example, if your data is a tab-delimited text file in an OO world, an object representing the file would (a lot of the time) be the appropriate translation. If there were to be more than one file, an array of file objects would probably be good (but see below).
Here, it sounds to me like the best thing would be a People object containing references to a bunch of Persons. This model maps well to the data as it touches your program (the database is a single entity) and to the way the human mind works: the database contains information on a bunch of people, not just one, so it's best represented by People, not a Person.
If having Person objects in this interface seems like overkill for your program (though given your description, it doesn't sound to me like it would, unless you're working with a large table) the People object could implement that functionality with subs, like a new_person() function, and maybe find_person().
By the way, I don't advocate always patterning your code after the way your data is presented to it. The fact that you're reading your data from twenty log files doesn't mean you need 20 file objects. If your program is simply parsing the data from the files line by line and file by file, a Logparser object that reads the logs and returns lines on demand would probably be better. If your program is only going to see a slew of lines anyway, it might as well be presented with them in that form.
--
Love justice; desire mercy.
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.