Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

2 different types of singleton

 
author
Posts: 14112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator

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!
 
Ranch Hand
Posts: 490
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator

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.
 
Bartender
Posts: 1844
Eclipse IDE Ruby Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
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.
 
author
Posts: 4342
40
jQuery Eclipse IDE Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator

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.
 
Ranch Hand
Posts: 809
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
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
 
Ranch Hand
Posts: 1078
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator

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
Posts: 809
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator


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 ]
 
Ranch Hand
Posts: 1608
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator

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.
 
Greenhorn
Posts: 13
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
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
Posts: 1078
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator

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
Posts: 1608
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator

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.
 
Ranch Hand
Posts: 1923
Scala Postgres Database Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
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.
 
author and iconoclast
Posts: 24207
46
Mac OS X Eclipse IDE Chrome
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Report post to moderator
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.
 
What I don't understand is how they changed the earth's orbit to fit the metric calendar. Tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
    Bookmark Topic Watch Topic
  • New Topic