Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

Re^5: Data Structures

by BrowserUk (Pope)
on May 02, 2008 at 17:14 UTC ( #684213=note: print w/replies, xml ) Need Help??


in reply to Re^4: Data Structures
in thread Data Structures

What about the argument for using object oriented code...

Don't. Three reasons.

  1. Unless you are already familiar with a technique, it is a steep learning curve.
  2. As specified, you would have an object interface that allowed you to instantiate instance and the get or set the attributes.

    But you can already do that with a hash, without the extra effort.

    The reasoning is that it will allow you to change your structure later, if necessary, and so save time.

    But expending effort now to save time for an eventuality that may never happen, that will take more memory and run more slowly, is total folly.

    Expend the effort when you know you need to and when you know in what way things have to chage.

  3. Let's say you did create a class (or probably 3, Seismic::Line, Seismic::Station and Seismic::Point3D ), then you read the file and create instances to hold the data:
    while( <FILE> } { my( @attributes = unpack '...', $_; my $object = Siesmic::Line->new( @attributes ); ## Now what? ## ???

    Where are you going to put you objects so that you can retrieve them when you need them??

    ### IN A HASH OF COURSE!!!! $lines{ $object->getLineNo() }{ $object->getStnNo() } } = $object; }

    So now, you've still got the HoHs in order to find the one you want, but instead of each leaf being an small anonymous array, it's an object (or nest of objects) that requires more memory, runs more slowly, uses clumsy unfamiliar syntax, and requires at least 5 times more effort to develop.

    For what? Just in case?

My advice is to stick with the HoHoAs. If the needs change, you can make objects later, but you'll still need the container to hold them and find the one you want.


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

Replies are listed 'Best First'.
Re^6: Data Structures
by YYCseismic (Beadle) on May 02, 2008 at 21:26 UTC

    Okay, well I think that about settles it, then. I'll stick with HoHoAs and forgo the OO structure. I don't want to needlessly take up space that can be better used elsewhere.

    Thanks for your help!

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (3)
As of 2021-04-22 03:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?