Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: Testing -- making a new constructor behave differently for one package

by chromatic (Archbishop)
on Jan 27, 2012 at 23:23 UTC ( [id://950467]=note: print w/replies, xml ) Need Help??


in reply to Testing -- making a new constructor behave differently for one package

I wrote about the way I solve this problem in You're Already Using Dependency Injection. In short, rather than hardcoding the name of a class to construct within your constructor, make the constructed object parametric—whether from passing an allomorphic equivalent to the constructor, using the default object, or overriding the accessor/builder from a subclass.


Improve your skills with Modern Perl: the free book.

  • Comment on Re: Testing -- making a new constructor behave differently for one package

Replies are listed 'Best First'.
Re^2: Testing -- making a new constructor behave differently for one package
by tj_thompson (Monk) on Jan 27, 2012 at 23:39 UTC
    Actually the name of the class I'm using is not hardcoded, and I believe the accessor where I get the name of the package to use might be an easier point to hijack the object creation instead of the actual new method. Thanks Chromatic!

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://950467]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (2)
As of 2024-04-24 23:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found