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

Re: Confused about splitting program into multiple files.

by jeffa (Bishop)
on Feb 15, 2004 at 15:55 UTC ( #329129=note: print w/replies, xml ) Need Help??


in reply to Confused about splitting program into multiple files.

"I cannot install this as a module on the system, I only have limited access to where I can put my files."

I would like to bring your attention to non-priviledged installations in case you didn't already know that you can install modules on your system. :)

(updated ... added paragraph)
Now then. As for exporting ... why do people think that exporting is easier to implement then OO? If you stick with OO methods (that is, you instantiate a class and use it's methods) then you never have to worry about cluttering namespace or getting the Export code correct. Besides, these days you can cheat big time with modules like Class::MethodMaker that "write the code for you." Observe:

my $dude = new Person; $dude->name('Spicoli'); $dude->age(20); print $dude->as_string, "\n"; package Person; use Class::MethodMaker new => 'new', get_set => [qw(name age)], ; sub as_string { my $self = shift; return $self->name . ' (' . $self->age . ')'; }
Much nicer. :)

jeffa

L-LL-L--L-LL-L--L-LL-L--
-R--R-RR-R--R-RR-R--R-RR
B--B--B--B--B--B--B--B--
H---H---H---H---H---H---
(the triplet paradiddle with high-hat)

Replies are listed 'Best First'.
Re: Re: Confused about splitting program into multiple files.
by davido (Cardinal) on Feb 15, 2004 at 16:16 UTC
    Ok, here's a question though. What made you choose to

    use Class::MethodMaker;

    instead of

    use base Class::MethodMaker;

    or

    use Class::MethodMaker; our @ISA = qw/Class::MethodMaker/;

    In other words, when should you choose inheritance rather than simple use? The barometer that I've kind of adopted is if I want my object or class to behave as a parent class, inherit. It seems that Class::MethodMaker is one of those cases.

    Please forgive my continued novicity on this subject. ;)


    Dave

      Because i still forget from time to time that one should always "favor aggregation over inheritance." :)

      UPDATE:
      Or am i second guessing myself again? Yes ... never mind my reply, i thought you were referring to something else. (But the concept of aggregation vs. inheritance is still important.)

      My usage simply follows what is illustrated in the POD. There is some syntactical sugar involved, so i don't read into the "useage" too literally -- think of Class::MethodMaker as magic. :)

      jeffa

      L-LL-L--L-LL-L--L-LL-L--
      -R--R-RR-R--R-RR-R--R-RR
      B--B--B--B--B--B--B--B--
      H---H---H---H---H---H---
      (the triplet paradiddle with high-hat)
      

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chilling in the Monastery: (6)
As of 2021-10-26 10:00 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My first memorable Perl project was:







    Results (90 votes). Check out past polls.

    Notices?