i met a guy who worked in coldfusion and specially...
# water-cooler
s
i met a guy who worked in coldfusion and specially in 11 version he said to me, Application scopes are the most evil scopes and components should be used as included files how far this statement is true and guy is very old and lots of experience
d
Not sure what the second half of your statement actually means, but application scope should not be used regularly or directly. Calling it evil is questionable and really just doesn't make sense.
p
I’m curious as to what this means, given that any DI implementation with singletons is saving those objects… in the Application scope.
d
You are not accessing application scope directly, it is an implementation detail hidden behind your factory. As a developer you don't care where or how it is cached and so you don't "know" it is in application scope. Yes you know because everyone tells you where it is but if you didn't look behind the curtain you wouldn't know and you shouldn't care.
c
The phrase
components should be used as included files
tells me that this person only uses CFCs as function libraries, not as "objects" in the way that CFCs are typically used most often in modern CFML apps.
👍 2
To paraphrase what @Peter Hoopes and @deactivateduser are saying above, it's okay to use the application scope to store application-wide objects.... but, they should be abstracted and accessed through a high-level component and the app code should not be littered with references to
application.myWidget
all over the place.
w
Application scopes are the most evil scopes and components should be used as included files
if this statement is accurately quoted, then this ranks as one of the most inane and stupid statements related to cf i think i've heard. forget the nuance, it's just dumb on its face
a
Atop of what everyone else says here, which I agree with (except I would have been somewhat more harsh in my assessment of the original advice), I would add two things: • "and guy is very old and lots of experience". There's a logical fallacy called "argument from authority" (https://en.wikipedia.org/wiki/Argument_from_authority) that applies here. • I know a lot of CFML devs who have been doing CFML for 20yrs. Unfortunately it's the same one year, 20 times over.
🤣 2
d
Eh wouldn't call it that far, it is a statement that has been blown out of proportion on 2 views of how to code. first half saying you should have minimum amount of global state second half says that cfc's should be used a dumb libraries and not classes with bloated data. First part most folks can agree on the second part I know many developers have promoted that, especially if you go something like the flyweight pattern https://en.wikipedia.org/wiki/Flyweight_pattern its a statement like the old grizzled guys would tell their grandkids to keep them out of the forest.
But the statement as written, if that is directly quoted, makes the person's authority come into question purely because it is so blown out of proportion and has no criteria on how/why/when to apply the advice.
2
s
"very old and lots of experience" in the CF world can also mean "lots of experience doing the things I learned 30 years ago and zero experience updating those things"
a
If one wants function libraries over objects... I'm not sure why one would put the functions inside
component {}
, within a file with a
.cfc
extension. Seems to be a pointless abuse of the technology to hand. Just... put the functions in a
.cfm
file. TBH though... yer not gonna make very many friends writing code like that without good reason.
(@sknowlton has been looking at my CV again, by the sounds of it)
d
The only benefit of using cfc for function libraries, is it is easier to manage double includes.
a
Can you expand on that?
c
I think for a while after CFCs first came out, a lot of people used them instead of custom tag libraries. Stuff a bunch of stuff in utility.cfc, cache it in an application scope variable, then call
application.utility.myFunction()
all over the place. That was my first exposure to using CFCs way back in the day.
s
Back when we last tried to hire CF developers, I was appalled at how many "very old" candidates with "lots of experience" were just woefully out of touch with almost any progress that had actually been made in the last couple of decades...
1
a
(I have to admit I have no idea what
include "My.cfc"
would actually even do. I would have thought it would have just slapped everything within the .cfc file into the including-file's variables scope)
d
Putting a bunch of functions in a
cfm
file you then need to make sure you don't include that
cfm
file twice when including other
cfm
files. So when we came across this we just built out a cfc with the function and instead inside the "library"
cfm
file we used that to instantiate the library and have it in a variable. That way if that
cfm
file was included twice it didn't doublt define a function, it just rewrote over the variable
Not saying you should use this strategy in todays world, but when we were dealing with a mess of a legacy app it helped keep things from getting to messy quickly
w
this discussion about using cfm files for 'udf libraries' rather than cfcs is a total non-starter in the dependency injection world. how is it even a topic?
a
we used that to instantiate the library and have it in a variable
Yeah, but that's _not "_components should be used as included files"
d
Well that is why my original statement said I wasn't sure what the second meant. But going off someone else "redefining" it came to me to be the above
a
@websolete a runtime mixin is a type of dependency injection. There's more than one way to skin a cat. As long as the cat gets skinned.
☝️ 1
(am not advocating mixins either static or runtime. But was just an example)
(and I mean I actively advocate against mixins as a concept)
(for shits 'n' giggles... https://blog.adamcameron.me/2021/06/cfml-messing-around-with-mixins-part-3.html. Links to parts 1&2 in first para)
w
dunno, seems like a lot of work to validate some blanket, unfounded statement by random cf guy that probably prefers tags over script because 'that's how cf was intended to be written'. and if you want mixins, you can have cfc-based ones without the need for any cfms
a
I'm not validating anything about the original statement. I was offering a counter to your blanket statement.
w
if the guy is going to spew dogma, it better be good dogma
didn't think you were advocating the original
a
it's not dogma. It's dogshite.
w
also, TIL there is more than one application scope
a
huh?
w
see original quote
a
Go on then... (new thread maybe?)
w
could be a typo
a
oh ok hang on
"Application *scopes*" I see what you did there.
Pendant.
\me lies in wait...
w
anal retentives are the most evil of the retentives
a
Copy code
<cfapplication name="app1">
<cfset application.myvar = "first application scope">
<cfapplication name="app2">
<cfset application.myvar = "second application scope">

<cfdump var="#application#"> <!--- second application scope --->

<cfapplication name="app1">
<cfdump var="#application#"><!--- first application scope --->

<!--- Tada! multiple application scopes :-) --->
m
crikey what did I wander into here. lol
☝️ 1
☝🏻 1
a
yeah, don't touch anything, and wipe yer shoes on the way out. Or burn them.
And... good evening Mister @Mark Takata (Adobe)
m
Good evening to you sir. Hell of a day. It is like 90 degrees here. Totally loony.
a
Ugh. I only had a half-day today (school run), so it was OK but 100% meetings. Not 90degF either. 6deg here (in modern units)
😂 1
s
'modern', please, I have more fingers than you have degrees
m
I'm an old school kind of guy, what can I say? lol
a
(and that's on each hand, right Sam? ;-))
m
Adam is technically correct. The best kind of correct. Celsius is the younger of the two systems.
Which is why I'll now be only describing the temperature here in the MOST modern of the scales, Kelvin. As soon as I figure out how the hell to do that lol
a
hahahahaha
"pheweeee.... 300Kelvin in the shade today!!"
m
hashtag balmy
But really, it is a dry heat
a
Well TBH I'd just be happy with not feeling the urge to look skyward and mutter "oh just *fuck off*", whenever I walk outdoors ATM.
(not the weather, just hate the person living upstairs 😉 )
m
lol
s
I thought that's what 'Scotland' meant in one of those charming, old languages ya'll have over there
m
Like "English"?
I don't think anyone actually speaks that anymore tbh 😄
a
I live too close to Essex for the local dialect to still be be considered "English"
I must say we are really outdoing ourselves in including all this random conversation In @Simone’s thread about including .cfc files into the application scopeS
Where's the "don't use a thread please!" police when we need them?
m
Blimey! Well, in fairness, this WAS posted to water cooler. So there is that. Sorry Simone :(
s
Oh we know all about Wessex! Colin Firth told us