• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Lightweight CFC's in Application Scope

Community Beginner ,
Jul 07, 2006 Jul 07, 2006

Copy link to clipboard

Copied

Hi ,

I am looking for a way to reduce database calls and at the same time avoid the creation of many many redundant CFC's which all would end up serving the same purpose. My question to all the ColdFusion gurus is, is it acceptable to store 5 - 10 lightweight cfc's in the application scope and use their properties such as url and heading to load the data into the cfml template instead of going back to the database to reset those properties every page load? Thanks for your valued input.

--Brian
TOPICS
Advanced techniques

Views

319

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jul 07, 2006 Jul 07, 2006

Copy link to clipboard

Copied

i'm not following you too close.
Have you tried cfmodule instead of cfinclude?
sorry, probably doesn't help, i don't understand what you're trying to do.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 07, 2006 Jul 07, 2006

Copy link to clipboard

Copied

I think it is acceptable to use the application and server scopes so
that one does not have to create a new instance of a CFC for every
session that comes along.

One should do this wisely and be aware of what type of CFC's play well
this way and what type do not.


madtux2 wrote:
> Hi ,
>
> I am looking for a way to reduce database calls and at the same time avoid the
> creation of many many redundant CFC's which all would end up serving the same
> purpose. My question to all the ColdFusion gurus is, is it acceptable to store
> 5 - 10 lightweight cfc's in the application scope and use their properties such
> as url and heading to load the data into the cfml template instead of going
> back to the database to reset those properties every page load? Thanks for
> your valued input.
>
> --Brian
>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 07, 2006 Jul 07, 2006

Copy link to clipboard

Copied

As long as the data is never going to change, there is more than one way to make it always available. Application variables are one such method, but lightweight cfc's might constitute excessive complication.

But if your data changes, you have to do something to update your app.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 10, 2006 Jul 10, 2006

Copy link to clipboard

Copied

Dan Bracuk wrote:
> As long as the data is never going to change, there is more than one way to
> make it always available. Application variables are one such method, but
> lightweight cfc's might constitute excessive complication.

Why are you saying that CFCs constitute excessive complication? When
done well objects are typically simpler to use because you make a simple
method call to the CFC to retrieve the data. I drop CFCs into my
Application and Session scopes all the time and it's an extremely
effective approach.

Matt
--
Matt Woodward
mpwoodward@gmail.com
Adobe Community Expert - ColdFusion

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 10, 2006 Jul 10, 2006

Copy link to clipboard

Copied

quote:

Originally posted by: Newsgroup User
Dan Bracuk wrote:
> As long as the data is never going to change, there is more than one way to
> make it always available. Application variables are one such method, but
> lightweight cfc's might constitute excessive complication.

Why are you saying that CFCs constitute excessive complication?


Because writing cfcs and calling methods is more complicated than putting that code right in your template. You need justification for this extra work. In my opinion, and yours may differ, the only acceptable justification is to produce re-useable code.

This thread is about application variables. In that context, the code might not get used anywhere else, I don't know, it's not my app. However, if the code does not get used anywhere else, writing cfcs would be extra work with no extra value.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jul 11, 2006 Jul 11, 2006

Copy link to clipboard

Copied

LATEST
Dan Bracuk wrote:
> Because writing cfcs and calling methods is more complicated than putting that
> code right in your template. You need justification for this extra work. In
> my opinion, and yours may differ, the only acceptable justification is to
> produce re-useable code.

Reuse is only one reason (and not even the most compelling reason) to
use objects. There's tremendous value in encapsulation and abstraction
as well. You're correct, it all depends on the application. To me the
amount of extra work is both minimal and worth it in most cases if you
have a group of application variables that form a logical grouping. If
it's a handful of completely independent application variables then
you're right, might not make sense to put it in an object.

Matt
--
Matt Woodward
mpwoodward@gmail.com
Adobe Community Expert - ColdFusion

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation