Search the web
Sign In
New User? Sign Up
stlroundtable · Saint Louis Developers' Roundtable
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Want to share photos of your group with the world? Add a group photo to Flickr.

Best of Y! Groups

   Check them out and nominate your group.
Having problems with message search? Fill out this form to ensure your group is one of the first to be migrated to the new message search system.

Messages

  Messages Help
Advanced
Messages 290 - 319 of 459   Oldest  |  < Older  |  Newer >  |  Newest
Messages: Simplify | Expand   (Group by Topic) Author Sort by Date ^
290
OK, This question came up at work, and I was curious to see if there were any strong opinions out there. ... class Singleton { static { // init } static public...
Louis K. Thomas
louisthom
Offline Send Email
Feb 6, 2002
6:45 pm
291
#1 is not really a singleton. Static methods are not very plugable and don't get the benefits of a singleton in many cases. For instance, lets say that you...
Shoemaker, Michael (S...
mshoemaker@...
Send Email
Feb 6, 2002
6:56 pm
292
... and ... a ... are ... do ... saying ... of I'll say it, then: :-) Static initializers that do any non-trivial work (i.e., anything that could possible...
Kyle Cordes
kylejcordes
Offline Send Email
Feb 6, 2002
8:19 pm
293
It all comes down to when you create your instance. In method #1, you create it in the static initializer. I'm not sure I agree with the debugging issues; I've...
crazyboblee
Online Now Send Email
Feb 6, 2002
9:22 pm
294
Oh, yeah, and throwing Exceptions in static initializers is not permitted (if you want your app to continue to run). From my experience, if something fails in...
crazyboblee
Online Now Send Email
Feb 6, 2002
9:29 pm
295
From: "crazyboblee" <crazybob@...> ... Go write some code that throws an exception during static initialization, then try to debug it. For extra fun,...
Kyle Cordes
kylejcordes
Offline Send Email
Feb 6, 2002
9:38 pm
296
... Runtime exceptions can always be thrown, and produce the delightful stack traces I mentioned before. ... Indeed, often in hard to track down ways. [ Kyle...
Kyle Cordes
kylejcordes
Offline Send Email
Feb 6, 2002
9:40 pm
297
Thanks for the replies so far. I am amused that what everybody has attacked so far is the static initialization, which I put in to my example just for ...
Louis K. Thomas
louisthom
Offline Send Email
Feb 6, 2002
10:03 pm
298
Louis, This is an issue that I've bounced back and forth on, but have finally adopted #2 as my preferred method for coding a singleton. My reasons are...
Jack Frosch
jackfrosch
Offline Send Email
Feb 6, 2002
11:48 pm
299
... Um, wouldn't the class being unloaded wreak equivalent havoc on example #2's shared static instance as on #1's static variables? Wouldn't the reload of the...
Louis K. Thomas
louisthom
Offline Send Email
Feb 7, 2002
12:37 am
300
Hi Louis, I always like to put some context in with a real world example. My favorite singleton is one that gets all the properties of the system. Here would...
Tim Burns
timburnsowlmtn
Offline Send Email
Feb 7, 2002
1:34 am
301
From: "Jack Frosch" <jfrosch@...> ... class' ... [...] It's nice to know that I am not the only one who avoids idioms that have the potential...
Kyle Cordes
kylejcordes
Offline Send Email
Feb 7, 2002
1:51 am
302
I don't think the class variable representing the singleton instance represents the state of the singleton, but is just a handle to it. If any object in the...
Jack Frosch
jackfrosch
Offline Send Email
Feb 7, 2002
2:18 am
303
Gang, You all have very good points. I think that the one thing about the #2 singleton pattern that was not mentioned was the flexibility to use polymorphism...
Jeff Osborn
java_osborn
Offline Send Email
Feb 7, 2002
3:13 pm
304
... multiple ... because ... First, you obviously have no idea how much experience I have writing code that uses static initialization. Second, those of us who...
crazyboblee
Online Now Send Email
Feb 7, 2002
3:47 pm
305
Louis, Just a quick note, this implementation is not thread-safe. This article does a good job of explaining why: ...
crazyboblee
Online Now Send Email
Feb 7, 2002
3:50 pm
306
This is a good example, but there is no need for your client to be exposed to these details. Using getInstance() and polymorphism does not allow you to extend...
crazyboblee
Online Now Send Email
Feb 7, 2002
3:58 pm
307
From: "crazyboblee" <crazybob@...> ... I would guess the answer is "a whole lot" from your comment, though :-) ... I've not been bitten by such a bug...
Kyle Cordes
kylejcordes
Offline Send Email
Feb 7, 2002
4:11 pm
308
... could ... It really depends on the nature of the solution. If the component is not critical, I'd print a warning and continue. If the application depends...
crazyboblee
Online Now Send Email
Feb 7, 2002
7:40 pm
309
Correct me if I'm wrong, but based on your description, if the Singleton class's ClassLoader can be reclaimed, than no client code would be left that could...
crazyboblee
Online Now Send Email
Feb 7, 2002
7:57 pm
310
This is true and it does happen. The only time I've seen this happen "in the wild" is when another program on the machine running the JVM had a memory leak...
Tim Burns
timburnsowlmtn
Offline Send Email
Feb 8, 2002
1:07 pm
311
It sounds to me like there was something else going on here. Maybe they were using a WeakHashMap or something? The VM shouldn't clear strong references under...
crazyboblee
Online Now Send Email
Feb 8, 2002
2:04 pm
312
OK all you Test-First gurus. You talk a good story, and I'd like to believe you that test first is The Way. I want to do it. But here's my real life problem: I...
Louis K. Thomas
louisthom
Offline Send Email
Feb 8, 2002
9:15 pm
313
I'm anything but a Test-First guru, but I do have a couple ideas. If you did a little refactoring and broke out a couple more methods, it would be easier to...
Bob Lee
crazyboblee
Online Now Send Email
Feb 8, 2002
11:19 pm
314
I'm forwarding this note for Paul. It was sent to the list owner by mistake... bba ... -- Brian Button bbutton@... Senior Consultant...
Brian Button
bbutton
Offline Send Email
Feb 11, 2002
4:05 pm
315
Another try. I don't know why the message wasn't forwarded the first time, but here is the text: Date: Mon, 11 Feb 2002 15:57:19 -0000 From: "paul_t_craig"...
Brian Button
bbutton
Offline Send Email
Feb 11, 2002
4:08 pm
316
... Louis> OK all you Test-First gurus. You talk a good story, and I'd Louis> like to believe you that test first is The Way. I want to Louis> do it. But...
Brian Button
bbutton
Offline Send Email
Feb 12, 2002
3:18 am
317
The task, as I originally conceived of it, is this: The thread's job is to open a server socket and then loop forever accepting client connections. For each...
Louis K. Thomas
louisthom
Offline Send Email
Feb 12, 2002
3:54 am
318
Bob, thanks for the comments! They actually gave me some ideas, but I've got a few questions about what you said. The refactoring that you suggested is already...
Louis K. Thomas
louisthom
Offline Send Email
Feb 12, 2002
4:19 am
319
... Louis> The task, as I originally conceived of it, is this: The Louis> thread's job is to open a server socket and then loop Louis> forever accepting client...
Brian Button
bbutton
Offline Send Email
Feb 12, 2002
4:28 am
Messages 290 - 319 of 459   Oldest  |  < Older  |  Newer >  |  Newest
Advanced
Add to My Yahoo!      XML What's This?

Copyright © 2009 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines - Help