Hi all, I¹m a relatively new coldfusion programmer (if I can call myself that) and I¹ve been working on an application for about two years now which hosts multiple websites under the same code base. The particular website is determined by the host header name, and it works, so far as it goes.
However, the app has grown dramatically, with the introduction of a lot of new features, to the point where maintaining the code is a terrible struggle. Currently it has about 500 templates, with snaky, messy code that leads here and there, and whenever I introduce a change or fix it breaks something else. Very procedural, etc, with something in excess of 100,000 lines of code. I came to the conclusion that putting together the new version, I¹m rewriting it from the ground up, using components as much as possible, but I¹m new to thinking in object oriented terms, so I was hoping to bounce my thinking off the list. In particular, I want to make the various functions as portable as possible, so I can reuse them wherever possible, and so I can routinely introduce new features. I¹m also concerned about performance with some of most recent changes to the app, a few of the hosted sites have taken an exponential leap in traffic (one of the sites is now drawing > 20k users/100,000 page views per day). There¹s a relatively small set of data, including the details of a particular organization, their formatting options, stylesheets choices, etc., which almost never change. My intent was to place those in an application scoped cfc. In the past, I¹ve maintained user data in a members table, with associated tables for custom fields (defined by the customer), donation histories, online profiles, uploaded photos, etc. This was all keyed off client variables, so logins were persistent. I¹m thinking to set up a session scoped cfc to retrieve all of this data when someone visits or logs into the site. New visitors, or those not logged in, would have null values here until they logged in or registered. Does it make sense to instantiate this object (call it member.cfc) in application cfm? I want to make sure the values in this are available throughout the application. I¹m not sure what kind of gotchas there are on session scoped components, though I¹ve been doing a lot of reading on the topic. There¹s a set of data which changes on a daily basis database of congressional contacts, phone numbers, faxes, etc., staffers, etc. Does it make sense to persist something like this in a component? The key factor is that when a website visitor visits a page, the data is personalized for example, if we have their zip code, the app determines who their representatives in Congress are and how they voted on specific legislation. I¹m inclined to create the object in the application scope, then call the various functions passing them the values for the members. The final set of data is the website content, which typically changes very frequently, as website visitors post blogs and comments in addition to the customer posted articles. Currently I cache most of these queries for time periods between 2 and 10 minutes to reduce load on the server. I¹m not sure of the impact of encapsulating all of this data into a persistent CFC. Do caching rules still apply? For example, if I have a function ³listarticles² in a persistent component, can I cache that query inside the CFC so that I don¹t impact the database more than currently? In most of these cases, I don¹t want the data to be around for the life of the object, both because it changes, and because there are tens of thousands of articles and blogs and I don¹t want to crush my web server. I hope all these apparently newbee questions aren¹t too vague. I¹m still getting a handle on how to best do this, and wanted to hear some thoughts from some of the folks here who are clearly more experienced at this. Finally as I recode and test this, I¹m wondering if there are any good tools out there which can give a view of what is going on inside the web server in terms of persistent component how much memory they are using, etc. I¹ve used FusionReactor, but that seems to only address currently running requests. Thanks, Charles ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Introducing the Fusion Authority Quarterly Update. 80 pages of hard-hitting, up-to-date ColdFusion information by your peers, delivered to your door four times a year. http://www.fusionauthority.com/quarterly Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:250847 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4

