On Jan 18, 2008 8:05 AM, Marc Esher <[EMAIL PROTECTED]> wrote: > But if he could call the 3rd party code directly, he could just call his > own methods right after. Is that right Clarkee? I was assuming that the > framework itself is calling method1() and that his code is not. >
Oh. I didn't notice that he had mentioned a framework. Depending on the framework then, it may have hooks or events to listen for itself. In any case, the problem with calling your own methods with each call to the 3rd party method is that you need to remember to do it every time. Much better to encapsulate that in a method somewhere and only call that. (I'm just clarifying. IIRC, you're example did that.) Sam > > > On Jan 18, 2008 9:02 AM, Sam Larbi <[EMAIL PROTECTED]> wrote: > > > That's how I would do it. Instead of using the 3rd party code > > directly, provide your own derived version of it that simply adds hooks and > > calls the 3rd party code. > > > > Sam > > > > > > > > On Jan 18, 2008 7:56 AM, Marc Esher < [EMAIL PROTECTED]> wrote: > > > > > In that code I posted (which probably won't work anyway), there's no > > > editing of the 3rd party code. he's injecting methods into objects, not > > > literally modifying code. > > > > > > best. > > > > > > marc > > > > > > > > > On Jan 18, 2008 8:36 AM, Alan Livie <[EMAIL PROTECTED]> > > > wrote: > > > > > > > > > > > The problem with this is he would still have to edit the 3rd party > > > > code to use the new cfc. > > > > > > > > If the cfc's are managed by a factory / Coldspring then its less of > > > > a problem as the change would only need to happen in the factory / > > > > coldspring xml config file > > > > > > > > The new cfc could extend the 3rd party one and polymorphism can be > > > > used to override the method as suggested below. > > > > > > > > If the cfc's are not managed by a factory then 3rd party code would > > > > need to change to call the new cfc in which case the original cfc may as > > > > well be changed. > > > > > > > > It's not an easy one! > > > > ________________________________________ > > > > From: [email protected] [ [email protected] ] On Behalf > > > > Of Marc Esher [EMAIL PROTECTED] > > > > Sent: 18 January 2008 13:19 > > > > To: [email protected] > > > > Subject: [CFCDEV] Re: Running a child method without a parent > > > > knowing - Can it be done? > > > > > > > > this is probably way out there, and it's certainly far more > > > > confusing and probably less maintainable and overall a bigger pain in > > > > the > > > > butt than your proposed solution, but it's friday so what the hell: > > > > > > > > i think you technically could do something like this: > > > > > > > > you could have a new component that had these functions: > > > > > > > > <cfcomponent hint="something i'm gonna inject"> > > > > > > > > <cffunction name="method1"> > > > > ....args same as original method1's arguments ... > > > > > > > > <cfset originalMethod1(arg1=arg1, arg2=arg2....)> > > > > > > > > <cfset doMyDateStuff()> > > > > > > > > </cffunction> > > > > > > > > <cffunction name="doMyDateStuff"> > > > > ... do my date stuff here ... > > > > </cffunction> > > > > > > > > > > > > </cfcomponent> > > > > > > > > > > > > > > > > i'm assuming you at least have an instance of the original component > > > > containing method 1, or access to that component, so: > > > > > > > > in your code somewheres: > > > > > > > > <cfset myInjector = createObject("component","MyInjector")> > > > > > > > > > > > > > > > > Now's where it gets weird: > > > > > > > > <!--- 'copy' method 1 into a new function ---> > > > > <cfset thirdPartyObject["originalMethod1"] = > > > > thirdPartyObject["method1"]> > > > > > > > > <!--- override original method 1 with the method1 from your injector > > > > ---> > > > > <cfset thirdPartyObject["doMyDateStuff"] = > > > > myInjector["doMyDateStuff"]> > > > > <cfset thirdPartyObject["method1"] = myInjector["method1"]> > > > > > > > > > > > > when method1 is called, it's going to call the original method 1 > > > > that you created by "copy", then it's going to call your date function. > > > > > > > > Now, what I don't know is: A) whether this will work at all. > > > > probably not. B) whether when you overwrite method1 it also technically > > > > overwrites originalMethod1 since originalMethod1 just points to method > > > > 1. > > > > That's my suspicion. > > > > > > > > But hey, if you have nothing else to do and want to futz around with > > > > creating hard to understand, unmaintainable method injection stuff that > > > > will > > > > break whenever ThirdParty releases a new version, it might be fun to at > > > > least give it a shot. > > > > > > > > have a great day. > > > > > > > > marc > > > > > > > > > > > > > > > > > > > > On Jan 18, 2008 6:47 AM, Clarkee21 <[EMAIL PROTECTED]<mailto:[EMAIL > > > > PROTECTED]>> > > > > wrote: > > > > > > > > Hi Marc, > > > > > > > > Yeah we did consider that but there was a few twists and turns to > > > > that > > > > solution which would have resulted in us basically rewritting the > > > > core > > > > method as a database script. > > > > > > > > I've actually just had a bit of a brainstorm with one of the guys > > > > here > > > > and I think we might have come up with a solution in that we just > > > > leave the dates and run a scheduled task to wipe any redundant data > > > > at > > > > a later stage. > > > > > > > > Cheers, > > > > James > > > > > > > > On Jan 18, 11:30am, "Marc Esher" < [EMAIL PROTECTED]<mailto:[EMAIL > > > > PROTECTED]>> > > > > wrote: > > > > > I've never heard of anything native in CF for doing this. > > > > > > > > > > I'm going to assume that if you're asking this there isn't much > > > > use in going > > > > > back to the 3rd party tool creators and asking them to add > > > > listener hooks. > > > > > > > > > > but what about doing it the old fashioned way: putting a trigger > > > > on your DB > > > > > that looks for changes from 1 to 0 in that column and then > > > > responds > > > > > appropriately. > > > > > > > > > > Best, > > > > > > > > > > marc > > > > > > > > > > On Jan 18, 2008 6:11 AM, Clarkee21 <[EMAIL PROTECTED]<mailto:[EMAIL > > > > > PROTECTED] >> > > > > wrote: > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > > Hi guys, > > > > > > > > > > > I'm a bit of an OO newbie so I was wondering if someone on here > > > > might > > > > > > be able to help me find an approach to my problem. > > > > > > > > > > > I have two methods - > > > > > > Method #1 is a core part of a 3rd party open source application > > > > we're > > > > > > running in-house. > > > > > > Method #2 is part of a plugin I'm developing for this > > > > application. > > > > > > > > > > > Method #1 is used to simply switch a section of a page on or > > > > off. In > > > > > > other words is sets a DB field "visible" to 0 or 1 depending on > > > > the > > > > > > section's current status. > > > > > > > > > > > Method #2 is used to reset two date fields in my table. > > > > > > > > > > > What I want to do is somehow have method #2 executed the moment > > > > method > > > > > > #1 has run but, and here is the twist, I don't want to have to > > > > rewrite > > > > > > anything in method #1 or it's object. This is mainly because a) > > > > we're > > > > > > planning to release this back out into the community at a later > > > > stage > > > > > > so I'd rather have it as a single directory of stand-alone files > > > > and > > > > > > b) it would mean we'd have to insert the code into method #1 > > > > again and > > > > > > retest if we ever upgraded. > > > > > > > > > > > Is there anyway that method #2 can "listen" for method #1 being > > > > > > executed without method #1 being aware that there is anything > > > > else > > > > > > going on? > > > > > > > > > > > Cheers, > > > > > > James- Hide quoted text - > > > > > > > > > > - Show quoted text - > > > > > > > > > > > > > > > > > > > > > > --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "CFCDev" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/cfcdev?hl=en -~----------~----~----~----~------~----~------~--~---
