Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: Can you override lexically scoped variables when sub-classing a module.

by ELISHEVA (Prior)
on Oct 11, 2012 at 21:02 UTC ( #998548=note: print w/ replies, xml ) Need Help??


in reply to Can you override lexically scoped variables when sub-classing a module.

Why are you opposed to changing the original code? Is this a third party provided file so that your changes will be wiped out by the latest update? If so, that might be a good reason - PROVIDED that you document a hack using PadWalker very carefully with lots of asterisks and capital letters or other PAY ATTENTION TO ME signs in the code that uses. Anything private to a third party module is likely to get renamed, reengineered, restructured, or otherwise disappeared. Despite your goal of not touching third party code, your hack may still break with the next release of the third party code.

If this is internal company code, then you really are better off getting permission to change "my" to "our", even though it is major hassle. The problem with hacks like using PadWalker is that they are virtually impossible for the next programmer to discover who has your job after you. Anyone reading the source code of the file with the "my" variable will reasonably expect that variable not to be vulnerable to being messed with by outside modules. They will be going nuts trying to figure out what in the original module is making it change (nothing of course) they will NEVER think to look elsewhere outside of the file in the many company scripts to find your module playing hack with PadWalker. "my" is like a contract with future maintainers that outsiders won't muck with this.

Of course if the pesky module with "my" is yours and yours alone, then again why NOT change it to "our"?


Comment on Re: Can you override lexically scoped variables when sub-classing a module.
Re^2: Can you override lexically scoped variables when sub-classing a module.
by learnedbyerror (Beadle) on Oct 11, 2012 at 22:01 UTC

    I'm not opposed to changing the original code. It is a 3rd party and I have a request out. Eventually, it will get done, just not as fast as I would like. I have been looking at Padwalker and considering it. However, my gut is telling me that this isn't a "good" path for all of the reasons that you pointed out.

    Given your feedback and the feedback from the other monks, I think I am going to create a patched local copy and then sub-class it. This will minimize the impact on the maintenance to reverse out when changed.

    Thanks! lbe

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (5)
As of 2014-08-30 20:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (293 votes), past polls