|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
CFC vs. CFINCLUDE for function librariesx
Can anyone please briefly discuss pros and cons of using a CFC as opposed to a CFINCLUDE for function libraries (collections of common functions used throughout an application)?
|
|
#2
|
|||
|
|||
|
It depends on what you want to do. But CFCs support more OO elements like encapsulation, polymorphism, and inheritance. If all you need is a simple set of UDFs, an include might be fine. But even for simple sets of UDFs, nowadays I create a Utility (or whatever) CFC, instantiate it at request start (or into the application scope at application initialization) and then call methods on it. That way you can pass the Utility CFC into your other CFCs in the future while maintaining encapsulation.
__________________
Ask if you have a question, but also help answer questions that you have knowledge of! Thanks, Brian. How to Post a Question in the Forums |
|
#3
|
|||
|
|||
|
I have other low-level programmers mucking in my code, so if I don't want them to touch something or break something I put what I can in a cfc. They don't go in those files so it's more safe than in an include. Just a learned preference.
|
|
#4
|
|||
|
|||
|
Encapsulation in action.
![]() |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ColdFusion Development > CFC vs. CFINCLUDE for function libraries |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|