Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: OO Application Design

by strider corinth (Friar)
on Sep 25, 2002 at 21:31 UTC ( [id://200746]=note: print w/replies, xml ) Need Help??


in reply to OO Application Design

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.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://200746]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others musing on the Monastery: (5)
As of 2024-03-29 22:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found