Chris: Looks like the same thing I've been playing with. Let me know how you come out on it and what you find the ultimate solution to be.
Rob Love Scope Mapping LLC Cell (903) 647 1301 Fax (817) 288 0713 From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] On Behalf Of Christopher Jordan Sent: Friday, September 14, 2007 9:29 AM To: Dallas/Fort Worth ColdFusion User Group Mailing List Subject: Re: [DFW CFUG] Ack! I need help from an OO-type person Hey everyone, Thanks for responding. @Jeff: Thanks for the links. And it's a deal. ;o) @Rob: Are you saying that I should do something like: <cfcomponent ...> <cfset variables.instance = structNew()> <cffunction name="blah" ...> <cfset variables.instance.myParameter = "I've drunk the OO Kool-Aid"> ... <cfreturn this> </cffunction> ... </cfcomponent> @Adrian: Well, you're probably right, but aside from separating things out, shouldn't what I've got here work? I need to have this going by the end of today, and I don't feel like I've got the time to re-factor it right now. Thought I'll take full advantage of your articles very soon as I've got a couple of OS projects I want to work on, and I think they'd be great candidates for diving head first into OO from the design phase up (Dave: the "looking for all the nouns in the program" idea seemed to strike a chord with me, and I'm going to try using that idea in these little side projects of mine.) @Dave: You're spot on with how I'm instantiating it. I wrote the getters and setters just in case I needed them later. In the case of the setters, I'm of course trying to use them in the init function as I think I saw you do in one of your examples. The idea was that I would just run the following two lines of code: <cfset LienApplication = CreateObject("component", "path.to.my.LienApplication").init(form.LoanNumber)> <cfset myPDFLink = LienApplication.WriteLienApp()> And then myPDFLink would contain a link to the file that I saved in that method. The object explorer does indeed show the methods as public, and I don't know what happens when I try to dump getMetadata(LienApplication)... I'll give that a try when I get to that client today. Right now, I'm at another client finishing up some work, but I expect to be back at the client in question after lunch. Thanks everyone! Chris On 9/13/07, Dave Shuck <[EMAIL PROTECTED]> wrote: I tend to agree that there is quite a bit going on in that CFC, but aside from that I would be interested in how you are instantiating it. Are you doing something like this? <cfset LienApplication = CreateObject("component"," whatever.dot.path.LienApplication").init(LoanNumber=[whatevernumber]) /> Also, I realize that by default methods are public, but it is good practice to declare their access attributes, in addition to setting output="false" to help reduct whitespace generation. When you view the object explorer, does it show that the methods are indeed public? What happens when you take the above instantiation and then call: <cfdump var="#getMetadata(LienApplication)#" /> p.s.... side note: thanks for your work on the cfjs plugin. You saved me some good time today! On 9/13/07, Adrian J. Moreno <[EMAIL PROTECTED]> wrote: Chris, At first glance, I think you're mixing too many things into a single CFC. The init() method looks like it should be a Service Object by itself since it calls a DAO (Loan.cfc) to get data and populate a bean, the CFC getters and setters should be a Bean by themselves and the "other functions" might need to be part of the Service object or possibly even a separate AppWriter.cfc. Check out the series I mentioned at the CFUG: http://www.iknowkungfoo.com/blog/index.cfm/2007/8/22/Object-Oriented-Coldfus ion--1--Intro-to-Objectcfc Part two explains what "this" is. Let me know if it helps any or if there's anything that I could explain further. I'm off to the gym, but I'll be working on the DAO entry when I get back. -- Adrian Christopher Jordan wrote: > Okay, > > So I'm trying to implement *some* of what I saw the other night, and it's > not working. I've got a CFC called LienApplication.cfc and it contains an > init function that takes a loan number, runs three queries, and then sets > several instance variables with values returned from each of the queries. > I'm using all the setters I wrote to set those values. Then I return 'this' > (without the quotes... you know what I mean). > > The problem is that if I try to instantiate the cfc and then dump the > subsequent object it's empty! No methods, no properties.. nothin'! However, > if I view it through the CFC introspection stuff (like Dave showed us the > other night), I can see all my methods. > > I'm at a loss! I'.ve done this sort of thing before (once or twice) without > any problems, but now I'm trying to use the getters and setters idea. I > should also mention that I tried shortening up my init function to just: > > <cffunction name="init" access="public" returntype="LienApplication"> > <cfset instance.test = "ChrisRocks"> > <cfreturn this> > </cffunction> > > (yes, instance is a structure declared outside of the function just below > the cfcomponent tag) > I still get nothing! :o( > > If instead of trying to just do a <cfdump var="#myobj#"> I try to do > something like <cfdump var="#getCustomerFirstName()#"> I get an error > telling me that "Element Instance.CustomerFirstName is undefined in > Variables". :o( > > I'll reprint my entire cfc here (and attach it as well) for anyone who > thinks they'd like to take a look at it and could help me out. I've got to > run home and celebrate my mother's birthday, but I'll be online later this > evening to see if anyone has responded. > > Thanks so much everyone! > Chris _______________________________________________ Reply to DFWCFUG: [email protected] Subscribe/Unsubscribe: http://lists1.safesecureweb.com/mailman/listinfo/list <http://lists1.safesecureweb.com/mailman/listinfo/list> List Archives: http://www.mail-archive.com/list%40list.dfwcfug.org/ http://www.mail-archive.com/list%40dfwcfug.org/ <http://www.mail-archive.com/list%40dfwcfug.org/> DFWCFUG Sponsors: www.instantspot.com/ <http://www.teksystems.com/> www.teksystems.com/ -- ~Dave Shuck [EMAIL PROTECTED] http://daveshuck.instantspot.com _______________________________________________ Reply to DFWCFUG: [email protected] Subscribe/Unsubscribe: http://lists1.safesecureweb.com/mailman/listinfo/list List Archives: http://www.mail-archive.com/list%40list.dfwcfug.org/ <http://www.mail-archive.com/list%40dfwcfug.org/> http://www.mail-archive.com/list%40dfwcfug.org/ DFWCFUG Sponsors: www.instantspot.com/ www.teksystems.com/ <http://www.teksystems.com/> -- http://cjordan.us
_______________________________________________ Reply to DFWCFUG: [email protected] Subscribe/Unsubscribe: http://lists1.safesecureweb.com/mailman/listinfo/list List Archives: http://www.mail-archive.com/list%40list.dfwcfug.org/ http://www.mail-archive.com/list%40dfwcfug.org/ DFWCFUG Sponsors: www.instantspot.com/ www.teksystems.com/
