in reply to Re: Re: subclass and overridden constructor
in thread subclass and overridden constructor

Ah, sure enough -- if you look at the source of OnlinePayment.pm you'll see that it's got a very specific approach to subclassing already implemented.

It might be straightforward to make a package that was a subclass of a specific processor, such as Unleashed::AuthorizeCard::AuthorizeNet inheriting from both your Unleashed::AuthorizeCard and Business::OnlinePayment::AuthorizeNet.

If you want to dynamically handle whichever processor the end-user selects, you'll probably have to either generate subclasses on the fly, or use delegation rather than inheritance.

(More generally, this illustrates one of the advantages of well-factored frameworks that use delegation internally; for example, I can imagine a version of Business::OnlinePayment that was divided into separate Transaction and Processor classes, which would allow you to subclass Transaction without worrying which Processor it was connecting to.)

  • Comment on Re: Re: Re: subclass and overridden constructor

Replies are listed 'Best First'.
Re: Re: Re: Re: subclass and overridden constructor
by geektron (Curate) on Dec 03, 2003 at 22:12 UTC
    i looked at the source and realized that subclassing *wasn't* what i should be doing.

    i should have been writing a wrapper, not a subclass. so that's what i did, and stashed the Business::OnlinePayment object in the wrapper object. that takes care of the issue, and i just need an extra method call to access the processor object.

      You could use delegation to bypass that extra method call assuming you mean from the object users point of view