aspose file tools*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Reading database file assumption? 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 "Reading database file assumption?" Watch "Reading database file assumption?" New topic
Author

Reading database file assumption?

Mark O' Sullivan
Ranch Hand

Joined: Aug 17, 2009
Posts: 160
Hi,
Just wondering is it possible not to read all values in database file, e.g. magicCookie, record length, etc. and just assume an offset into the actual file content since we know the schema and the actual file format or does 1 have to implement and return all file content and headers in file? Or would 1 automatically fail if didn't implement this?
Thanks.
Roel De Nijs
Bartender

Joined: Jul 19, 2004
Posts: 5278
    
  13

Hi Mark,

You could hard-code the position where the records section starts (and maybe document this decision). Because the assignment has no must requirement about having to read the database schema, you certainly won't fail taking such an approach. Maybe you will lose some points, because this approach is not really flexible for future changes (like columns getting bigger, smaller, being added, removed,...)

Kind regards,
Roel


SCJA, SCJP (1.4 | 5.0 | 6.0), SCJD
http://www.javaroe.be/
Roberto Perillo
Bartender

Joined: Dec 28, 2007
Posts: 2265
    
    3

Howdy, Mark!

Also, some people choose not to read the magic cookie value and just assume that the file provided to the application is a valid one. This is really your choice; just remember to document it!


Cheers, Bob "John Lennon" Perillo
SCJP, SCWCD, SCJD, SCBCD - Daileon: A Tool for Enabling Domain Annotations
Jason Moors
Ranch Hand

Joined: Dec 04, 2001
Posts: 188
Hi Mark,

I agree with the Roberto and Roel, I don't think your approach would automatically fail but I'd be surprised if you didn't lose some marks, as I'm not sure how you could justify not checking the magic cookie, it's there to check you are opening file in the correct format, i.e. what would happen if didn't check the magic cookie and tried to open a Word document for example.

I definitely agree with keeping it simple, but not to the extent where I cannot reasonably justify implementing functionality.

Regards,
Jason
Gert-Jan den Besten
Ranch Hand

Joined: May 02, 2008
Posts: 56

Hi Mark,

In my assignment I hard-coded the starting position of the records section. But I did check the magic cookie.
No points were deducted.

SCJP 5; SCJD; SCWCD 5.
Mark O' Sullivan
Ranch Hand

Joined: Aug 17, 2009
Posts: 160
Cheers, thanks to everyone for all their kind help.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Reading database file assumption?