Even though it works, it is not a normal practice for the guts of a
component to know what is going on outside.
Alghouth it's a reach, it is possible that your update_product method
could accept URL variables, rather than form variables. If this were
true, then you would have to modify your
Couple others suggestions...
You need to VAR your query:
In your cffunction tag right after the cfargument tag, add:
cfset var qUpdateProduct =
Also, Lose the and # characters:
cfset variables.product_id = arguments.product_id
(However, you don't really need to set this variable unless
I generally make my CFCs as generic as possible. You are updating a
product and looking in the form scope for everything. It'll work,
sure. But, what if in the future you get an entire cart. Then you
won't be looking in the form scope, you'll be looking at something in
the session or
-Original Message-
From: Rick Faircloth [mailto:[EMAIL PROTECTED]
Sent: Wednesday, October 22, 2008 10:10 AM
To: cf-talk
Subject: How can this CFC be improved?
Hi, all... still trying to get a handle on using CFC's.
Here's an update method I wrote and I'd like to know
what can
Thanks for the feedback, Mike.
Even though it works, it is not a normal practice for the guts of a
component to know what is going on outside.
What's the difference, ultimately, in referring to the form variables
in cfset myObj.update_product(form, product_id) and just referring
to them
the lifetime of the component's instance
Such as, if the variable is going to be used in other methods
before returning data to the calling page?
Dawson, Michael wrote:
Couple others suggestions...
You need to VAR your query:
In your cffunction tag right after the cfargument tag, add:
But by referring to the form directly, your CFC already knows about the
outside. I am just learning about CFCs and OO myself, but I thought the
point of them was to make them independent of what was going on the
outside, and to just pass them the information that they needed regardless
of the
Thanks for the feedback, Jake.
All that reassigning of variables is a lot more typing. (But, can I
get around
reassigning each form variable individually by using the
argumentCollection
attribute when calling the method?)
I think I see what you're saying, however.
By translating the type of
10:15 AM
To: cf-talk
Subject: Re: How can this CFC be improved?
Thanks for the feedback, Mike.
Even though it works, it is not a normal practice for the guts of a
component to know what is going on outside.
What's the difference, ultimately, in referring to the form variables in
cfset
Correct.
-Original Message-
From: Rick Faircloth [mailto:[EMAIL PROTECTED]
Sent: Wednesday, October 22, 2008 10:19 AM
To: cf-talk
Subject: Re: How can this CFC be improved?
the lifetime of the component's instance
Such as, if the variable is going to be used in other methods
I think I'm beginning to understand your reasoning.
It's just taking some time for me to get to the best practices of CFC
usage.
Trying to get anything to work at first keeps my projects moving, while
beginning to employ different coding techniques. I'm basically trying to
learn by writing code
Good...maybe I'll catch on before the next decade rolls around...
Jake Churchill wrote:
Right!.
Your call (if you are using the form scope) would look like this:
object.update_product(argumentCollection=form);
or
object.update_product(duplicate(form));
Same thing if you are looking at
Using CFCs as function collections like you are doing is the easy part.
Wait till you start creating a true OO backend. I'm working on my first
right now and I thought I was really good at CFCs until I started
this... No pain no gain though, right?
Rick Faircloth wrote:
Good...maybe I'll
Right!.
Your call (if you are using the form scope) would look like this:
object.update_product(argumentCollection=form);
or
object.update_product(duplicate(form));
Same thing if you are looking at something in the session:
object.update_product(argumentCollection=session.key);
Rick Faircloth
Gotcha... thanks.
Charlie Griefer wrote:
even if you're a solo developer, creating components that are truly
black-boxed (e.g. they know nothing of the world outside them), you're
creating components that you can potentially reuse yourself. Also, by
passing in the information explicitly
No pain no gain though, right?
As long as whatever is causing the pain doesn't kill you! :o)
Rick
Using CFCs as function collections like you are doing is the easy part.
Wait till you start creating a true OO backend. I'm working on my first
right now and I thought I was really good
even if you're a solo developer, creating components that are truly
black-boxed (e.g. they know nothing of the world outside them), you're
creating components that you can potentially reuse yourself. Also, by
passing in the information explicitly (rather than referring to outside
scopes from
Rick, imagine how it would be if (as is fairly common) you have
business objects (beans) handling single items, and DAO cfcs handling
all the database interaction back and forth.This is the scenario i
drew in the tutorials I wrote ...
So in the application scope you have a DAO - just one .
could move specific logic from the main .cfm.
It took a couple of iterations, but it works fine and it's easy enough
to maintain.
Mike
-Original Message-
From: Rick Faircloth [mailto:[EMAIL PROTECTED]
Sent: Wednesday, October 22, 2008 10:39 AM
To: cf-talk
Subject: Re: How can this CFC
Thanks for the overview, Mike.
I see what everyone's saying about the encapsulation. I'm just trying to
make all the pieces of the puzzle fit. Your tutorial was helpful. It
was a little
advanced in some respects. I just needed to approach the CFC's a little
more carefully, until I could
Sounds like a good approach.
I'm about to duplicate much of the work I've done on a recent project
for another client and I plan to use CFC's instead of putting the
code into my .cfm's. (I wouldn't call what I'm going to do OOP... :oP)
But since I've already written the code procedurally once,
For now I probably wouldn't worry about DAOs and other related concepts.
Build a strong foundation by encapsulating the CFC methods so that they
don't rely on any external variables. That'd be a good start.
Once you recoil in terror at seeing a CFC method reference application or
session or form
I think I can handle that approach and stay sane! :o)
Charlie Griefer wrote:
For now I probably wouldn't worry about DAOs and other related concepts.
Build a strong foundation by encapsulating the CFC methods so that they
don't rely on any external variables. That'd be a good start.
Once
Oh, and VAR your variables!!!
If you don't, Ray Camden will be knocking at your door.
Mike
-Original Message-
From: Rick Faircloth [mailto:[EMAIL PROTECTED]
Sent: Wednesday, October 22, 2008 1:26 PM
To: cf-talk
Subject: Re: How can this CFC be improved?
I think I can handle
Now *that* would be scary this close to Halloween! :oP
Dawson, Michael wrote:
Oh, and VAR your variables!!!
If you don't, Ray Camden will be knocking at your door.
Mike
~|
Adobe® ColdFusion® 8 software 8 is the most
25 matches
Mail list logo