Re: CFCs - Rule of thumb when to use
Yeh, I'd go with that. Not overkill at all and good thinking. If you also have mini app specific checks, you could extend the 'global' cfc too. And apologies for souding like a patronising git, I misread you as not having used cfcs in an app before ;) Lol, didn't take it that way at all. I just didn't want my initial post to be swamped in detail :-). I've actually been using CFC's for a few years now but I've been unclear as to if I'm using them in the right way. I appreciate that these things aren't black and white but I just want to get an opinion on my approach. In my head I know that I should be using CFCs as a tool for common/specific tasks but then I look at the example(s) below and think a) it's overkill and more code and b) I'm breaking a simple process down into two separate parts which might not be needed this way anyway! No CFC approach: cfif not session.username) cflocation url=login.cfm addtoken=no / /cfif RESULT: Simple, three lines, job donebut no not modular and results in duplication. CFC approach (1): - // Get CFCs UserManager = createObject(component,com.userManager).init(); AppManager = createObject(component,com.appManager).init(); // Check that the username exists in a session (returns boolean). userChecker = IWSCFCManager.getUserName(); // No username. Send them to the login page if(not userChecker){ appManager.getLogingPage(); } RESULT: Process is now in two separate areas so good that it's modular and can be cached but it's more external files to deal with. or I guess all this could be far more generic. CFC approach (2) - More generic CFC approach: - // Get CFC AppManager = createObject(component, com.appManager).init(); // Check that the user exists in the session scope using a generic variable checker. This method takes two parameters, the scope and which variable to look for. Returns boolean. userChecker = AppManager.getVariable(session,username); if(not userChecker){ // This method does a redirect appManager.redirectUser(login.cfm); } RESULT: One CFC and could use this for all kinds of things then again I could just use a structKeyExists :-)... and oh look!!! I'm back to another way of coding CFC approach 1 (ARRGGGHHH!!!) There are many paths but I'm just concerned that I make the wrong one for the wrong reasons :-) @Gerald - Thanks for all those links. OO concepts are something I've never used but I've got a good understanding of how it works in principle. I do aim to keep everything encaplusated in my CFCS and I'm keen to look at things like ColdSpring at some point soon. When I get two geeky minutes :-) Thanks again for the feedback, James ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;192386516;25150098;k Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:303020 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Re: CFCs - Rule of thumb when to use
I'd recommend looking at ColdSpring or Litewire now. These help answer a lot of the questions about how organise and separate the CFCs and how to make them work with each other. On Wed, Apr 9, 2008 at 9:22 PM, James Buckingham [EMAIL PROTECTED] wrote: Yeh, I'd go with that. Not overkill at all and good thinking. If you also have mini app specific checks, you could extend the 'global' cfc too. And apologies for souding like a patronising git, I misread you as not having used cfcs in an app before ;) Lol, didn't take it that way at all. I just didn't want my initial post to be swamped in detail :-). I've actually been using CFC's for a few years now but I've been unclear as to if I'm using them in the right way. I appreciate that these things aren't black and white but I just want to get an opinion on my approach. In my head I know that I should be using CFCs as a tool for common/specific tasks but then I look at the example(s) below and think a) it's overkill and more code and b) I'm breaking a simple process down into two separate parts which might not be needed this way anyway! -- mxAjax / CFAjax docs and other useful articles: http://www.bifrost.com.au/blog/ ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;192386516;25150098;k Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:303023 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=11502.10531.4
Re: CFCs - Rule of thumb when to use
I'd recommend looking at ColdSpring or Litewire now. These help answer a lot of the questions about how organise and separate the CFCs and how to make them work with each other. Thanks James but my question was aimed more at what I should be putting in CFC's rather than how I should organise them. Hence why I was asking about the Rule of thumb. I could do everything in them but I'm wondering if there are scenerios where they're overkill, the example being the one I've mentioned. I saw a presentation on ColdSpring at Scotch on the Rocks last year and I've seen a few more online. I'm still trying to get my head around it all though to be honest. Litewire I've not seen but I'll have a look ;-). ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;192386516;25150098;k Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:303026 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
CFCs - Rule of thumb when to use
Hi everyone, I'm just putting the foundation code into a new project and I was wondering if I could get some opinions on CFC approach from people. The vast majority of our systems come from a previous CF5 environment. This is the first project I've had the opportunity to do since we moved into our new CF7 environment though. I'm keen to try and get our more regularly used code into some CFCs so it's easier to plug into things in the future. The issue I've got is that some of the regular code is so smaller that I feel that a CFC is overkill. It's simply things like (pseudo): if (NOT (is this user login?)){ send them to the login page } which appear in every one of our applications but it's a two second job to put it in. At the moment I've got this inside my application.cfc so there is a modular sense already but I'm wondering where do people draw the line when it comes to things like this? Is this overkill or does the benefits of having this in a CFC outweigh that? Thanks, James ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;192386516;25150098;k Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:302924 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: CFCs - Rule of thumb when to use
I imagine you'll get a heap of response to this! What I would say is that simply using CFCs is not neccessarily going to make the code more scalable and reusable. What will help with that is using a solid framework for your application in which the CFCs have their purpose and position well defined. There are plenty of Frameworks to choose from. My preference is Model-Glue, an MVC (Model, View, Controller) Framework - use of CFCs to define the model of the application makes a whole lot of sense and is a joy to code(!). Once the basic concepts are understood, I'd say it was not overkill at all. However, if time is not on your side and it seems overkill now; I'd consider using any existing framework that they use while you get to grips with the bounty of joyous learning that awaits you in your own time (though if your bosses are willing to pay for that extra time, all the better)! HTH Dominic -- Blog it up: http://fusion.dominicwatson.co.uk ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;192386516;25150098;k Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:302926 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: CFCs - Rule of thumb when to use
Thanks Dominic, That reminds me that I should add that I'm using Fusebox5.0 (MVC) and looking to do most of the SQL in Transfer as well ;-). My way of thinking was that I'd put the initial checks specific to our core system (this one is a mini app running off the back of the core) within a CFC and call it from the application.cfc. That CFC would sit in a location which is mapped and accessible to all the other apps if we decide to repoint them. It's just as a I was writing it that I thought I'm doubling up what I'm doing here as I could probably just write all this inside the application.cfc instead. Of course doing that means I'm mixing it up with all my custom code. Hopefully you can see the 6 and 3*2's scenerio I've got myself in here :-). Cheers, James ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;192386516;25150098;k Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:302927 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: CFCs - Rule of thumb when to use
@ Dominic with the bounty of joyous learning that awaits you Your not a geek. Nope, not at all. ;) @James Actually your first example is a perfect example for using a cfc. I have been in the same boat over the last year or so, Tying to apply OO principles to a 1400 page intranet that dates back to CF 4. The first question I ask is am I going to use this again? The first principle(s) of OO is Encapsulation and/or DRY. The process learning OO can be very intimidating at first. I would recommend taking a look at this presentation from the folks at Netobjectives as a starter. http://www.netobjectives.com/streamzines/EncapsulateThat/player.html This is also very helpful in getting your head around the basics of OO: http://www.netobjectives.com/files/Encapsulation_First_Principle_Object_Oriented_Design.pdf As is The Net Objectives Pattern Repository. Design patterns can be dificult to get your head around at first. This helps explain Design patterns in simple, concrete terms that allows you to see how they are used to solve problems with out getting into a lot of theory. http://www.netobjectivesrepository.com/http://www.netobjectivesrepository.com/TheFacadePattern And no, I don't know them or have any interest in the company. I just ran into them on Brian Kotek's blog and recognized it as an excellent resource. HTH G -- Education is a progressive discovery of our own ignorance. - Will Durant ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;192386516;25150098;k Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:302934 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4
Re: CFCs - Rule of thumb when to use
Your not a geek. Nope, not at all. ;) Me?! Certainly not. My way of thinking was that I'd put the initial checks specific to our core system (this one is a mini app running off the back of the core) within a CFC and call it from the application.cfc. That CFC would sit in a location which is mapped and accessible to all the other apps if we decide to repoint them. Yeh, I'd go with that. Not overkill at all and good thinking. If you also have mini app specific checks, you could extend the 'global' cfc too. And apologies for souding like a patronising git, I misread you as not having used cfcs in an app before ;) Dominic On 08/04/2008, Gerald Guido [EMAIL PROTECTED] wrote: @ Dominic with the bounty of joyous learning that awaits you Your not a geek. Nope, not at all. ;) @James Actually your first example is a perfect example for using a cfc. I have been in the same boat over the last year or so, Tying to apply OO principles to a 1400 page intranet that dates back to CF 4. The first question I ask is am I going to use this again? The first principle(s) of OO is Encapsulation and/or DRY. The process learning OO can be very intimidating at first. I would recommend taking a look at this presentation from the folks at Netobjectives as a starter. http://www.netobjectives.com/streamzines/EncapsulateThat/player.html This is also very helpful in getting your head around the basics of OO: http://www.netobjectives.com/files/Encapsulation_First_Principle_Object_Oriented_Design.pdf As is The Net Objectives Pattern Repository. Design patterns can be dificult to get your head around at first. This helps explain Design patterns in simple, concrete terms that allows you to see how they are used to solve problems with out getting into a lot of theory. http://www.netobjectivesrepository.com/ http://www.netobjectivesrepository.com/TheFacadePattern And no, I don't know them or have any interest in the company. I just ran into them on Brian Kotek's blog and recognized it as an excellent resource. HTH G -- Education is a progressive discovery of our own ignorance. - Will Durant ~| Adobe® ColdFusion® 8 software 8 is the most important and dramatic release to date Get the Free Trial http://ad.doubleclick.net/clk;192386516;25150098;k Archive: http://www.houseoffusion.com/groups/CF-Talk/message.cfm/messageid:302937 Subscription: http://www.houseoffusion.com/groups/CF-Talk/subscribe.cfm Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4