wood burning stoves 2.0*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes DvdFileAccess  Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "DvdFileAccess  " Watch "DvdFileAccess  " New topic
Author

DvdFileAccess

Mohammad Yacin
Greenhorn

Joined: May 27, 2006
Posts: 5
Hi Guys and Gals,

How come the database is not defined as static in the DvdFileAccess class
of Denny's DVD sample project???

It is defined as
private RandomccessFile database = null;

However, it shoudl be static, otherwise the file will be accessed by multiple handles.

Please clarify.

Regards,
Mohammad Yacin
Greenhorn

Joined: May 27, 2006
Posts: 5
I'm sorry, but this Monkhouse book plus code on web of publisher is a piece of crap!
The source code on publisher website says something and the book says something else!

database in DvdFileAccess class is static in the book but instance in the code downloaded from website!

dbPath is static in the book and code. However, the check in the constroctor is

in the code downloaded from web site:
if (database == null) {


in the book

if (dbPath == null) {


What kind of nonsense is this!!!



I searched the forum and it seems the authors (most of the time) never address the serious issues of threading, etc.


I don't know what is going on!! Is it Sun not wanting them to publish a correct solution or what is it???



I think I can solve this on my own. I'm just abset that I wasted $25 for the ebook. I couldv'e had a nice Red Lobster meal with that money.

Anyway, peace Ya'll
Jeroen T Wenting
Ranch Hand

Joined: Apr 21, 2006
Posts: 1847
No, Sun does not allow anyone to publish a complete solution to a real assignment.
You agreed to that when you purchased the assignment.

Books at this level are NOT designed to provide you complete working solutions in easily digestible chunks, they're designed to provide you enough hints and information to figure out what to do on your own.
You're in the big league now, out of the sort of education that's provided in highschool classrooms.

Remember that the code in the book are just fragments of code under development.
The code you can download is an evolved version of that, of course it will have differences.


42
Mohammad Yacin
Greenhorn

Joined: May 27, 2006
Posts: 5
Thanks Jeroen!

That is fair.
However, I would have appreciated if there was a disclaimer in the book and code. If there is one, I must�ve missed it.

Regards.
Jeroen T Wenting
Ranch Hand

Joined: Apr 21, 2006
Posts: 1847
Most readers would expect what you encounter, and authors expect readers to expect it.
Robert McDonald
Greenhorn

Joined: Apr 20, 2006
Posts: 17
Jeroen,

I disagree when you say "Most readers would expect what you encounter" as I don't believe that when someone buys a technical book (at whatever level) that they automatically expect there to be 'mistakes' in it (or the accompanying code). Of course, sometimes mistakes happen no matter how closely books are proofed but the authors should really ensure that the errata are kept current to avoid any confusion.

Don't misunderstand - i am not having a go as i think the book is very useful (clarifies certain topics and shows another coders approach). The problem i find is that sometimes you can end up wasting time struggling to understand how a piece of code works only to discover that there is a mistake in it and this can be frustrating.

Mohammad points out about the static modifier being absent and as i understand it this is crucial to the thread safety of the application. If there are multiple RAF's and the code synchronises on each individual instance of the RAF then this looks to me like it would not be threadsafe. It is critical that if a piece of code is used to illustrate a point (multithreading), that it does so correctly otherwise it just muddies the waters.

Robert


Robert
Jeroen T Wenting
Ranch Hand

Joined: Apr 21, 2006
Posts: 1847
I wasn't talking about mistakes, I was talking about incomplete samples that don't form a cut and paste recipe for the reader to use as the solution to his own problems but rather are designed to guide his thinking in the right direction.
Andrew Monkhouse
author and jackaroo
Marshal Commander

Joined: Mar 28, 2003
Posts: 11404
    
  81

Hi Mohammad,

I'm sorry you are not happy with the book.
The source code on publisher website says something and the book says something else
This is to be expected. It is extremely rare for anything to be published without mistakes, and for most books there is an errata page listing the problems. Ours is no exception, and you will find that where mistakes are noted they are included in our published errata page and also included in the README.txt file included in the downloads plus in the source code itself where appropriate. We add to the errata page whenever items are brought to our attention, and now that you have identified some more issues, they will be added as well.
I searched the forum and it seems the authors (most of the time) never address the serious issues of threading, etc.
"threading, etc." covers the entire assignment, so that is a big amount you are suggesting not being covered. The reality is somewhat different - I try not to interfere if there is a discussion already in place, so if somebody has already answered a question I try to avoid just repeating the answer. Otherwise I will answer almost any question - the ones I do tend to avoid is when someone posts 200 lines of GUI code and asks why it is not working. If you look back at my 5000+ posts you will see that I have not avoided threading, or any other topic.
However, I would have appreciated if there was a disclaimer in the book and code. If there is one, I must’ve missed it.
There are several disclaimers in the book, both describing how we have deviated from the real assignment (and why), and describing how the downloaded code may differ from the published code.
Of course, sometimes mistakes happen no matter how closely books are proofed but the authors should really ensure that the errata are kept current to avoid any confusion.
We do try to keep the errata current, and as a result of the posts in this last week I will be updating the errata during the comming week.
How come the database is not defined as static in the DvdFileAccess class of Denny's DVD sample project???

It is defined as
private RandomccessFile database = null;

However, it shoudl be static, otherwise the file will be accessed by multiple handles.
Because the DvdFileAccess class is only used by the DvdDatabase class, and is defined as a static member of that class.

Regards, Andrew


The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: DvdFileAccess
 
Similar Threads
Regarding Monkhouse's SCJD book
DvdDatabase synchronization issue
SCJD Exam Book: Why is 'database' Static?
A Question In The Monkhouse Book
Questions about DvdFileAccess (code from the book)