note
Anonymous Monk
The advantage of returning <tt>$self</tt> is that the user of the code is free to decide to use either style, that is:
<code>
$window->title('foo');
$window->border(20);
</code>
Or
<code>
$window->title('foo')->border(20);
</code>
If you don't return <tt>$self</tt>, you're taking the decision for the user. Which isn't very friendly.
<p>
Now, I don't have a problem with
<code>
$window->title('foo')->border(20);
</code>
If I see this code, and I've no idea what the <tt>title</tt> and <tt>border</tt> methods are, my assumption will be that the title of the window is set to <em>foo</em>, and the border will be <tt>20</tt> pixels wide. I don't see the problem either, unless you have windows with labelled titles, so that there's the possibility that <code>$window->title('foo')</code> returns the 'foo' title.
<p>
I probably won't do the chaining as you give. I'd probably write it as:
<code>
$window->title('foo')->border(20);
my $button = $window->child->border(20);
my $label_formatting = $button->child->font_style;
</code>
<p>
But I will return <tt>$self</tt> from accessors.
417872
417872
13