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

Re: ... Re: My first stab at OO perl...

by ichimunki (Priest)
on Jul 16, 2002 at 21:20 UTC ( #182234=note: print w/ replies, xml ) Need Help??


in reply to Re: (jeffa) 5Re: My first stab at OO perl...
in thread My first stab at OO perl...

Except that open can fail as a result of all kinds of things not under the control of the program(mer). Calling a constructor in a way that is not documented in the API for a module... well, if it works the way you expected it to, that's an undocumented feature. If it works, but not quite the way you wanted it to, that's a bug (in the mind of the programmer, anyway). If it just plain doesn't work, that's what one expects having read the documentation.

Personally, I'd go with the last of these. If your constructor contains a bit of unexpected magic, you may as well document it. And if you want to allow for $instance->new(), you'll have to painstakingly document whether this creates a new "empty" object, or whether it creates a copy of the instance it was called on. FWIW, I think of "new" as a class method no matter what, so to my mind providing a way to use new from an instance is just muddying the water.

Notes on reply: my point is that you will need to document this behavior, otherwise there is no reason to include it. And I have no idea what this adds to the module or how it helps programmers. It seems only to add a layer of indirection, which Perl OO already has enough of (imho-- and hopefully this will improve in Perl 6).


Comment on Re: ... Re: My first stab at OO perl...
Re: Re: ... Re: My first stab at OO perl...
by Anonymous Monk on Jul 16, 2002 at 23:23 UTC
    If it works, but not quite the way you wanted it to, that's a bug (in the mind of the programmer, anyway).

    Well, if it's not documented to work the programmer can't really expect anything from it. I don't see how that can be considered a bug if you can't expect it to work in any way at all.

    And if you want to allow for $instance->new(), you'll have to painstakingly document whether this creates a new "empty" object, or whether it creates a copy of the instance it was called on.

    How painstakingly is "Doing $obj->new is the same as doing ref($obj)->new"?

    -Anomo

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (8)
As of 2014-08-28 02:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (255 votes), past polls