The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
SCJP 1.4 100%
SCJD 99.5%
The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
SCJP 1.4 100%
SCJD 99.5%
The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
SCJP 1.4 100%
SCJD 99.5%
Alecsandru Cocarla wrote:Well, I used a singleton, not for the Data class, but for the file access manager class (and also for the record lock manager). And I think it's not wrong.
The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
Andrew Monkhouse wrote:
If you are using a Singleton for the file access manager class, how are you going to handle any future enhancement requests (such as a likely request for the ability to handle more than one table within the application)? Or are you just considering this out of scope? (a valid design design).
SCJP 1.4 100%
SCJD 99.5%
Roel De Nijs wrote:
And what is the reason why you made your file access manager thread safe? because you use synchronize on each method (read, update,...) to make them atomic operations?
And how did you implement your singleton, because i was also thinking about doing so and i was wondering if my singleton had to be thread-safe itself or not (i read some articles on the net about it and it's not that easy). And did you go for a classic implementation (with the getInstance) or for the new approach of joshua bloch: "a single-element enum type is the best way to implement a singleton"
SCJP 1.4 100%
SCJD 99.5%
Alecsandru Cocarla wrote:
Synchronization is used only for file access operations. Any other operations (like transforming from string to byte) are performed asynchronous. So, the methods are not entirely synchronized, just portions of them.
Alecsandru Cocarla wrote:
And I don't think that "single-element enum type is the best way to implement a singleton".
Alecsandru Cocarla wrote:How would you do it? I mean, non-singleton way (we agreed that the implementation from the book is not really non-singleton).
SCJP 1.4 100%
SCJD 99.5%
Tell me how it all turns out. Here is a tiny ad:
Low Tech Laboratory
https://www.kickstarter.com/projects/paulwheaton/low-tech-0
|