6 Replies Latest reply on Jul 11, 2006 7:39 AM by Newsgroup_User

    Lightweight CFC's in Application Scope

    madtux2
      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
        • 1. Re: Lightweight CFC's in Application Scope
          ghartong
          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.
          • 2. Re: Lightweight CFC's in Application Scope
            Level 7
            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
            >
            • 3. Re: Lightweight CFC's in Application Scope
              Dan Bracuk Level 5
              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.
              • 4. Re: Lightweight CFC's in Application Scope
                Level 7
                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
                • 5. Re: Lightweight CFC's in Application Scope
                  Dan Bracuk Level 5
                  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.
                  • 6. Re: Lightweight CFC's in Application Scope
                    Level 7
                    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