Jeff Haynes

+ Follow
since Nov 09, 2004
Cows and Likes
Total received
In last 30 days
Total given
Total received
Received in last 30 days
Total given
Given in last 30 days
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Jeff Haynes

The reason why I ask this, is because on page 424 of the book there is a nice little diagram that shows what I thought was the same scenario.





Then you have this..




Maybe I am assuming to much here..

All thoughts are welcome!!

Okay tell me if I am wrong..

It is a 1-1 relationship between Foo and Bar


It is a 1-1 relationship between Bar and Foo

Given the information


And when you assign F2.setbar(f1.getBar())

Then this makes some sense as


Then shouldn't B2->Null be true too? Or is this answer wrong because you can't assume this?
I am a little confused on the answer to the following question from this book.

Given the container-managed unidirectional relationship:

Foo (0-1) -> Bar (0-1)

And the object relations:


What will be true after the following code runs?


a.) f1.getBar() == null
b.) b2.getFoo() == null
c.) b1.getBar() == null
e.) none of the above

Here is my thought process:

I understand this to mean..

Foo (0-1) -> Bar (0-1)

For Foo, it can have zero or 1 bar.
For each Bar, it can have zero or 1 foos.

AKA here is my table structure.

Foo PK, Foo Num, Bar PK (can be null)

Bar Table
Bar PK, Bar Num, Foo PK (can be null)

I understand this to mean..


F1 has a bar(called 1)
F2 has a bar(called 2)

So if this code is called

You will have

F1 has a bar(called 1)
F2 has a bar(called 1)

What I am missing is where does it say that each bar has a foo?

The answer by the way is A

I think I just don't understand the syntax of the question. Any ideas on how I should read this?
Again I am glad you passed!! The more the Certified Developers community grows the better. I can safely say for some unexplained reason I checked within my code if the record had been deleted before I read on this site that was a major cause of the 44/80 locking mark. It must of been a passing moment of brilliance on my part! Though after writting that code, then reading comments on this site, a bit of doubt raced through my head and I was forced to recheck what I had written.
14 years ago
I am glad you passed!! Congratulations!!

One question on your locking approach though.

When in the locking method, after you have waited for a notification that you may obtain the lock on the object, did you check to see if the record that your trying to obtain the lock on has been deleted?
14 years ago
And for the instance where they choose FileHandler I force them to choose a location for the log file.


I allow them to specify the level of logging, and the type of logging (FileHandler,ConsoleHandler) on the setup dialog.


Here is what I do in the scenario you mentioned.

User A performs a search that retuns room Z and shows it as bookable
User B performs the same search
User A books room Z
User B attempts to book room Z

Basically what I do is inform the user(B) that the record has already been booked, and it is no longer bookable, and I perform the same search they have already done. This displays all records matching the criteria, including the one they were just trying to book with all customer values associated to the given records. I am basically making the assumption that the user won't be 'freaked out' by the change in data.. but will understand that there could potentially be many users working on the system at the same time thus causing the scenerio you mentioned.

Here is my take on caching.

You may decide to NOT cache the database file. Which means every time you want to return a result set, or update a record in the database file, you must then access the file.

Which in the real world is not applicable because of a likely performance degradation, due to the potential number of times one would have to re-read the file. However no where in the assignment does it say that Performance is something you MUST consider when designing your approach.

Though I would suggest that if you take this approach make it clear in your choices.txt file, and reference your reasons for doing so.

The second option is a bit more real world in that you do implement cacheing. IMHO this is a bit more complicated but not so much that you would risk failing the assignment due to an overwhelming amount of extra code that could lead to errors.

I have chosen the second approach and have documented why in my choices.txt file. I take the approach of maintaining a date-time for the last time the data file was updated. I keep this date in my Data class as a private member variable, and update it on initial read as well as every time I write to the file. In my case I write to the file every time an update occurs to any record. When a read action occurs, say a search, I check to see if the date on the file has changed, and if it has, rebuild my internal data array.

I don't worry so much about File Access Collision because as the directions say only one app will be accessing the file at any given time.

Hope that helps.

IMHO - if the directions say that the data is in a particular format(DataInputStream,DataOutputStream) then you aren't necessarily required to use these Classes. You simply need to make sure that when you write the data out to the file its in the same format.

In the URLyBird assignment the DBAccess interface has a method deleteRecord in which the comments describe it as deleting the record, and making the record number and associated disk storage available for reuse.

Which seems to imply that deleted records are never written back to the database file?

However the database file is defined to specify a deleted flag.

Thinking over this, what it seems to imply is that when a record is deleted, this doesn't actually remove the record from whatever structure you have loaded your records into but sets a delete flag. Then when a new record is added to the database, it is placed into the first deleted records space that is returned from your structure.

Is this how these directions are understood by most?