• Post Reply 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:
  • Tim Cooke
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Rob Spoor
  • Bear Bibeault
Saloon Keepers:
  • Jesse Silverman
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
Bartenders:
  • Piet Souris
  • Al Hobbs
  • salvin francis

Regarding Monkhouse's SCJD book

 
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

I have read "SCJD Exam with J2SE 5". There is something that I do not understand in implementation of sampleproject.db.DvdDatabase:

according with its javadoc, that class (DvdDatabase) will be instanciated for each connected client. OK. But there is a static member (DvdFileAccess database) that is instantiated from DvdDatabase() constructor. This means that each client will create a new DvdFileAccess - and this is marked as static. This is what I do not understand - why this DvdFileAccess is static but each new client creates a new instance ?

Regards,
Catalin Mihalache
 
author and jackaroo
Posts: 12199
280
Mac IntelliJ IDE Firefox Browser Oracle C++ Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I would have to say that this is a mistake on my part. I will have to write up a suitable replacement and get it added to the errata.

Thanks for bringing it to our attention.

Regards, Andrew
 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have downloaded the latest sources and this was not addressed yet.

Maybe the authors can look at this as well:

On Page 155, the releaseLock Method does an == test. i.e.

if (reservations.get(upc) == renter) {

Should this not rather be an .equals. as in
if (reservations.get(upc).equals.(renter)) {
 
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,

thanks a lot Catalin for bringing up this topic! I was wondering about this also, and as the errata correction is not yet online I would like use this occasion to ask something (I'm afraid it's rather stupid to ask a question like that, but as it's troubling me I just try...):

I was wondering if the DvdFileAccess (or rather my equivalent class) should be static or not, and what would be the consequences.

- If it's static, it's in fact a singleton even though I don't use this pattern, right?
- If it's static, I have to synchronize between seek's and read's, but if it's not and every DvdDatabase gets its own (and every thread uses its own DvdDatabase like in the RMI solution), I don't need to synchronize, do I?
- Last not least, do you consider a non-static DvdFileAccess a sensible option too - what would you prefer?

Sorry if these questions sound too stupid for this forum (in fact with this assignment I notice there are big differences between having the theoretical knowledge of SCJP and making design decisions...)
Ciao
Sigrid
 
You showed up just in time for the waffles! And this tiny ad:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
reply
    Bookmark Topic Watch Topic
  • New Topic