Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

[OT] Re: Module Renaming Suggestions

by trammell (Priest)
on Jul 02, 2005 at 15:01 UTC ( [id://471926]=note: print w/replies, xml ) Need Help??


in reply to Module Renaming Suggestions

I think this module is too complicated to be called "Simple":
  • wouldn't it be even simpler if new() called open()? No sense in having a simple logging object that's in no condition to log anything.
  • I'm also not grokking why you need an exit() method. Sounds like functionality unrelated to logging.
  • for that matter, you can simplify further by making the object have exactly one state: OK. Just croak() if you can't open the logfile, and close the log by DESTROYing the object.

Update: I guess I'd say a truly simple log object would have exactly three methods: new, print, and DESTROY. Log::Trivial?

Replies are listed 'Best First'.
Re: [OT] Re: Module Renaming Suggestions
by TGI (Parson) on Jul 02, 2005 at 16:34 UTC

    I included an exit method so that I could easily log a message and exit with a specified error code and the same time. In an early project with this module, I found that I was regularly logging some message and then croaking with the same message. This made for an ugly mess and much duplicated code. To fix this, I added the exit method.

    While I can see your point about automatically opening the file, something about it bothers me. I could make it possible to control open and close in a call to the constructor. But, since I chose not to use named parameters in the method calls, at that puts a real constraint on how many parameters each method can take without becoming cumbersome. I'd have to add two parameters to new. I hate functions and methods with long parameter lists, so I have say I can't agree to this one. I also feel like there is a built-in expectation that you have to open a file to use it. This module is intended to be a rather thin wrapper around a file handle. Of course it would be a simple matter to subclass and add this feature if one desired it.

    Your points about auto-opening the handle and what it means to be simple really do emphasize brian_d_foy's point about good naming.

    Your point about closing on a DESTROY is well taken. I've mostly used this on windows systems, which don't choke up if you fail to close a filehandle. But it could be used on other systems that might have that failing. I really should add a DESTROY method.


    TGI says moo

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (4)
As of 2024-04-25 02:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found