Best means of setting a library of reusable code

2013-06-25 Thread Rick Faircloth

Hi, all...

I've been writing code for every project I've worked on for the last 10+
years.
I did that purposefully to make myself work in a manner which would,
hopefully,
not cause me to rely on known practices because they were familiar and
understood, but always strive to discover better ways of coding.

Now, however, I'm trying to combine reusing code I've already written with
enhancing the reused code, instead of writing it from scratch each time.

On my latest project I decided to take the dive and structure my code of
HTML,
CF, jQuery, and CSS in away that allows me to create resource libraries
that I can build upon and reference from within new projects.

I know *not* doing it this way sounds nuts to some of you. But, again, see
my
first paragraph. There was a method to the madness of this approach.

But, now I find myself (after days of trying to understand what I've found
on the
Internet and in the CF docs to little avail)  trying to get a working
method for this
approach.

I started first by putting my initial components for the project *above*
the website's
root folder. I knew this was going to be problematic. I, of course,
immediately
got the error, component cannot be found.

Then, I read about cfincluding an application.cfc into an application.cfm
in the
website root folder. For kicks and giggles, not a real solution, because
this approach
is fundamentally flawed, I put an application.cfm in the site root folder
and
used the relative path capability of cfinclude to pull in the
application.cfc above
the site web root and it's settings into the site's directory structure.
Knowing that's
not a solution, I continued to dig on the Internet. Nothing has clicked. I
think there
are too many gaps in my understanding to make sense of everything I'm
reading.

So, I thought I'd just ask the brains that inhabit the world of CF-Talk and
ask
for a simple explanation of how to go about accessing cfc's above a website
root,
that allows those cfc's access to the variables set up in application.cfc
when it
resides inside the site root directory structure.

I'm trying to get this to work in the manner that I access virtually every
cfc currently,
which is through AJAX functionality in jQuery. I can access a mapped path
created
in application.cfc using AJAX in this manner:

url: location.protocol + '//' + location.host +
'/common/coldfusion/form-processing/contact.cfc?method=json'

However, the contact.cfc has to reference variables setup in the
application.cfc,
which exists inside the website root. Unless I place the application.cfc in
the same
folder as contact.cfc, it doesn't work.

So, how do I make the variables from application.cfc available to
contact.cfc under
such a scenario? Does the extends functionality of cfc's solve this? Is
that what
I need to understand and implement or do I need to look into something else?

Clues? Breadcrumbs?

Thanks for any feedback!

Rick

-- 
--
Ninety percent of the politicians give the other ten percent a bad
reputation.  Henry Kissinger


~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:356043
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm


Re: Best means of setting a library of reusable code

2013-06-25 Thread Russ Michaels

if you use EXTENDS, then everything in the parent CFC is available tot he
child.
If you want libraries to use on multiple sites, then you would need to put
the components in a central location and then adding a mapping to them.



On Tue, Jun 25, 2013 at 4:01 PM, Rick Faircloth r...@whitestonemedia.comwrote:


 Hi, all...

 I've been writing code for every project I've worked on for the last 10+
 years.
 I did that purposefully to make myself work in a manner which would,
 hopefully,
 not cause me to rely on known practices because they were familiar and
 understood, but always strive to discover better ways of coding.

 Now, however, I'm trying to combine reusing code I've already written with
 enhancing the reused code, instead of writing it from scratch each time.

 On my latest project I decided to take the dive and structure my code of
 HTML,
 CF, jQuery, and CSS in away that allows me to create resource libraries
 that I can build upon and reference from within new projects.

 I know *not* doing it this way sounds nuts to some of you. But, again, see
 my
 first paragraph. There was a method to the madness of this approach.

 But, now I find myself (after days of trying to understand what I've found
 on the
 Internet and in the CF docs to little avail)  trying to get a working
 method for this
 approach.

 I started first by putting my initial components for the project *above*
 the website's
 root folder. I knew this was going to be problematic. I, of course,
 immediately
 got the error, component cannot be found.

 Then, I read about cfincluding an application.cfc into an application.cfm
 in the
 website root folder. For kicks and giggles, not a real solution, because
 this approach
 is fundamentally flawed, I put an application.cfm in the site root folder
 and
 used the relative path capability of cfinclude to pull in the
 application.cfc above
 the site web root and it's settings into the site's directory structure.
 Knowing that's
 not a solution, I continued to dig on the Internet. Nothing has clicked. I
 think there
 are too many gaps in my understanding to make sense of everything I'm
 reading.

 So, I thought I'd just ask the brains that inhabit the world of CF-Talk and
 ask
 for a simple explanation of how to go about accessing cfc's above a website
 root,
 that allows those cfc's access to the variables set up in application.cfc
 when it
 resides inside the site root directory structure.

 I'm trying to get this to work in the manner that I access virtually every
 cfc currently,
 which is through AJAX functionality in jQuery. I can access a mapped path
 created
 in application.cfc using AJAX in this manner:

 url: location.protocol + '//' + location.host +
 '/common/coldfusion/form-processing/contact.cfc?method=json'

 However, the contact.cfc has to reference variables setup in the
 application.cfc,
 which exists inside the website root. Unless I place the application.cfc in
 the same
 folder as contact.cfc, it doesn't work.

 So, how do I make the variables from application.cfc available to
 contact.cfc under
 such a scenario? Does the extends functionality of cfc's solve this? Is
 that what
 I need to understand and implement or do I need to look into something
 else?

 Clues? Breadcrumbs?

 Thanks for any feedback!

 Rick

 --

 --
 Ninety percent of the politicians give the other ten percent a bad
 reputation.  Henry Kissinger


 

~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:356045
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm


Re: Best means of setting a library of reusable code

2013-06-25 Thread Rick Faircloth

Alright, that's the confirmation I needed to proceed. So, use 'extends it
is!

Thanks,

Rick


On Tue, Jun 25, 2013 at 11:21 AM, Russ Michaels r...@michaels.me.uk wrote:


 if you use EXTENDS, then everything in the parent CFC is available tot he
 child.
 If you want libraries to use on multiple sites, then you would need to put
 the components in a central location and then adding a mapping to them.



 On Tue, Jun 25, 2013 at 4:01 PM, Rick Faircloth r...@whitestonemedia.com
 wrote:

 
  Hi, all...
 
  I've been writing code for every project I've worked on for the last 10+
  years.
  I did that purposefully to make myself work in a manner which would,
  hopefully,
  not cause me to rely on known practices because they were familiar and
  understood, but always strive to discover better ways of coding.
 
  Now, however, I'm trying to combine reusing code I've already written
 with
  enhancing the reused code, instead of writing it from scratch each time.
 
  On my latest project I decided to take the dive and structure my code of
  HTML,
  CF, jQuery, and CSS in away that allows me to create resource libraries
  that I can build upon and reference from within new projects.
 
  I know *not* doing it this way sounds nuts to some of you. But, again,
 see
  my
  first paragraph. There was a method to the madness of this approach.
 
  But, now I find myself (after days of trying to understand what I've
 found
  on the
  Internet and in the CF docs to little avail)  trying to get a working
  method for this
  approach.
 
  I started first by putting my initial components for the project *above*
  the website's
  root folder. I knew this was going to be problematic. I, of course,
  immediately
  got the error, component cannot be found.
 
  Then, I read about cfincluding an application.cfc into an
 application.cfm
  in the
  website root folder. For kicks and giggles, not a real solution,
 because
  this approach
  is fundamentally flawed, I put an application.cfm in the site root folder
  and
  used the relative path capability of cfinclude to pull in the
  application.cfc above
  the site web root and it's settings into the site's directory structure.
  Knowing that's
  not a solution, I continued to dig on the Internet. Nothing has clicked.
 I
  think there
  are too many gaps in my understanding to make sense of everything I'm
  reading.
 
  So, I thought I'd just ask the brains that inhabit the world of CF-Talk
 and
  ask
  for a simple explanation of how to go about accessing cfc's above a
 website
  root,
  that allows those cfc's access to the variables set up in application.cfc
  when it
  resides inside the site root directory structure.
 
  I'm trying to get this to work in the manner that I access virtually
 every
  cfc currently,
  which is through AJAX functionality in jQuery. I can access a mapped path
  created
  in application.cfc using AJAX in this manner:
 
  url: location.protocol + '//' + location.host +
  '/common/coldfusion/form-processing/contact.cfc?method=json'
 
  However, the contact.cfc has to reference variables setup in the
  application.cfc,
  which exists inside the website root. Unless I place the application.cfc
 in
  the same
  folder as contact.cfc, it doesn't work.
 
  So, how do I make the variables from application.cfc available to
  contact.cfc under
  such a scenario? Does the extends functionality of cfc's solve this? Is
  that what
  I need to understand and implement or do I need to look into something
  else?
 
  Clues? Breadcrumbs?
 
  Thanks for any feedback!
 
  Rick
 
  --
 
 
 --
  Ninety percent of the politicians give the other ten percent a bad
  reputation.  Henry Kissinger
 
 
 

 

