Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

I am going to approach question from a different angle.
I am going to assume by "would then be accessed as" and by "Is there an easier, more efficient way to do this?" you may be talking about interface more then performance.

"accessed as" wreaks of api, as does 'easier'. I'm going to imagine that efficient means you want to be able to remain efficient in your job as in you don't want to go insane in 6 months- and create something important that only you know how to use...

I smell poop here.
Perl Object Oriented Programming.

I am trying to suggest that.. let your code be all nuts and creepy.. but.. provide an object oriented interface. Then later on you can worry about the innards and not change the interface.

Wouldn't it be nicer to interact with ...

use Seismic; my $s = new Seismic; my $lines = $s->lines; my $line0 = $s->line(0); my $line1 = $lines->[1]; my $stations = $line0->stations; my $station0 = $stations->[0]; my $station1 = $s->line(0)->station(1); my $x = $station0->easting; my $y = $station0->northing; my $z = $station0->elevation; my ($x,$y,$z) = $station1->xyz;

You can then rearrange your code, change your hash hierarchy, and it won't change your scripts using it, etc!

I've done some crazy hash stuff like this before- and looking back, this is stuff that's a nightmare to maintain interaction with. The interface really should be separated from the innards.

This is what OO is for, this is what computers are for, not people, imho.

Putting the extra week or two to learn some OO and implement it here- will save you countless hours later.


In reply to Re: Data Structures by leocharre
in thread Data Structures by YYCseismic

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (3)
As of 2024-04-20 02:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found