Doug's Resume
OO Lexicon
Chat with Doug!
Recent Entries
You may also be interested in...

heaters
hotels boeken in 7 sec
Engagement Rings
Online Dating Australia




SURF'S UP!
You:
Your Web Site:
<< July, 2008 >>
SMTWTFS
12345
6789101112
13141516171819
20212223242526
2728293031
Search Blog

ColdFusion Jobs
Recent Comments
Categories
Archives
Photo Albums
Funnies (5)
Family (3)
RSS
Reciprocal Links

Powered by
BlogCFM v1.11

22 March 2007
Just What IS the Singleton Pattern, Anyway?

You, O Best Beloved, are a Singleton. There is nobody else like you in the whole wide world, nor has there ever been. You’re a singular occurrence, a unique random combination of genetics that exists only wherever you happen to be at a given moment. And if any of  your friends wants to interact with you, they know just where to find you. You can interact with lots of different people, but no matter how many friends you may have, every one of them is interacting with the exact same YOU. When your good friend Dave asks you to tell Theresa hello next time you see her, you store that information and next time you interact with Theresa, you pass along that exact message.

 
You getting the picture here? If you instantiate a CFC and put it in a place (Application scope, anyone?) where EVERY other part of your application is able to interact with THAT PARTICULAR instance of your CFC, then YOU, O Best Beloved, have created your object as a Singleton. Now, for whatever reason, people seem to be awfully fond of tossing around the buzz phrase “Singleton Pattern”…not sure why. It’s way simpler just to use the word as an adjective describing how you have instantiated your object, and it makes more sense, too.

 A few other thoughts on Singletons…
 

  • It’s vital to understand this term because it has a huge effect on how your app will work. Basically, if an object is created as a Singleton and you aren’t able to visualize what that means, you could have people seeing other people’s data. Not good.
  • That I’m aware of, there is no opposite of Singleton...an object either IS a Singleton, or it isn't.

 
POP QUIZ!

Which of the lines of code below is creating my object as a Singleton?

A) <cfset adminObject = createobject("component",model.admin) >

B) <cfset application.adminObject = createobject("component",model.admin) >




Posted by dougboude at 4:41 PM | PRINT THIS POST! |Link | 2 comments
Subscription Options

You are not logged in, so your subscription status for this entry is unknown. You can login or register here.

Re: Just What IS the Singleton Pattern, Anyway?
When you began point #2 with the "That I'm aware of," I didn't quite understand the subtle nuance of that phraseology.

I wonder if you could supply the answer upside down on this page?
Now THAT would be a bit of CSS!
Come to think of it, I know that there's some sort of RIGHT-TO-LEFT CSS...
Posted by psenn on March 23, 2007 at 1:55 PM

Re: Just What IS the Singleton Pattern, Anyway?
> When you began point #2 with the "That I'm aware of," ...
psenn,

I understood that phrase to mean "as far as I know" or "to the best of my knowledge"
Posted by jm on April 4, 2007 at 2:48 PM

Name:   Required
Email:   Required your email address will not be publicly displayed.

Want to receive notifications when new comments are added? Login/Register for an account.

Time to take the Turing Test!!!

What letter comes four place(s) before the letter N?
Type your answer exactly two time(s) in the designated box.

Type in the answer to the question you see above:

Your comment:

Sorry, no HTML allowed!