Hello again, all you venerable chaps & chappesses,
After a relatively prolonged absence (from cluttering this forum with my trivial perl questions), I thought it was once again time I bolstered my candidature for the useless brain-dead question of the year award (it makes a change from pressing for the equivalent award for answers/responses:-)), so here goes...
In my current incarnation, I've encountered numerous situations of late whereby a called method could do with establishing, not just the package/sub i.e. class method details, but the instance i.e. object, details of the caller - the currently vexatious situation revolves around the implementation of a dynamic bi-directional relationship between classes and indeed, objects.
To my (obviously inadequate) mind, the self-evident answers have, if not problems, then at the very least, limitations...
- Passing the caller class/instance as an argument looks not a little inelegant and also IMO, violates one, or more, OO rules & best practice(s).
- The use of inheritance is, apart from being frowned upon by the powers that be (since composition is the new inheritance), not applicable in all but one of the instances (pun intended)
IMHO there ought to be a method to identify such details in a more elegant, perl-like manner - in either...
- A manner similar to that of the automatically supplied called class/instance details or...
- An extension to caller() such that either the package or an instance (dependant on whether it was called by a package sub/class method or an object method) is returned as the 1st element of the list.
Question is, is it just me ... or do any of you have a view &/or an alternative solution ?
OTOH, maybe in addition to the above, the best solution would be to find/write a class to implement class/instance inter-relationships whereby each side of the relationship knows about both the...
- The class on the 'other side' of the relationship & the ...
- Arity of its own side of the relationship
.oO(...wonders whether if, in the light of 20/20 hindsight, this node might not be re-housed as a meditation - if the nodereaper can leave it alone that long:-)
A user level that continues to overstate my experience :-))
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.