• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Regarding Monkhouse's SCJD book

 
Catalin Mihalache
Greenhorn
Posts: 16
  • Mark post as helpful
  • send pies
  • 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
 
Andrew Monkhouse
author and jackaroo
Marshal Commander
Pie
Posts: 12007
215
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • 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
 
Marius Snyman
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
  • 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)) {
 
Sigrid Kajdan
Ranch Hand
Posts: 72
  • Mark post as helpful
  • send pies
  • 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
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic