I'm not sure how applying different roles to provide a standard method
is less complicated than delegating this method to various objects.
Using an object may be abstract and indirect, but fairly flexible and
a pretty standard thing to do.

On Fri, Jan 13, 2012 at 3:39 PM, Mark Hedges <[email protected]> wrote:
>
>
>
> On Thu, 12 Jan 2012, Dave Rolsky wrote:
>
>> It seems to me that this would be better written like this:
>>
>>   package Machine;
>>   use Moose;
>>
>>   has power_cycler => (
>>       is => 'ro',
>>       does => 'PowerCycler',
>>       handles => [ 'restart' ],
>>   );
>>
>> In other words, make a separate object that represents the
>> type of power cycler (or whatever you call it) and let
>> that handle restarting the machine.
>
> I haven't communicated clearly.  There may be a number of
> different ways to power cycle depending on the attributes of
> the host.  The point was to separate them into classes, then
> add the right one to the machine object, granting a uniform
> method that does what I mean.  There may be other methods
> that come along with being one or another kind of hardware.
> This seems over-abstract and indirect.
>
> Mark

Reply via email to