Aristotle wrote: I think this is a problem best left unaddressed. In general OO the Law of Demeter forbids such deep hierarchy navigation constructs.
I am wondering if I missed what you were trying to say. The Law of Demeter lets us know that this is bad:
my $company = $sales_rep ->office ->division ->company;
This enforces a class heirarchy which becomes inflexible since the user's code must now know the class heirarchy (bad!) and this makes changing the heirarchy more difficult. However, there's nothing wrong with this:
$sales_rep ->set_title($title) ->set_office($office) ->set_something_else($foo);
In this case, there is no enforcement of a particular class heirarchy and you therefore aren't bound by one. With mirod's example, I think we have the same thing:
$doc ->root ->last_child('section') ->first_child('title') ->att('num')'
While these are accessors and not mutators, we still appear to only be dealing with only one class and are less concerned with restructuring things. We have a published interface that only one class needs to maintain, whereas with my first example, we appear to have the various classes needing to know about the published interfaces of other classes and this greatly compounds the problem, thus increasing maintenance costs.
If I am misunderstanding the situation (or your objection), please let me know.
Cheers,
Ovid
New address of my CGI Course.
In reply to Re: Re^4: Autoboxing: Yes or No?
by Ovid
in thread Autoboxing: Yes or No?
by Ovid
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |