Help coderanch get a
new server
by contributing to the fundraiser
  • 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Devaka Cooray
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Tim Moores
  • Carey Brown
  • Mikalai Zaikin
Bartenders:
  • Lou Hamers
  • Piet Souris
  • Frits Walraven

NX: Questions about URLyBird 1.3.2

 
Ranch Hand
Posts: 4982
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have just downloaded the assignment, and I would like ask some silly questions.
1. In the Server part, the question paper provides us a MUST implement interface DBMain, can I edit it? What I mean is, for example, change the // comment to javadoc comments, add the necessary packages, like Regular expression to the interface, etc. Of course, the original methods and their arguments will be kept as it is.
2. There are 3 operating modes: server, alone, and "blank".
Does this mean:
A. We use "server" to start the server, nothing else.
B. We use "alone" to start local mode (The client GUI pops up and all writes to local file systems)
C. We use "blank" to start the client, and connected to the "previously" started server, or return an error if the server not start?
Thanks.
 
Bartender
Posts: 1872
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Nicholas,

1. In the Server part, the question paper provides us a MUST implement interface DBMain, can I edit it? What I mean is, for example, change the // comment to javadoc comments, add the necessary packages, like Regular expression to the interface, etc. Of course, the original methods and their arguments will be kept as it is.


It's OK for javadoc comments (probably even an indirect "must"), but what do you mean with "add the necessary packages, like Regular expression to the interface" ? I wouldn't touch DBMain except for its doc.

2. ...


All you wrote in 2. is correct.
Best,
Phil.
 
Nicholas Cheung
Ranch Hand
Posts: 4982
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have tried to decode the data file, and I get this:

According to my data format, the data are shown as above.
However, I am a bit wonder, according to my specification, it said:


2 byte flag. 00 implies valid record, 0x8000 implies deleted record


1. Should I change the empty bytes to "00", when my application first load?
2. Does all records (total no. of Hotels) fixed?
3. Since the user can book a selected recorded, so how if, the record is already be booked? Simply reply room is not available?
4. If 3 is the case, then are there any "add" function in fact? Seems to me that there is only update function, when a booking of the hotel is cancelled.
Here is the illustration for Q3, and Q4:
Say, for the 1st time, no one book the hotel "Excelsior", and I booked it, then, the owner will then changed from null to "Nicholas"? How about, if another person, Mike, booked the same hotel? If is case 3, then Mike cant booked that hotel. If NOT, then we have:
name: Excelsior
.....
owner: Nicholas
.....
name: Excelsior
.....
owner: Mike
Which one should be the case?
Thanks for answering my silly Qs again.
 
Ranch Hand
Posts: 555
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Nicholas,

1. Should I change the empty bytes to "00", when my application first load?


It seeems that you read the flag as a plain text. It not correct. It must be read as bytes, not characters.


2. Does all records (total no. of Hotels) fixed?


No, it is not fixed

3. Since the user can book a selected recorded, so how if, the record is already be booked? Simply reply room is not available?


Sounds reasonable, but not for update method, but for client or middle-tier
method book(), which uses update().

4. If 3 is the case, then are there any "add" function in fact? Seems to me that there is only update function, when a booking of the hotel is cancelled.


I don't know how your interfaces looks like, but my interface has method create() to add a hotel room.
Best,
Vlad
 
Nicholas Cheung
Ranch Hand
Posts: 4982
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Vlad,
Thanks for clarifying a bit, but I would like to further ask:

1. The beginning of the data file contains, say, 10 records with owner field null. If a customer book a room, would you add 1 more record, i.e. 11 in total, with 10 of them have null owner, while the new one has owner "Nicholas"? OR you will find the corresponding record and update the owner field?
2. Since the function read(int rec_id) requires a record id, do we store it into the data file? OR we just count it in this way:

And the record ID in fact is the "location" of the record in the Vector?
3. For data object, does it read the data from data file every time? OR it reads all records into the memery and access it via memory every time?
Thanks a lot.
 
Vlad Rabkin
Ranch Hand
Posts: 555
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Nicholas,

If a customer book a room, would you add 1 more record,


