• 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 all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Workflow

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I got the urlybird 1.1.3 assignment is and I have some questions about the workflow and the data file.

First of all, I don't see something like a record id in the database, so I assume the record id is just a virtual unique id representing a specific record.
As far as I can see, the update and create method in the DB interface are never used. Do I have to fill the implementation with working code ?

When a request is made and the result of the query is displayed in a table, the user should be able to select a record and submit it using its customer id.
Do I have to delete the record then (mark it with 0xFF) or do I have to update the owner of the record, indicating that the room is booked ?

What if the room was already booked by another client inbetween ?
Do I have to display a message to the user, that his selection was already booked while he made his decision ?

Thanks for your help
 
Ranch Hand
Posts: 85
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


As far as I can see, the update and create method in the DB interface are never used. Do I have to fill the implementation with working code ?



I didn't fill the create and delete methods. Reading other people's posts on the list I feel most people do.


What if the room was already booked by another client inbetween ?
Do I have to display a message to the user, that his selection was already booked while he made his decision ?



There are several solutions to this problem. Pick one that you feel is best and defend it on your choices.txt.

Good luck!
Dies
 
Ranch Hand
Posts: 247
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
My understanding is the update is used. When a CSR assigns a customer number to the record it needs to update.

The create and delete don't ever seem to be used. I did however implement them as it says you must implement the DBMain interface and these methods are part of it.
 
Kris Reid
Ranch Hand
Posts: 247
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
One thing I don't understand is the DuplicateKeyException
When would this be thrown?

It is ownly used with create. Isn't the Key the record number? and the record number is just its position in the file. How could you have a Duplicate Key?
 
Ranch Hand
Posts: 1033
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The best solution is to update the record to book it for a customer. I implemented all the CRUD methods, since they are described in the interface and may be needed in a later version. They are also useful for testing that your code behaves properly under those conditions.

On the questions about keys and DuplicateKeyException, URLyBird doesn't have a primary key, since the room number isn't included in the record.

BTW, is your name really M. Groening? Did you write Live in Hell?
 
Kris Reid
Ranch Hand
Posts: 247
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is it exceptable to change the interface by declaring exceptions?

i.e.
This
public String [] read(int recNo) throws RecordNotFoundException;

to this
public String [] read(int recNo) throws RecordNotFoundException, RemoteException;
 
author and jackaroo
Posts: 12199
280
Mac IntelliJ IDE Firefox Browser Oracle C++ Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi M. Groening,

Welcome to JavaRanch and this forum.

We don't have many rules here, but one we do have is the Official policy on registered names, which states (in part) "No names of celebrities or fictional characters.".

Could you please review the official policy, and change your name accordingly. You can change your name here.

Thanks, Andrew
 
Linus Friedrich
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So, if a booking procedure is just a matter of update the record and set the given customer number, where is the lock and unlock method for ?
In this case it should be sufficient to "synchronize" the update method, isn't it.
Do I miss something ???



By the way: My apologize about my display name, I wasn't aware of that. I changed it now from M. Groening to Linus Friedrich.
 
peter wooster
Ranch Hand
Posts: 1033
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by Linus Friedrich:
So, if a booking procedure is just a matter of update the record and set the given customer number, where is the lock and unlock method for ?
In this case it should be sufficient to "synchronize" the update method, isn't it.
Do I miss something ???



Yes, the sequence {read, compare, update} must be available across the network. You can't get synchronization between multiple clients over the network. If you were using the "thin client" model you could synchronize that, but its a rather large block of code.
 
ranger
Posts: 17346
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by Linus Friedrich:
So, if a booking procedure is just a matter of update the record and set the given customer number, where is the lock and unlock method for ?
In this case it should be sufficient to "synchronize" the update method, isn't it.
Do I miss something ???



By the way: My apologize about my display name, I wasn't aware of that. I changed it now from M. Groening to Linus Friedrich.



So how was your last Bicycle race Linus?

Markus, just change it to your real name please.

Mark
 
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
--------------------------------------------------------
Is it exceptable to change the interface by declaring exceptions?

i.e.
This
public String [] read(int recNo) throws RecordNotFoundException;

to this
public String [] read(int recNo) throws RecordNotFoundException, RemoteException;
--------------------
I don't think this change is ok. So I write a new Interface for
client ,for RMI server.
For the DB class , I just implement it to Data class.
Maybe the request just want some olg system can access the new application through the interface,So you should not change this DB interface.

dennis
 
peter wooster
Ranch Hand
Posts: 1033
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by dennis du:
--------------------------------------------------------
Is it exceptable to change the interface by declaring exceptions?

i.e.
This
public String [] read(int recNo) throws RecordNotFoundException;

to this
public String [] read(int recNo) throws RecordNotFoundException, RemoteException;
--------------------
I don't think this change is ok. So I write a new Interface for
client ,for RMI server.
For the DB class , I just implement it to Data class.
Maybe the request just want some olg system can access the new application through the interface,So you should not change this DB interface.

dennis



It's not a good idea to add checked exceptions to the interface. There has been a lot of discussion of this on this forum. Do a search on Exception. The choices boil down to using a RuntimeException to wrap IOException or trying to shoehorn it into the declared exceptions. Throwing additional checked exceptions is sure to break any code that tries to use your Data class as a facade on your database.

I use a RuntimeException and the Adapter and Proxy patterns to get around this.
 
Getting married means "We're in love, so let's tell the police!" - and invite this tiny ad to the wedding:
Thread Boost feature
https://coderanch.com/t/674455/Thread-Boost-feature
    Bookmark Topic Watch Topic
  • New Topic