~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:356047
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm


Re: Best means of setting a library of reusable code

2013-06-25 Thread Matt Quackenbush

Hang on a minute. If I understand this correctly 

So, how do I make the variables from application.cfc available to
 contact.cfc under
 such a scenario? Does the extends functionality of cfc's solve this?


... you're thinking about adding `extends=Application` to your
contact.cfc?  If that's a correct understanding on my part, then the answer
is: HELL NO! DO NOT USE EXTENDS!

Your CFCs should be self-contained and any outside variables they need
should be passed in as either arguments or properties. Here's a contrived
example.

// foo.cfc
component
{
property name=datasourcename

function init( required string datasourcename )
{
variables.datasourcename = arguments.datasourcename
return this
}

function doQuery()
{
// your query goes here
return mycoolquery
}
}

// test.cfm
foo = createObject( 'component', 'foo' ).init( application.datasourcename )
writeDump( foo.doQuery )


HTH

On Tue, Jun 25, 2013 at 11:41 AM, Rick Faircloth
r...@whitestonemedia.comwrote:


 Alright, that's the confirmation I needed to proceed. So, use 'extends it
 is!

 Thanks,

 Rick


 On Tue, Jun 25, 2013 at 11:21 AM, Russ Michaels r...@michaels.me.uk
 wrote:

 
  if you use EXTENDS, then everything in the parent CFC is available tot he
  child.
  If you want libraries to use on multiple sites, then you would need to
 put
  the components in a central location and then adding a mapping to them.
 
 
 
  On Tue, Jun 25, 2013 at 4:01 PM, Rick Faircloth 
 r...@whitestonemedia.com
  wrote:
 
  
   Hi, all...
  
   I've been writing code for every project I've worked on for the last
 10+
   years.
   I did that purposefully to make myself work in a manner which would,
   hopefully,
   not cause me to rely on known practices because they were familiar and
   understood, but always strive to discover better ways of coding.
  
   Now, however, I'm trying to combine reusing code I've already written
  with
   enhancing the reused code, instead of writing it from scratch each
 time.
  
   On my latest project I decided to take the dive and structure my code
 of
   HTML,
   CF, jQuery, and CSS in away that allows me to create resource libraries
   that I can build upon and reference from within new projects.
  
   I know *not* doing it this way sounds nuts to some of you. But, again,
  see
   my
   first paragraph. There was a method to the madness of this approach.
  
   But, now I find myself (after days of trying to understand what I've
  found
   on the
   Internet and in the CF docs to little avail)  trying to get a working
   method for this
   approach.
  
   I started first by putting my initial components for the project
 *above*
   the website's
   root folder. I knew this was going to be problematic. I, of course,
   immediately
   got the error, component cannot be found.
  
   Then, I read about cfincluding an application.cfc into an
  application.cfm
   in the
   website root folder. For kicks and giggles, not a real solution,
  because
   this approach
   is fundamentally flawed, I put an application.cfm in the site root
 folder
   and
   used the relative path capability of cfinclude to pull in the
   application.cfc above
   the site web root and it's settings into the site's directory
 structure.
   Knowing that's
   not a solution, I continued to dig on the Internet. Nothing has
 clicked.
  I
   think there
   are too many gaps in my understanding to make sense of everything I'm
   reading.
  
   So, I thought I'd just ask the brains that inhabit the world of CF-Talk
  and
   ask
   for a simple explanation of how to go about accessing cfc's above a
  website
   root,
   that allows those cfc's access to the variables set up in
 application.cfc
   when it
   resides inside the site root directory structure.
  
   I'm trying to get this to work in the manner that I access virtually
  every
   cfc currently,
   which is through AJAX functionality in jQuery. I can access a mapped
 path
   created
   in application.cfc using AJAX in this manner:
  
   url: location.protocol + '//' + location.host +
   '/common/coldfusion/form-processing/contact.cfc?method=json'
  
   However, the contact.cfc has to reference variables setup in the
   application.cfc,
   which exists inside the website root. Unless I place the
 application.cfc
  in
   the same
   folder as contact.cfc, it doesn't work.
  
   So, how do I make the variables from application.cfc available to
   contact.cfc under
   such a scenario? Does the extends functionality of cfc's solve this?
 Is
   that what
   I need to understand and implement or do I need to look into something
   else?
  
   Clues? Breadcrumbs?
  
   Thanks for any feedback!
  
   Rick
  
   --
  
  
 
 --
   Ninety percent of the politicians give the other ten percent a bad
   reputation.  Henry 

Re: Best means of setting a library of reusable code

2013-06-25 Thread Brian Cain

I have to agree with Matt.  You are setting yourself up for a dependency
nightmare if your cfc functions do not encapsulate their logic.


On Tue, Jun 25, 2013 at 10:50 AM, Matt Quackenbush quackfu...@gmail.comwrote:


 Hang on a minute. If I understand this correctly 

 So, how do I make the variables from application.cfc available to
  contact.cfc under
  such a scenario? Does the extends functionality of cfc's solve this?


 ... you're thinking about adding `extends=Application` to your
 contact.cfc?  If that's a correct understanding on my part, then the answer
 is: HELL NO! DO NOT USE EXTENDS!

 Your CFCs should be self-contained and any outside variables they need
 should be passed in as either arguments or properties. Here's a contrived
 example.

 // foo.cfc
 component
 {
 property name=datasourcename

 function init( required string datasourcename )
 {
 variables.datasourcename = arguments.datasourcename
 return this
 }

 function doQuery()
 {
 // your query goes here
 return mycoolquery
 }
 }

 // test.cfm
 foo = createObject( 'component', 'foo' ).init( application.datasourcename )
 writeDump( foo.doQuery )


 HTH

 On Tue, Jun 25, 2013 at 11:41 AM, Rick Faircloth
 r...@whitestonemedia.comwrote:

 
  Alright, that's the confirmation I needed to proceed. So, use 'extends
 it
  is!
 
  Thanks,
 
  Rick
 
 
  On Tue, Jun 25, 2013 at 11:21 AM, Russ Michaels r...@michaels.me.uk
  wrote:
 
  
   if you use EXTENDS, then everything in the parent CFC is available tot
 he
   child.
   If you want libraries to use on multiple sites, then you would need to
  put
   the components in a central location and then adding a mapping to them.
  
  
  
   On Tue, Jun 25, 2013 at 4:01 PM, Rick Faircloth 
  r...@whitestonemedia.com
   wrote:
  
   