No. If a customer books a record, you set the owner field to the customer id. If the record field "owner" is set to a value, it is booked. You don't need (and may not!!!) any new record after that.
Let's take a sample: you book a record #17. Yout set its owner to #xxx. That is it.

2. Since the function read(int rec_id) requires a record id, do we store it into the data file? OR we just count it in this way:


You MAY not change format of the db file. So, there are two ways to do it:
- Cache database in a List. Record id is the record index in the List
- Don't cache db. Record id is the number of the record in the file.

3. For data object, does it read the data from data file every time? OR it reads all records into the memery and access it via memory every time?


It is your design choise whether to cache the database or not. You will neither penaltied for caching nor get additional marks. If you cache it, don't forget to document your choise.
Best,
Vlad
[ November 11, 2003: Message edited by: Vlad Rabkin ]
 
Nicholas Cheung
Ranch Hand
Posts: 4982
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


No. If a customer books a record, you set the owner field to the customer id. If the record field "owner" is set to a value, it is booked. You don't need (and may not!!!) any new record after that.
Let's take a sample: you book a record #17. Yout set its owner to #xxx. That is it.


I am a bit confused. If so, does this mean, for a customer "cancel" a booking, I just set the owner to null?
Then, what is the usage of create() and delete()?
From your previous message, you use create() to add new hotel, but, this seems do not a requirement.
In addtion, we have no way to use delete(), since we just use update to "play around" with the owner?
Thanks for your kindly help.
 
Vlad Rabkin
Ranch Hand
Posts: 555
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Nicholas,
You have to differ functionality requirement for the client and database.

...customer "cancel" a booking


Do you have such requirement? I don't think you are required to provide cancellation of the booking.
delete, create method are required to be implemeted. It is functionality requirement for the database. However, they are not required to be impleneted on the client.
Your client must provide, I suppose, two functiolities:
- search
- book
Search will probably use search() or/and read() method from the database.
Book will probably use lock/unlock/read/update methods to book the record.
You are right, to cancel a record a client would have to delete the content of the "owner" field by calling update() method. However, your client application is not required to do it.
I don't know your assignement, but I believe that an available room would have the owner value, containing blanks, not a null.
Best,
Vlad
[ November 11, 2003: Message edited by: Vlad Rabkin ]
 
Nicholas Cheung
Ranch Hand
Posts: 4982
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
That is to say, for the user, we just need to give them the function "book" and "search".
However, we need to implement all functions given according to the spec, even those will not be used by the user?
In addition, how should I handle a customer who wants to book a room that has been "booked"? Can I assume that the CSR will tell him that the room is booked, instead of checked by the GUI/system?
Thousand thanks
[ November 11, 2003: Message edited by: Nicholas Cheung ]
 
Vlad Rabkin
Ranch Hand
Posts: 555
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

That is to say, for the user, we just need to give them the function "book" and "search".


Correct.

However, we need to implement all functions given according to the spec, even those will not be used by the user?


Yes, but only on the server, not a client. All functionality required is in database interface. There is no any book or cancel method!!!
My understanding is that your database must implement the following methods:
read(), create(), update(), delete(), search(), lock(), unlock()
You client must implement search() and book().
It means that create()/delete() is implemented in database, but not used in client application at all. You don't need to provide functionality in GUI such as create new record or delete a record.
Best,
Vlad
 
Nicholas Cheung
Ranch Hand
Posts: 4982
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Many thanks Vlad.
I am very confuse at the very begining, but I understand it better now.
BTW, do you mind telling me that how many classes you have developed?
And, do u create a RecordAdpator class to encapsulate the String[]?
i.e. when, say, the function search being called, there maybe more than 1 record, and there is an RecordAdpator class that convert the String[] into Record? and use a Vector to store multiple records?
 
Vlad Rabkin
Ranch Hand
Posts: 555
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
hi Nicholas,

do you mind telling me that how many classes you have developed


No problem : 48. I am sure it does not matter. The point is clearity of the code, not the number of classes.


do u create a RecordAdpator class to encapsulate the String[]?


Good idea...
Best,
Vlad
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic