aspose file tools*
The moose likes Java in General and the fly likes 2 different types of singleton Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Soft Skills this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Java » Java in General
Reply locked New topic
Author

2 different types of singleton

Ilja Preuss
author
Sheriff

Joined: Jul 11, 2001
Posts: 14112
Originally posted by Vj Kamath:
The universe is a singleton. God is a singleton. "The One" as they like to call


With all due respect, the only singleton that is *not* off topic for all forums at JavaRanch but Meaningless Drivel is the Singleton design pattern as it is used in the patterns community.

I think it would be good if we could restrict the discussion in this forum to the technical matters of the design pattern, and move the philosophical discussions - however interesting they are - to some more appropriate place.

Thanks!


The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Rusty Shackleford
Ranch Hand

Joined: Jan 03, 2006
Posts: 490
PLEASE ,dont compare java, and computer fundamentals with physics,maths or any other scrap


You know there is a reason why a heavy load of physics and mathematics is required for computer science and computer engineering.

Computer and programming language fundamentals is built on them.


"Computer science is no more about computers than astronomy is about telescopes" - Edsger Dijkstra
Joel McNary
Bartender

Joined: Aug 20, 2001
Posts: 1824

This was a very interesting thread. The arguments presented by Mr. Morris are quite fascinating. However, as far as I know and as I have been taught, the Singleton design pattern does not require that there be a Single instance -- just a controlled number of instances. I myself have implemented Singleton patterns such that there is one instance per Thread.

I also am in deep sympathy for Mr. Morris for his having to work on WebSphere. My deepest regrets.


Piscis Babelis est parvus, flavus, et hiridicus, et est probabiliter insolitissima raritas in toto mundo.
Scott Selikoff
author
Saloon Keeper

Joined: Oct 23, 2005
Posts: 3716
    
    5

Originally posted by Tony Morris:
Computational progression requires time (and therefore space) in order to exist. The laws of the physics are what makes Java possible even if indirectly or not immediately obvious. I had already put the disclaimer in place anyway; the casual observer will not see the correlation. It simply isn't taught at school despite being of utmost importance (market pressures aside).


Yes, because market pressues hate when programmers are forced to understand that time and space exist, instead of taking it as a given; it really interferes with their timetables.

In fact, since you doubt the existence of language, classloaders, and pretty much everything having to do with programming, then I one-up you be claiming that languages itself do not exist since they are just concepts with no concrete explanation. The bits floating through the web that happen to make it on to the website are shear luck of atoms and energy. In fact, heck, I'm not even sure anyone outside the room I am in exists, I can't be sure therefore doubt wins and I must be a sole brain floating in a vat in the Texas. The robots won and we are all playing their game. You figured it out.


My Blog: Down Home Country Coding with Scott Selikoff
Naseem Khan
Ranch Hand

Joined: Apr 25, 2005
Posts: 809
I think the definition given by Joel McNary is absolutely correct.

Controlled number of instances rather than single instance.

Single instance is a relative term. Important thing is who is the Observer. It could be Thread or class loader or even jvm.

Naseem


Asking Smart Questions FAQ - How To Put Your Code In Code Tags
Ken Blair
Ranch Hand

Joined: Jul 15, 2003
Posts: 1078
Originally posted by Naseem Khan:
I think the definition given by Joel McNary is absolutely correct.

Controlled number of instances rather than single instance.

Single instance is a relative term. Important thing is who is the Observer. It could be Thread or class loader or even jvm.

Naseem


He didn't give a definition.

The GoF book I have in front of me says "single instance" not "a controlled number of instances". It's not really a relative term, it simply requires a context.
Naseem Khan
Ranch Hand

Joined: Apr 25, 2005
Posts: 809

Originally posted by Joel McNary
However, as far as I know and as I have been taught, the Singleton design pattern does not require that there be a Single instance -- just a controlled number of instances. I myself have implemented Singleton patterns such that there is one instance per Thread.



Whatever you say relative or context? End result is same.


Naseem
[ July 19, 2006: Message edited by: Naseem Khan ]
Tony Morris
Ranch Hand

Joined: Sep 24, 2003
Posts: 1608
Originally posted by Scott Selikoff:


Yes, because market pressues hate when programmers are forced to understand that time and space exist, instead of taking it as a given; it really interferes with their timetables.

In fact, since you doubt the existence of language, classloaders, and pretty much everything having to do with programming, then I one-up you be claiming that languages itself do not exist since they are just concepts with no concrete explanation. The bits floating through the web that happen to make it on to the website are shear luck of atoms and energy. In fact, heck, I'm not even sure anyone outside the room I am in exists, I can't be sure therefore doubt wins and I must be a sole brain floating in a vat in the Texas. The robots won and we are all playing their game. You figured it out.


The first paragraph is probably sarcasm but correct nonetheless. The second paragraph is a digression from anything related to this thread and anything I have said, so I can only respond with "wtf?". Perhaps you are confusing my assertion that "singletons do not exist until spacetime is shown to be finite" with something related to programming languages and/or class loaders.

An alternative approach to the conclusion is to perform a thought experiment; conjecture some definition of "singleton", externalise it, expend effort attempting to derive some artifact which meets the aforementioned definition (it is quite easy for this case but I can help you out if you like) and then ask yourself if it is absurd to consider it a "singleton". If it does appear absurd, then conjecture a new definition for "singleton". If it doesn't appear absurd, repeat the process of deriving an artifact to meet the definition. If you have shifted your definition, repeat the entire process. After you have repeated it 10 or so times, we might consider discussing whether or not the process is in fact infinite (I assert that it is). After which, we would conclude that no such thing exists as a formal definition - only relative to the observer (i.e. you and I can have two different but legitimate definitions). We have already seen three definitions on this thread:
1) Class loader scoped data (to which I provided an artifact that is class loader scoped data and it was denied to be a singleton).
2) The GoF definition
3) Instance scoped data (making the "single" in "singleton" meaningless)

The third point has attached with it an extremely long discussion involving requirement analysis that I am most interested in, but concede to the fact that others may not or simply don't have the required background knowledge. Suffice to say that I haven't explicitly invoked a constructor in years - I have only ever declared an explicit constructor private and I also declare it to throw an exception at all times; I'll leave you to ponder that.

There is a name for the above method of logic, but sound reasoning (aka logic, mathematics, philosophy) seems to scare a few people and appears unrelated to software (which might well be a valid point for a given definition of software) so perhaps we should just leave it all be.


Tony Morris
Java Q&A (FAQ, Trivia)
Steve L. Williams
Greenhorn

Joined: May 20, 2006
Posts: 13
It is nice you claim that your often odd theories are proved mathematically. Problem is, I have yet to see you prove anything, just claim that it is proved.
Ken Blair
Ranch Hand

Joined: Jul 15, 2003
Posts: 1078
Originally posted by Naseem Khan:


Whatever you say relative or context? End result is same.


Naseem

[ July 19, 2006: Message edited by: Naseem Khan ]


Yeah, it probably is. I think I misinterpreted what you meant.
Tony Morris
Ranch Hand

Joined: Sep 24, 2003
Posts: 1608
Originally posted by Steve L. Williams:
It is nice you claim that your often odd theories are proved mathematically. Problem is, I have yet to see you prove anything, just claim that it is proved.


I assume this is addressed to me given the usual (from the Java community) adjective 'odd', which I reject, but I'll ignore it anyway. I have not claimed to have proven anything, not mathematically, not at all. However, I have claimed that the notion of a singleton has not been proven to exist. I have asked for a reasonably formal definition a couple of times - not for any other reason than I know that nobody will provide me with one (since it does not exist) and this is the 50th post on this thread, so I could continue ad infinitum or call it a day at 50. I'm proposing the latter.
Stefan Wagner
Ranch Hand

Joined: Jun 02, 2003
Posts: 1923

Multiton is mentioned at wikipedia:
"Multiton is a (disputed) term often used to describe a Singleton-like pattern that allows more than just one instance to be created."

I can imagine Dualton, Tripliton, Dozenton and Gigaton too.
Of course we should get the Singleton right, before discussing the Dualton.


http://home.arcor.de/hirnstrom/bewerbung
Ernest Friedman-Hill
author and iconoclast
Marshal

Joined: Jul 08, 2003
Posts: 24187
    
  34

Tony's got it right. Since this thread long ago left the path of righteousness, it's time to close it. Good night, and good luck.


[Jess in Action][AskingGoodQuestions]
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: 2 different types of singleton