Hi, all...
   
I've been writing code for every project I've worked on for the last
  10+
years.
I did that purposefully to make myself work in a manner which would,
hopefully,
not cause me to rely on known practices because they were familiar
 and
understood, but always strive to discover better ways of coding.
   
Now, however, I'm trying to combine reusing code I've already written
   with
enhancing the reused code, instead of writing it from scratch each
  time.
   
On my latest project I decided to take the dive and structure my code
  of
HTML,
CF, jQuery, and CSS in away that allows me to create resource
 libraries
that I can build upon and reference from within new projects.
   
I know *not* doing it this way sounds nuts to some of you. But,
 again,
   see
my
first paragraph. There was a method to the madness of this approach.
   
But, now I find myself (after days of trying to understand what I've
   found
on the
Internet and in the CF docs to little avail)  trying to get a working
method for this
approach.
   
I started first by putting my initial components for the project
  *above*
the website's
root folder. I knew this was going to be problematic. I, of course,
immediately
got the error, component cannot be found.
   
Then, I read about cfincluding an application.cfc into an
   application.cfm
in the
website root folder. For kicks and giggles, not a real solution,
   because
this approach
is fundamentally flawed, I put an application.cfm in the site root
  folder
and
used the relative path capability of cfinclude to pull in the
application.cfc above
the site web root and it's settings into the site's directory
  structure.
Knowing that's
not a solution, I continued to dig on the Internet. Nothing has
  clicked.
   I
think there
are too many gaps in my understanding to make sense of everything I'm
reading.
   
So, I thought I'd just ask the brains that inhabit the world of
 CF-Talk
   and
ask
for a simple explanation of how to go about accessing cfc's above a
   website
root,
that allows those cfc's access to the variables set up in
  application.cfc
when it
resides inside the site root directory structure.
   
I'm trying to get this to work in the manner that I access virtually
   every
cfc currently,
which is through AJAX functionality in jQuery. I can access a mapped
  path
created
in application.cfc using AJAX in this manner:
   
url: location.protocol + '//' + location.host +
'/common/coldfusion/form-processing/contact.cfc?method=json'
   
However, the contact.cfc has to reference variables setup in the
application.cfc,
which exists inside the website root. Unless I place the
  application.cfc
   in
the same
folder as contact.cfc, it doesn't work.
   
So, how do I make the variables from application.cfc available to
contact.cfc under
such a scenario? Does the extends functionality of cfc's solve
 this?
  Is
that what
I need to understand and 

Re: Best means of setting a library of reusable code

2013-06-25 Thread Russ Michaels

taking best practices into consideration is a whole different matter, but
his original post implied he just wants to keep his existing code.
Having global functions in your application.cfc is pretty common evrn if
not a best practice.

Russ Michaels
www.michaels.me.uk
 On 25 Jun 2013 16:54, Brian Cain bcc9...@gmail.com wrote:


 I have to agree with Matt.  You are setting yourself up for a dependency
 nightmare if your cfc functions do not encapsulate their logic.


 On Tue, Jun 25, 2013 at 10:50 AM, Matt Quackenbush quackfu...@gmail.com
 wrote:

 
  Hang on a minute. If I understand this correctly 
 
  So, how do I make the variables from application.cfc available to
   contact.cfc under
   such a scenario? Does the extends functionality of cfc's solve this?
 
 
  ... you're thinking about adding `extends=Application` to your
  contact.cfc?  If that's a correct understanding on my part, then the
 answer
  is: HELL NO! DO NOT USE EXTENDS!
 
  Your CFCs should be self-contained and any outside variables they need
  should be passed in as either arguments or properties. Here's a contrived
  example.
 
  // foo.cfc
  component
  {
  property name=datasourcename
 
  function init( required string datasourcename )
  {
  variables.datasourcename = arguments.datasourcename
  return this
  }
 
  function doQuery()
  {
  // your query goes here
  return mycoolquery
  }
  }
 
  // test.cfm
  foo = createObject( 'component', 'foo' ).init(
 application.datasourcename )
  writeDump( foo.doQuery )
 
 
  HTH
 
  On Tue, Jun 25, 2013 at 11:41 AM, Rick Faircloth
  r...@whitestonemedia.comwrote:
 
  
   Alright, that's the confirmation I needed to proceed. So, use
 'extends
  it
   is!
  
   Thanks,
  
   Rick
  
  
   On Tue, Jun 25, 2013 at 11:21 AM, Russ Michaels r...@michaels.me.uk
   wrote:
  
   
if you use EXTENDS, then everything in the parent CFC is available
 tot
  he
child.
If you want libraries to use on multiple sites, then you would need
 to
   put
the components in a central location and then adding a mapping to
 them.
   
   
   
On Tue, Jun 25, 2013 at 4:01 PM, Rick Faircloth 
   r...@whitestonemedia.com
wrote:
   

 Hi, all...

 I've been writing code for every project I've worked on for the
 last
   10+
 years.
 I did that purposefully to make myself work in a manner which
 would,
 hopefully,
 not cause me to rely on known practices because they were familiar
  and
 understood, but always strive to discover better ways of coding.

 Now, however, I'm trying to combine reusing code I've already
 written
with
 enhancing the reused code, instead of writing it from scratch each
   time.

 On my latest project I decided to take the dive and structure my
 code
   of
 HTML,
 CF, jQuery, and CSS in away that allows me to create resource
  libraries
 that I can build upon and reference from within new projects.

 I know *not* doing it this way sounds nuts to some of you. But,
  again,
see
 my
 first paragraph. There was a method to the madness of this
 approach.

 But, now I find myself (after days of trying to understand what
 I've
found
 on the
 Internet and in the CF docs to little avail)  trying to get a
 working
 method for this
 approach.

 I started first by putting my initial components for the project
   *above*
 the website's
 root folder. I knew this was going to be problematic. I, of course,
 immediately
 got the error, component cannot be found.

 Then, I read about cfincluding an application.cfc into an
application.cfm
 in the
 website root folder. For kicks and giggles, not a real solution,
because
 this approach
 is fundamentally flawed, I put an application.cfm in the site root
   folder
 and
 used the relative path capability of cfinclude to pull in the
 application.cfc above
 the site web root and it's settings into the site's directory
   structure.
 Knowing that's
 not a solution, I continued to dig on the Internet. Nothing has
   clicked.
I
 think there
 are too many gaps in my understanding to make sense of everything
 I'm
 reading.

 So, I thought I'd just ask the brains that inhabit the world of
  CF-Talk
and
 ask
 for a simple explanation of how to go about accessing cfc's above a
website
 root,
 that allows those cfc's access to the variables set up in
   application.cfc
 when it
 resides inside the site root directory structure.

 I'm trying to get this to work in the manner that I access
 virtually
every
 cfc currently,
 which is through AJAX functionality in jQuery. I can access a
 mapped
   path
 created
 in application.cfc using AJAX in this manner:

 url: location.protocol + '//' + location.host +
 

Re: Best means of setting a library of reusable code

2013-06-25 Thread Dave Watts

 However, the contact.cfc has to reference variables setup in the
 application.cfc, which exists inside the website root. Unless I place
 the application.cfc in the same folder as contact.cfc, it doesn't work.

 So, how do I make the variables from application.cfc available to
 contact.cfc under such a scenario? Does the extends functionality of
 cfc's solve this? Is that what I need to understand and implement or do
 I need to look into something else?

Is contact.cfc part of the same application as the Application.cfc
where the variables are defined? If so, why aren't those variables
just part of the Application scope, instead of local variables that
get recreated for each page request?

