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

comment on

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

Ok, that makes sense, but that isn't what Im talking about. My constructors are always

sub new { my $class = shift; my $obj = {}; # possible other initialization here # testing for args, making sure defaults are sane etc.. bless($obj, $class); # possible havy duty init stuff here # init new objects inside this one, make expensive # connections now, if its Ok to do that. $obj; } # END sub new

In regards to the function/method conundrum.I only write methods. first line is always
my $self = shift; or my($self,@other_stuff) = @_;
I tend to have each method self sustaining and not necessarily reliant on other methods, I.e if inserting data, make sure its going to be clean when I pull it out, if some resource should exist (an open socket for instance) and it doesn't, either bomb out or possibly initalize it now. This way, if I have solved a problem once, then I can pick up a few methods from module_a, and drop into module_b with relative ease. I can see where you are going with the thread though, and I simply didn't realize the horrific road that could come from a simple @EXPORT_OK = qw(new); To me it means, the only thing you can get at is new, and I expected the coder to write $obj = l2kashe->new(@args); (yes I understand that expectations are not always what happens) I try to always provide at least rudimentary documentation, and always note the appropriate way to use the module is

use L2kashe; my $l2 = L2kashe->new();

Thanks for taking the time to clarify, and my apologies to the other monks for not understanding the depth of the issue. I'll just drop use Exporter and those variables from my code until truly needed. Again, thanks

On a side note, it might do to put a note in the tutorial about stub module generation via h2xs -A -X -n some::module, as that is where I saw use Exporter, assumed it was good practice to use (yes I realize how bad that is now in hindsight), and defined what I thought was a sane value.

A humbler monk

use perl;


In reply to Re: Re: Re: Re^4: USE or Require? by l2kashe
in thread USE or Require? by BUU

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 examining the Monastery: (7)
As of 2024-04-19 08:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found