Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options
 
PerlMonks  

Re^3: Conditional inheritance strategy

by BrowserUk (Pope)
on Oct 27, 2010 at 14:52 UTC ( #867744=note: print w/replies, xml ) Need Help??


in reply to Re^2: Conditional inheritance strategy
in thread Conditional inheritance strategy

If nothing else, having the initialisation class in the inheritance tree via @ISA, is baggage, if there are no other methods than _init(). Looking back at the OPs code, there seems to be little reason for calling the _init() routines as methods rather than subroutines.

Indeed, as no instance of the initialisation classes is ever instantiated, it could equally be termed "poor OO". And it is a weird use of "inheritance" in every sense. If the idea is simple to provide two methods of initialisation, better I would say to have them both in the main My package space called (say) _initFromXML() and _initFromJSON() and ditch the extra package spaces entirely.

But, as I said, it is quite hard to tell from what the OP posted, as he has obviously simplified the code for the purpose of the question. It is always possible that he also has code in each base package to persist the objects to disk or database, which might make all the difference.


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

Replies are listed 'Best First'.
Re^4: Conditional inheritance strategy
by JavaFan (Canon) on Oct 27, 2010 at 16:27 UTC
    If nothing else, having the initialisation class in the inheritance tree via @ISA, is baggage, if there are no other methods than _init().
    Well, calling two one element arrays "baggage" is stretching the meaning of "baggage". But even so, it's not baggage attached to any instance of the class. Just the classes themselves.
    Looking back at the OPs code, there seems to be little reason for calling the _init() routines as methods rather than subroutines.
    Hmm, yeah, but that seems to be true of at least 95% of OO code written. I'm not the worlds biggest OO fan, but if I were to do something like the OP, I'd use 3 classes as well, with two classes having just an init method (but with the inheritance tree as showed elsewhere in the thread).
    Indeed, as no instance of the initialisation classes is ever instantiated, it could equally be termed "poor OO".
    Really? You only use inheritance if you instantiate every class of your inheritance tree? (Or do you write "poor OO" code?)
    If the idea is simple to provide two methods of initialisation, better I would say to have them both in the main My package space called (say) _initFromXML() and _initFromJSON() and ditch the extra package spaces entirely.
    While certainly possible, it's not something I would do.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (6)
As of 2020-12-03 01:49 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    How often do you use taint mode?





    Results (49 votes). Check out past polls.

    Notices?