Code reuse is very important. But code reuse doesn't just mean invoke
one module from another one. It requires that you structure your code
appropriately in the first place. I'm not seeing that structure from
your description - that doesn't mean there isn't any structure, just
that I'm not seeing it in your description.

In general, you don't want to use Application.cfc as the parent class
for any other class except another Application.cfc - for example, in a
subdirectory of the parent application. You don't want to use it as
the parent class for other CFCs.

Dave Watts, CTO, Fig Leaf Software
http://www.figleaf.com/
http://training.figleaf.com/

Fig Leaf Software is a Veteran-Owned Small Business (VOSB) on
GSA Schedule, and provides the highest caliber vendor-authorized
instruction at our training centers, online, or onsite.

~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:356051
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm


Re: Best means of setting a library of reusable code

2013-06-25 Thread Matt Quackenbush

On Tue, Jun 25, 2013 at 12:04 PM, Dave Watts dwa...@figleaf.com wrote:


 In general, you don't want to use Application.cfc as the parent class
 for any other class except another Application.cfc - for example, in a
 subdirectory of the parent application. You don't want to use it as
 the parent class for other CFCs.



+infinity


~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:356052
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm


Re: Best means of setting a library of reusable code

2013-06-25 Thread Rick Faircloth

Your understanding is correct, Matt, but I don't see how your
example is relevant.

In my application.cfc, I've got a line that sets an application variable:

cfset application.siteShortDomain = myShortDomain.com

I need that application.siteShortdomain variable available when contact.cfc
runs.

So, how would I go about this?

(I just noticed what Brian and Russ added to the conversation,
and Russ is correct, as you can see from above, that I want to extend
the global application variables that I've set in application.cfc tp all
the other cfc's that are in a common library of cfc's above the website
root.

???

Thanks!

Rick


On Tue, Jun 25, 2013 at 11:50 AM, Matt Quackenbush quackfu...@gmail.comwrote:


 Hang on a minute. If I understand this correctly 

 So, how do I make the variables from application.cfc available to
  contact.cfc under
  such a scenario? Does the extends functionality of cfc's solve this?


 ... you're thinking about adding `extends=Application` to your
 contact.cfc?  If that's a correct understanding on my part, then the answer
 is: HELL NO! DO NOT USE EXTENDS!

 Your CFCs should be self-contained and any outside variables they need
 should be passed in as either arguments or properties. Here's a contrived
 example.

 // foo.cfc
 component
 {
 property name=datasourcename

 function init( required string datasourcename )
 {
 variables.datasourcename = arguments.datasourcename
 return this
 }

 function doQuery()
 {
 // your query goes here
 return mycoolquery
 }
 }

 // test.cfm
 foo = createObject( 'component', 'foo' ).init( application.datasourcename )
 writeDump( foo.doQuery )


 HTH

 On Tue, Jun 25, 2013 at 11:41 AM, Rick Faircloth
 r...@whitestonemedia.comwrote:

 
  Alright, that's the confirmation I needed to proceed. So, use 'extends
 it
  is!
 
  Thanks,
 
  Rick
 
 
  On Tue, Jun 25, 2013 at 11:21 AM, Russ Michaels r...@michaels.me.uk
  wrote:
 
  
   if you use EXTENDS, then everything in the parent CFC is available tot
 he
   child.
   If you want libraries to use on multiple sites, then you would need to
  put
   the components in a central location and then adding a mapping to them.
  
  
  
   On Tue, Jun 25, 2013 at 4:01 PM, Rick Faircloth 
  r...@whitestonemedia.com
   wrote:
  
   
Hi, all...
   
I've been writing code for every project I've worked on for the last
  10+
years.
I did that purposefully to make myself work in a manner which would,
hopefully,
not cause me to rely on known practices because they were familiar
 and
understood, but always strive to discover better ways of coding.
   
Now, however, I'm trying to combine reusing code I've already written
   with
enhancing the reused code, instead of writing it from scratch each
  time.
   
On my latest project I decided to take the dive and structure my code
  of
HTML,
CF, jQuery, and CSS in away that allows me to create resource
 libraries
that I can build upon and reference from within new projects.
   
I know *not* doing it this way sounds nuts to some of you. But,
 again,
   see
my
first paragraph. There was a method to the madness of this approach.
   
But, now I find myself (after days of trying to understand what I've
   found
on the
Internet and in the CF docs to little avail)  trying to get a working
method for this
approach.
   
I started first by putting my initial components for the project
  *above*
the website's
root folder. I knew this was going to be problematic. I, of course,
immediately
got the error, component cannot be found.
   
Then, I read about cfincluding an application.cfc into an
   application.cfm
in the
website root folder. For kicks and giggles, not a real solution,
   because
this approach
is fundamentally flawed, I put an application.cfm in the site root
  folder
and
used the relative path capability of cfinclude to pull in the
application.cfc above
the site web root and it's settings into the site's directory
  structure.
Knowing that's
not a solution, I continued to dig on the Internet. Nothing has
  clicked.
   I
think there
are too many gaps in my understanding to make sense of everything I'm
reading.
   
So, I thought I'd just ask the brains that inhabit the world of
 CF-Talk
   and
ask
for a simple explanation of how to go about accessing cfc's above a
   website
root,
that allows those cfc's access to the variables set up in
  application.cfc
when it
resides inside the site root directory structure.
   
I'm trying to get this to work in the manner that I access virtually
   every
cfc currently,
which is through AJAX functionality in jQuery. I can access a mapped
  path
created
in application.cfc using AJAX in this manner:
   
url: location.protocol + '//' + location.host +

Re: Best means of setting a library of reusable code

2013-06-25 Thread Rick Faircloth

Dave:

 Is contact.cfc part of the same application as the Application.cfc
 where the variables are defined?

No, I'm trying to figure out a way to have a common library of cfc's, js,
etc.,
that websites I build can reference.

I saw in other places around the Internet that it's best to keep code logic
outside the webroot. I thought I'd try that.

So, contact.cfc is in
e:\inetpub\common\coldfusion\form-processing\contact.cfc.

The application.cfc is in
e:\inetpub\webroot\hdspa-responsive-dev\application.cfc.

Since application.siteShortDomain is set in application.cfc, when
contact.cfc
is accessed via AJAX, contact.cfc has no knowledge of the
application.siteShortDomain
variable.

Just trying to figure out how to make contact.cfc aware of the value of
application.siteShortDomain.

Rick


On Tue, Jun 25, 2013 at 12:04 PM, Dave Watts dwa...@figleaf.com wrote:


  However, the contact.cfc has to reference variables setup in the
  application.cfc, which exists inside the website root. Unless I place
  the application.cfc in the same folder as contact.cfc, it doesn't work.
 
  So, how do I make the variables from application.cfc available to
  contact.cfc under such a scenario? Does the extends functionality of
  cfc's solve this? Is that what I need to understand and implement or do
  I need to look into something else?

 Is contact.cfc part of the same application as the Application.cfc
 where the variables are defined? If so, why aren't those variables
 just part of the Application scope, instead of local variables that
 get recreated for each page request?

 Code reuse is very important. But code reuse doesn't just mean invoke
 one module from another one. It requires that you structure your code
 appropriately in the first place. I'm not seeing that structure from
 your description - that doesn't mean there isn't any structure, just
 that I'm not seeing it in your description.

 In general, you don't want to use Application.cfc as the parent class
 for any other class except another Application.cfc - for example, in a
 subdirectory of the parent application. You don't want to use it as
 the parent class for other CFCs.

 Dave Watts, CTO, Fig Leaf Software
 http://www.figleaf.com/
 http://training.figleaf.com/

 Fig Leaf Software is a Veteran-Owned Small Business (VOSB) on
 GSA Schedule, and provides the highest caliber vendor-authorized
 instruction at our training centers, online, or onsite.

 

~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:356055
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm


Re: Best means of setting a library of reusable code

2013-06-25 Thread Matt Quackenbush

You do it exactly like I said you do it: Pass it in as either an argument
or a property. When you instantiate your contact.cfc, you pass in
everything it needs from outside in order to do its job.

The example I gave is completely relevant, albeit not an example of your
exact situation. I don't know your exact situation and I'm not going to
write your code for you, but I - along with others here - have definitely
given you all the information you need to apply the principles to your
exact scenario.


On Tue, Jun 25, 2013 at 12:40 PM, Rick Faircloth
r...@whitestonemedia.comwrote:


 Your understanding is correct, Matt, but I don't see how your
 example is relevant.

 In my application.cfc, I've got a line that sets an application variable:

 cfset application.siteShortDomain = myShortDomain.com

 I need that application.siteShortdomain variable available when contact.cfc
 runs.

 So, how would I go about this?

 (I just noticed what Brian and Russ added to the conversation,
 and Russ is correct, as you can see from above, that I want to extend
 the global application variables that I've set in application.cfc tp all
 the other cfc's that are in a common library of cfc's above the website
 root.

 ???

 Thanks!

 Rick


 On Tue, Jun 25, 2013 at 11:50 AM, Matt Quackenbush quackfu...@gmail.com
 wrote:

 
  Hang on a minute. If I understand this correctly 
 
  So, how do I make the variables from application.cfc available to
   contact.cfc under
   such a scenario? Does the extends functionality of cfc's solve this?
 
 
  ... you're thinking about adding `extends=Application` to your
  contact.cfc?  If that's a correct understanding on my part, then the
 answer
  is: HELL NO! DO NOT USE EXTENDS!
 
  Your CFCs should be self-contained and any outside variables they need
  should be passed in as either arguments or properties. Here's a contrived
  example.
 
  // foo.cfc
  component
  {
  property name=datasourcename
 
  function init( required string datasourcename )
  {
  variables.datasourcename = arguments.datasourcename
  return this
  }
 
  function doQuery()
  {
  // your query goes here
  return mycoolquery
  }
  }
 
  // test.cfm
  foo = createObject( 'component', 'foo' ).init(
 application.datasourcename )
  writeDump( foo.doQuery )
 
 
  HTH
 
  On Tue, Jun 25, 2013 at 11:41 AM, Rick Faircloth
  r...@whitestonemedia.comwrote:
 
  
   Alright, that's the confirmation I needed to proceed. So, use
 'extends
  it
   is!
  
   Thanks,
  
   Rick
  
  
   On Tue, Jun 25, 2013 at 11:21 AM, Russ Michaels r...@michaels.me.uk
   wrote:
  
   
if you use EXTENDS, then everything in the parent CFC is available
 tot
  he
child.
If you want libraries to use on multiple sites, then you would need
 to
   put
the components in a central location and then adding a mapping to
 them.
   
   
   
On Tue, Jun 25, 2013 at 4:01 PM, Rick Faircloth 
   r...@whitestonemedia.com
wrote:
   

 Hi, all...

 I've been writing code for every project I've worked on for the
 last
   10+
 years.
 I did that purposefully to make myself work in a manner which
 would,
 hopefully,
 not cause me to rely on known practices because they were familiar
  and
 understood, but always strive to discover better ways of coding.

 Now, however, I'm trying to combine reusing code I've already
 written
with
 enhancing the reused code, instead of writing it from scratch each
   time.

 On my latest project I decided to take the dive and structure my
 code
   of
 HTML,
 CF, jQuery, and CSS in away that allows me to create resource
  libraries
 that I can build upon and reference from within new projects.

 I know *not* doing it this way sounds nuts to some of you. But,
  again,
see
 my
 first paragraph. There was a method to the madness of this
 approach.

 But, now I find myself (after days of trying to understand what
 I've
found
 on the
 Internet and in the CF docs to little avail)  trying to get a
 working
 method for this
 approach.

 I started first by putting my initial components for the project
   *above*
 the website's
 root folder. I knew this was going to be problematic. I, of course,
 immediately
 got the error, component cannot be found.

 Then, I read about cfincluding an application.cfc into an
application.cfm
 in the
 website root folder. For kicks and giggles, not a real solution,
because
 this approach
 is fundamentally flawed, I put an application.cfm in the site root
   folder
 and
 used the relative path capability of cfinclude to pull in the
 application.cfc above
 the site web root and it's settings into the site's directory
   structure.
 Knowing that's
 not a solution, I continued to dig on the Internet. Nothing has
   clicked.
I
 think 

Re: Best means of setting a library of reusable code

2013-06-25 Thread Dave Watts

 In my application.cfc, I've got a line that sets an application variable:

 cfset application.siteShortDomain = myShortDomain.com

 I need that application.siteShortdomain variable available when contact.cfc
 runs.

 So, how would I go about this?

From within any file that's part of that application, you can directly
reference application.siteShortDomain:

cfoutput#application.siteShortDomain#/cfoutput

Any file within the same directory, or any subdirectories that don't
have their own Application.cfc or Application.cfm files, are part of
that application.

Dave Watts, CTO, Fig Leaf Software
http://www.figleaf.com/
http://training.figleaf.com/

Fig Leaf Software is a Veteran-Owned Small Business (VOSB) on
GSA Schedule, and provides the highest caliber vendor-authorized
instruction at our training centers, online, or onsite.

~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:356059
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm


Re: Best means of setting a library of reusable code

2013-06-25 Thread Azadi Saryev

With AJAX-accessed cfc's you really need them under your web root. CF
mappings won't work with those. Creating a virtual dir in your web server
pointing to the cfc location will do the trick.


On Wed, Jun 26, 2013 at 1:58 AM, Dave Watts dwa...@figleaf.com wrote:


  In my application.cfc, I've got a line that sets an application variable:
 
  cfset application.siteShortDomain = myShortDomain.com
 
  I need that application.siteShortdomain variable available when
 contact.cfc
  runs.
 
  So, how would I go about this?

 From within any file that's part of that application, you can directly
 reference application.siteShortDomain:

 cfoutput#application.siteShortDomain#/cfoutput

 Any file within the same directory, or any subdirectories that don't
 have their own Application.cfc or Application.cfm files, are part of
 that application.

 Dave Watts, CTO, Fig Leaf Software
 http://www.figleaf.com/
 http://training.figleaf.com/

 Fig Leaf Software is a Veteran-Owned Small Business (VOSB) on
 GSA Schedule, and provides the highest caliber vendor-authorized
 instruction at our training centers, online, or onsite.

 

~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:356063
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm


Re: Best means of setting a library of reusable code

2013-06-25 Thread Rick Faircloth

 From within any file that's part of that application, you can directly
 reference application.siteShortDomain:

 cfoutput#application.siteShortDomain#/cfoutput

 Any file within the same directory, or any subdirectories that don't
 have their own Application.cfc or Application.cfm files, are part of
 that application.

Thanks, Dave I understand that usage of application variables.
The problem here is that the contact.cfc that I need to have access
to application.siteShortDomain is outside the directory structure
of application.cfc that sets the variable, contact.cfc doesn't have
access to it in the normal way.

I've set up resource files, such as contact.cfc, which processes
contact form information, set up in a separate directory structure
outside the webroot, so in other applications I can refer to the
contact.cfc for processing contact form information, as well.

Just trying to figure out how to setup a library of functionality
that I can reference from various websites. Normally, I just copy
all the cfc's into a new site's directory structure. I'm just trying
to find a way around that.


~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:356064
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm


Re: Best means of setting a library of reusable code

2013-06-25 Thread Rick Faircloth

Matt, just participate in the conversation without being asinine about it.

I haven't asked anyone to write my code for me. Just looking
for some guidance as to the correct approach.

So, offer your advice in a friendly manner, if you're going to offer
it at all.



On Tue, Jun 25, 2013 at 12:56 PM, Matt Quackenbush quackfu...@gmail.comwrote:


 You do it exactly like I said you do it: Pass it in as either an argument
 or a property. When you instantiate your contact.cfc, you pass in
 everything it needs from outside in order to do its job.

 The example I gave is completely relevant, albeit not an example of your
 exact situation. I don't know your exact situation and I'm not going to
 write your code for you, but I - along with others here - have definitely
 given you all the information you need to apply the principles to your
 exact scenario.


 On Tue, Jun 25, 2013 at 12:40 PM, Rick Faircloth
 r...@whitestonemedia.comwrote:

 
  Your understanding is correct, Matt, but I don't see how your
  example is relevant.
 
  In my application.cfc, I've got a line that sets an application variable:
 
  cfset application.siteShortDomain = myShortDomain.com
 
  I need that application.siteShortdomain variable available when
 contact.cfc
  runs.
 
  So, how would I go about this?
 
  (I just noticed what Brian and Russ added to the conversation,
  and Russ is correct, as you can see from above, that I want to extend
  the global application variables that I've set in application.cfc tp all
  the other cfc's that are in a common library of cfc's above the website
  root.
 
  ???
 
  Thanks!
 
  Rick
 
 
  On Tue, Jun 25, 2013 at 11:50 AM, Matt Quackenbush quackfu...@gmail.com
  wrote:
 
  
   Hang on a minute. If I understand this correctly 
  
   So, how do I make the variables from application.cfc available to
contact.cfc under
such a scenario? Does the extends functionality of cfc's solve
 this?
  
  
   ... you're thinking about adding `extends=Application` to your
   contact.cfc?  If that's a correct understanding on my part, then the
  answer
   is: HELL NO! DO NOT USE EXTENDS!
  
   Your CFCs should be self-contained and any outside variables they
 need
   should be passed in as either arguments or properties. Here's a
 contrived
   example.
  
   // foo.cfc
   component
   {
   property name=datasourcename
  
   function init( required string datasourcename )
   {
   variables.datasourcename = arguments.datasourcename
   return this
   }
  
   function doQuery()
   {
   // your query goes here
   return mycoolquery
   }
   }
  
   // test.cfm
   foo = createObject( 'component', 'foo' ).init(
  application.datasourcename )
   writeDump( foo.doQuery )
  
  
   HTH
  
   On Tue, Jun 25, 2013 at 11:41 AM, Rick Faircloth
   r...@whitestonemedia.comwrote:
  
   
Alright, that's the confirmation I needed to proceed. So, use
  'extends
   it
is!
   
Thanks,
   
Rick
   
   
On Tue, Jun 25, 2013 at 11:21 AM, Russ Michaels r...@michaels.me.uk
 
wrote:
   

 if you use EXTENDS, then everything in the parent CFC is available
  tot
   he
 child.
 If you want libraries to use on multiple sites, then you would need
  to
put
 the components in a central location and then adding a mapping to
  them.



 On Tue, Jun 25, 2013 at 4:01 PM, Rick Faircloth 
r...@whitestonemedia.com
 wrote:

 
  Hi, all...
 
  I've been writing code for every project I've worked on for the
  last
10+
  years.
  I did that purposefully to make myself work in a manner which
  would,
  hopefully,
  not cause me to rely on known practices because they were
 familiar
   and
  understood, but always strive to discover better ways of coding.
 
  Now, however, I'm trying to combine reusing code I've already
  written
 with
  enhancing the reused code, instead of writing it from scratch
 each
time.
 
  On my latest project I decided to take the dive and structure my
  code
of
  HTML,
  CF, jQuery, and CSS in away that allows me to create resource
   libraries
  that I can build upon and reference from within new projects.
 
  I know *not* doing it this way sounds nuts to some of you. But,
   again,
 see
  my
  first paragraph. There was a method to the madness of this
  approach.
 
  But, now I find myself (after days of trying to understand what
  I've
 found
  on the
  Internet and in the CF docs to little avail)  trying to get a
  working
  method for this
  approach.
 
  I started first by putting my initial components for the project
*above*
  the website's
  root folder. I knew this was going to be problematic. I, of
 course,
  immediately
  got the error, component cannot be found.
 
  Then, I read about cfincluding an application.cfc 

Re: Best means of setting a library of reusable code

2013-06-25 Thread Rick Faircloth

Thanks, Azadi...

I was afraid that or creating CF Admin mappings might end up being
the answer. I was trying to find a way of accessing the variables without
a lot of setup for each website. But, virtual directories won't be that much
to do, since the virtual directories will be the same for each website that
needs the functionality they contain.

But, will virtual directories put into the directory structure of an app in
IIS
then have access to global variables such as application variables?

I'll have to test that approach.

Another alternative might be to send the needed application variables
into the AJAX function which accesses the component function as
JS variables. That might work...


~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:356066
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm


Re: Best means of setting a library of reusable code

2013-06-25 Thread Matt Quackenbush

sigh I did. And you flatly stated that my example is (not) relevant. I
was merely pointing out - mostly for those who happen upon this thread
later, since they'll hopefully read and comprehend - that your assessment
is flatly wrong.

Good luck.


On Tue, Jun 25, 2013 at 2:24 PM, Rick Faircloth r...@whitestonemedia.comwrote:


 Matt, just participate in the conversation without being asinine about it.

 I haven't asked anyone to write my code for me. Just looking
 for some guidance as to the correct approach.

 So, offer your advice in a friendly manner, if you're going to offer
 it at all.



 On Tue, Jun 25, 2013 at 12:56 PM, Matt Quackenbush quackfu...@gmail.com
 wrote:

 
  You do it exactly like I said you do it: Pass it in as either an argument
  or a property. When you instantiate your contact.cfc, you pass in
  everything it needs from outside in order to do its job.
 
  The example I gave is completely relevant, albeit not an example of your
  exact situation. I don't know your exact situation and I'm not going to
  write your code for you, but I - along with others here - have definitely
  given you all the information you need to apply the principles to your
  exact scenario.
 
 
  On Tue, Jun 25, 2013 at 12:40 PM, Rick Faircloth
  r...@whitestonemedia.comwrote:
 
  
   Your understanding is correct, Matt, but I don't see how your
   example is relevant.
  
   In my application.cfc, I've got a line that sets an application
 variable:
  
   cfset application.siteShortDomain = myShortDomain.com
  
   I need that application.siteShortdomain variable available when
  contact.cfc
   runs.
  
   So, how would I go about this?
  
   (I just noticed what Brian and Russ added to the conversation,
   and Russ is correct, as you can see from above, that I want to extend
   the global application variables that I've set in application.cfc tp
 all
   the other cfc's that are in a common library of cfc's above the website
   root.
  
   ???
  
   Thanks!
  
   Rick
  
  
   On Tue, Jun 25, 2013 at 11:50 AM, Matt Quackenbush 
 quackfu...@gmail.com
   wrote:
  
   
Hang on a minute. If I understand this correctly 
   
So, how do I make the variables from application.cfc available to
 contact.cfc under
 such a scenario? Does the extends functionality of cfc's solve
  this?
   
   
... you're thinking about adding `extends=Application` to your
contact.cfc?  If that's a correct understanding on my part, then the
   answer
is: HELL NO! DO NOT USE EXTENDS!
   
Your CFCs should be self-contained and any outside variables they
  need
should be passed in as either arguments or properties. Here's a
  contrived
example.
   
// foo.cfc
component
{
property name=datasourcename
   
function init( required string datasourcename )
{
variables.datasourcename = arguments.datasourcename
return this
}
   
function doQuery()
{
// your query goes here
return mycoolquery
}
}
   
// test.cfm
foo = createObject( 'component', 'foo' ).init(
   application.datasourcename )
writeDump( foo.doQuery )
   
   
HTH
   
On Tue, Jun 25, 2013 at 11:41 AM, Rick Faircloth
r...@whitestonemedia.comwrote:
   

 Alright, that's the confirmation I needed to proceed. So, use
   'extends
it
 is!

 Thanks,

 Rick


 On Tue, Jun 25, 2013 at 11:21 AM, Russ Michaels 
 r...@michaels.me.uk
  
 wrote:

 
  if you use EXTENDS, then everything in the parent CFC is
 available
   tot
he
  child.
  If you want libraries to use on multiple sites, then you would
 need
   to
 put
  the components in a central location and then adding a mapping to
   them.
 
 
 
  On Tue, Jun 25, 2013 at 4:01 PM, Rick Faircloth 
 r...@whitestonemedia.com
  wrote:
 
  
   Hi, all...
  
   I've been writing code for every project I've worked on for the
   last
 10+
   years.
   I did that purposefully to make myself work in a manner which
   would,
   hopefully,
   not cause me to rely on known practices because they were
  familiar
and
   understood, but always strive to discover better ways of
 coding.
  
   Now, however, I'm trying to combine reusing code I've already
   written
  with
   enhancing the reused code, instead of writing it from scratch
  each
 time.
  
   On my latest project I decided to take the dive and structure
 my
   code
 of
   HTML,
   CF, jQuery, and CSS in away that allows me to create resource
libraries
   that I can build upon and reference from within new projects.
  
   I know *not* doing it this way sounds nuts to some of you. But,
again,
  see
   my
   first paragraph. There was a method to the madness of this
   approach.
  
   But, now I find 

Re: Best means of setting a library of reusable code

2013-06-25 Thread Rick Faircloth

Well, the good news is that I can include the application variables in the
AJAX post and pass them into the contact.cfc (which is also out of the
webroot and in the library) via the AJAX call to contact.cfc.

The bad news is, I have to type all those application variables into every
AJAX call. But, at least I only have to type them in once for the reusable
code!




On Tue, Jun 25, 2013 at 2:31 PM, Rick Faircloth r...@whitestonemedia.comwrote:

 Thanks, Azadi...

 I was afraid that or creating CF Admin mappings might end up being
 the answer. I was trying to find a way of accessing the variables without
 a lot of setup for each website. But, virtual directories won't be that
 much
 to do, since the virtual directories will be the same for each website that
 needs the functionality they contain.

 But, will virtual directories put into the directory structure of an app
 in IIS
 then have access to global variables such as application variables?

 I'll have to test that approach.

 Another alternative might be to send the needed application variables
 into the AJAX function which accesses the component function as
 JS variables. That might work...




-- 
--
Ninety percent of the politicians give the other ten percent a bad
reputation.  Henry Kissinger


~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:356069
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm


Re: Best means of setting a library of reusable code

2013-06-25 Thread Rick Faircloth

sigh No, Matt... I didn't say your example is (not) relevant.

I stated, I don't see how your example is relevant.

See the difference? I put the fault on my part for not understanding your
example.

Your example may be perfectly relevant, but I couldn't see how.

I think you just misread my statement and assumed I was being offensive
about your example. If I had said, your example is not relevant, then that
would be offensive, especially coming from me, someone who is the one
asking everyone for assistance in understanding what I was trying to do!

So, no offense intended...


On Tue, Jun 25, 2013 at 2:35 PM, Matt Quackenbush quackfu...@gmail.comwrote:


 sigh I did. And you flatly stated that my example is (not) relevant. I
 was merely pointing out - mostly for those who happen upon this thread
 later, since they'll hopefully read and comprehend - that your assessment
 is flatly wrong.

 Good luck.


 On Tue, Jun 25, 2013 at 2:24 PM, Rick Faircloth r...@whitestonemedia.com
 wrote:

 
  Matt, just participate in the conversation without being asinine about
 it.
 
  I haven't asked anyone to write my code for me. Just looking
  for some guidance as to the correct approach.
 
  So, offer your advice in a friendly manner, if you're going to offer
  it at all.
 
 
 
  On Tue, Jun 25, 2013 at 12:56 PM, Matt Quackenbush quackfu...@gmail.com
  wrote:
 
  
   You do it exactly like I said you do it: Pass it in as either an
 argument
   or a property. When you instantiate your contact.cfc, you pass in
   everything it needs from outside in order to do its job.
  
   The example I gave is completely relevant, albeit not an example of
 your
   exact situation. I don't know your exact situation and I'm not going to
   write your code for you, but I - along with others here - have
 definitely
   given you all the information you need to apply the principles to your
   exact scenario.
  
  
   On Tue, Jun 25, 2013 at 12:40 PM, Rick Faircloth
   r...@whitestonemedia.comwrote:
  
   
Your understanding is correct, Matt, but I don't see how your
example is relevant.
   
In my application.cfc, I've got a line that sets an application
  variable:
   
cfset application.siteShortDomain = myShortDomain.com
   
I need that application.siteShortdomain variable available when
   contact.cfc
runs.
   
So, how would I go about this?
   
(I just noticed what Brian and Russ added to the conversation,
and Russ is correct, as you can see from above, that I want to extend
the global application variables that I've set in application.cfc tp
  all
the other cfc's that are in a common library of cfc's above the
 website
root.
   
???
   
Thanks!
   
Rick
   
   
On Tue, Jun 25, 2013 at 11:50 AM, Matt Quackenbush 
  quackfu...@gmail.com
wrote:
   

 Hang on a minute. If I understand this correctly 

 So, how do I make the variables from application.cfc available to
  contact.cfc under
  such a scenario? Does the extends functionality of cfc's solve
   this?


 ... you're thinking about adding `extends=Application` to your
 contact.cfc?  If that's a correct understanding on my part, then
 the
answer
 is: HELL NO! DO NOT USE EXTENDS!

 Your CFCs should be self-contained and any outside variables they
   need
 should be passed in as either arguments or properties. Here's a
   contrived
 example.

 // foo.cfc
 component
 {
 property name=datasourcename

 function init( required string datasourcename )
 {
 variables.datasourcename = arguments.datasourcename
 return this
 }

 function doQuery()
 {
 // your query goes here
 return mycoolquery
 }
 }

 // test.cfm
 foo = createObject( 'component', 'foo' ).init(
application.datasourcename )
 writeDump( foo.doQuery )


 HTH

 On Tue, Jun 25, 2013 at 11:41 AM, Rick Faircloth
 r...@whitestonemedia.comwrote:

 
  Alright, that's the confirmation I needed to proceed. So, use
'extends
 it
  is!
 
  Thanks,
 
  Rick
 
 
  On Tue, Jun 25, 2013 at 11:21 AM, Russ Michaels 
  r...@michaels.me.uk
   
  wrote:
 
  
   if you use EXTENDS, then everything in the parent CFC is
  available
tot
 he
   child.
   If you want libraries to use on multiple sites, then you would
  need
to
  put
   the components in a central location and then adding a mapping
 to
them.
  
  
  
   On Tue, Jun 25, 2013 at 4:01 PM, Rick Faircloth 
  r...@whitestonemedia.com
   wrote:
  
   
Hi, all...
   
I've been writing code for every project I've worked on for
 the
last
  10+
years.
I did that purposefully to make myself work in a manner which
would,

Re: Best means of setting a library of reusable code

2013-06-25 Thread Matt Quackenbush

Fair 'nuff.  :-)

On Tue, Jun 25, 2013 at 3:11 PM, Rick Faircloth r...@whitestonemedia.comwrote:


 sigh No, Matt... I didn't say your example is (not) relevant.

 I stated, I don't see how your example is relevant.

 See the difference? I put the fault on my part for not understanding your
 example.

 Your example may be perfectly relevant, but I couldn't see how.

 I think you just misread my statement and assumed I was being offensive
 about your example. If I had said, your example is not relevant, then
 that
 would be offensive, especially coming from me, someone who is the one
 asking everyone for assistance in understanding what I was trying to do!

 So, no offense intended...


 On Tue, Jun 25, 2013 at 2:35 PM, Matt Quackenbush quackfu...@gmail.com
 wrote:

 
  sigh I did. And you flatly stated that my example is (not) relevant.
 I
  was merely pointing out - mostly for those who happen upon this thread
  later, since they'll hopefully read and comprehend - that your assessment
  is flatly wrong.
 
  Good luck.
 
 
  On Tue, Jun 25, 2013 at 2:24 PM, Rick Faircloth 
 r...@whitestonemedia.com
  wrote:
 
  
   Matt, just participate in the conversation without being asinine about
  it.
  
   I haven't asked anyone to write my code for me. Just looking
   for some guidance as to the correct approach.
  
   So, offer your advice in a friendly manner, if you're going to offer
   it at all.
  
  
  
   On Tue, Jun 25, 2013 at 12:56 PM, Matt Quackenbush 
 quackfu...@gmail.com
   wrote:
  
   
You do it exactly like I said you do it: Pass it in as either an
  argument
or a property. When you instantiate your contact.cfc, you pass in
everything it needs from outside in order to do its job.
   
The example I gave is completely relevant, albeit not an example of
  your
exact situation. I don't know your exact situation and I'm not going
 to
write your code for you, but I - along with others here - have
  definitely
given you all the information you need to apply the principles to
 your
exact scenario.
   
   
On Tue, Jun 25, 2013 at 12:40 PM, Rick Faircloth
r...@whitestonemedia.comwrote:
   

 Your understanding is correct, Matt, but I don't see how your
 example is relevant.

 In my application.cfc, I've got a line that sets an application
   variable:

 cfset application.siteShortDomain = myShortDomain.com

 I need that application.siteShortdomain variable available when
contact.cfc
 runs.

 So, how would I go about this?

 (I just noticed what Brian and Russ added to the conversation,
 and Russ is correct, as you can see from above, that I want to
 extend
 the global application variables that I've set in application.cfc
 tp
   all
 the other cfc's that are in a common library of cfc's above the
  website
 root.

 ???

 Thanks!

 Rick


 On Tue, Jun 25, 2013 at 11:50 AM, Matt Quackenbush 
   quackfu...@gmail.com
 wrote:

 
  Hang on a minute. If I understand this correctly 
 
  So, how do I make the variables from application.cfc available to
   contact.cfc under
   such a scenario? Does the extends functionality of cfc's
 solve
this?
 
 
  ... you're thinking about adding `extends=Application` to your
  contact.cfc?  If that's a correct understanding on my part, then
  the
 answer
  is: HELL NO! DO NOT USE EXTENDS!
 
  Your CFCs should be self-contained and any outside variables
 they
need
  should be passed in as either arguments or properties. Here's a
contrived
  example.
 
  // foo.cfc
  component
  {
  property name=datasourcename
 
  function init( required string datasourcename )
  {
  variables.datasourcename = arguments.datasourcename
  return this
  }
 
  function doQuery()
  {
  // your query goes here
  return mycoolquery
  }
  }
 
  // test.cfm
  foo = createObject( 'component', 'foo' ).init(
 application.datasourcename )
  writeDump( foo.doQuery )
 
 
  HTH
 
  On Tue, Jun 25, 2013 at 11:41 AM, Rick Faircloth
  r...@whitestonemedia.comwrote:
 
  
   Alright, that's the confirmation I needed to proceed. So, use
 'extends
  it
   is!
  
   Thanks,
  
   Rick
  
  
   On Tue, Jun 25, 2013 at 11:21 AM, Russ Michaels 
   r...@michaels.me.uk

   wrote:
  
   
if you use EXTENDS, then everything in the parent CFC is
   available
 tot
  he
child.
If you want libraries to use on multiple sites, then you
 would
   need
 to
   put
the components in a central location and then adding a
 mapping
  to
 them.
   
   
   
On Tue, Jun 25, 2013 at 4:01 PM, Rick 

Re: Best means of setting a library of reusable code

2013-06-25 Thread Carl Von Stetten

Rick,

I don't know if this will help, but I've read about people creating 
proxy CFCs in or below the webroot specifically for AJAX requests. 
Those proxy CFCs either extend the protected CFCs (the ones outside 
the webroot) or have functions that call the protected CFCs through 
createObject() or other similar means (which breaks encapsulation, but I 
think that doing this was thought of as a justifiable exception to 
encapsulation).  You would still need to create mappings to the CFCs 
that reside outside the webroot, but you likely would have to do that 
anyway if you use the same CFCs elsewhere in your application.

-Carl V.

On 6/25/2013 12:03 PM, Rick Faircloth wrote:
 Well, the good news is that I can include the application variables in the
 AJAX post and pass them into the contact.cfc (which is also out of the
 webroot and in the library) via the AJAX call to contact.cfc.

 The bad news is, I have to type all those application variables into every
 AJAX call. But, at least I only have to type them in once for the reusable
 code!

~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:356076
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm


Re: Best means of setting a library of reusable code

2013-06-25 Thread Rick Faircloth

Thanks for that info, Carl...

I think I read somewhere about that while researching. I'll take another
look and see if I can make that work. It'll beat typing in all the
application variables for every call to the cfc's!

Rick


On Tue, Jun 25, 2013 at 3:39 PM, Carl Von Stetten
vonner.li...@vonner.netwrote:


 Rick,

 I don't know if this will help, but I've read about people creating
 proxy CFCs in or below the webroot specifically for AJAX requests.
 Those proxy CFCs either extend the protected CFCs (the ones outside
 the webroot) or have functions that call the protected CFCs through
 createObject() or other similar means (which breaks encapsulation, but I
 think that doing this was thought of as a justifiable exception to
 encapsulation).  You would still need to create mappings to the CFCs
 that reside outside the webroot, but you likely would have to do that
 anyway if you use the same CFCs elsewhere in your application.

 -Carl V.

 On 6/25/2013 12:03 PM, Rick Faircloth wrote:
  Well, the good news is that I can include the application variables in
 the
  AJAX post and pass them into the contact.cfc (which is also out of the
  webroot and in the library) via the AJAX call to contact.cfc.
 
  The bad news is, I have to type all those application variables into
 every
  AJAX call. But, at least I only have to type them in once for the
 reusable
  code!

 

~|
Order the Adobe Coldfusion Anthology now!
http://www.amazon.com/Adobe-Coldfusion-Anthology/dp/1430272155/?tag=houseoffusion
Archive: 
http://www.houseoffusion.com/groups/cf-talk/message.cfm/messageid:356086
Subscription: http://www.houseoffusion.com/groups/cf-talk/subscribe.cfm
Unsubscribe: http://www.houseoffusion.com/groups/cf-talk/unsubscribe.cfm