• 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
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

What do you think on these two things?

 
Ranch Hand
Posts: 156
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
One : About book sequence
I'v looked someone use book sequence like this:
lock -- read -- update -- unlock.
But in my design, I don't need to use read method, I use 3 tier design and use a business method book to do this. The book sequence is : when the use enter one cusId and press "book" button, my view class can construct a Record object and pass it to the model class, the model class then get the informations of this record instance and call business method book() to finish this sequence. So my sequence is :
lock -- update -- unlock.
I don't need to read, because the record is construct in client. Whether I miss something here ?
Two : About find method of Data
On the find() method of DBMain that sun support interface, the statement like this:

A non-null value in criteria[n] matches any field
// value that begins with criteria[n]. (For example, "Fred"
// matches "Fred" or "Freddy".)


So I think this method's search mechanism is case-sensitive. Because the statement is "Fred" matches "Fred" or "Freddy, not "Fred" matches "Fred" or "Freddy or "freddy". In my design, search mechanism is case-insensitive defaultly, this means that this find method isn't fit me. So I create another method findByCondition() method and use it in my application. I implements find() method but don't use it at all. Whether this break SUN's requirements? And what do you think and solution on this?
Pls comments, thanx?
 
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 Leo,


One : About book sequence
I'v looked someone use book sequence like this:
lock -- read -- update -- unlock.
But in my design, I don't need to use read method, I use 3 tier design and use a business method book to do this. The book sequence is : when the use enter one cusId and press "book" button, my view class can construct a Record object and pass it to the model class, the model class then get the informations of this record instance and call business method book() to finish this sequence. So my sequence is :
lock -- update -- unlock.
I don't need to read, because the record is construct in client. Whether I miss something here ?


I do the same thing as yours. I constructs the record in the controller class, and then pass the "record" to the server for processing.
I guess this sequence is ok, as no marks have been deducted in this area.


Two : About find method of Data
On the find() method of DBMain that sun support interface, the statement like this:

So I think this method's search mechanism is case-sensitive. Because the statement is "Fred" matches "Fred" or "Freddy, not "Fred" matches "Fred" or "Freddy or "freddy". In my design, search mechanism is case-insensitive defaultly, this means that this find method isn't fit me. So I create another method findByCondition() method and use it in my application. I implements find() method but don't use it at all. Whether this break SUN's requirements? And what do you think and solution on this?


I do the same thing as well. In fact, what the search method from SUN's function is to compare two strings with "startsWith()". I have implemented another function, namely "find(int mode, String criteria[])" to capture whether the mode is exact match or similar match as the search string[] "criteria".
I guess this should be no problem as well.
Nick.
 
Bartender
Posts: 1872
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Leo,
I don't understand why the fact that your business layer is server-side (OK), let's you think that no read is necessary in book(). The purpose of that additional read() (and the test that follows it but that you don't show) is to ensure that the record to be updated was not changed (in any way) by another client since it was read by this client.
Regards,
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
Hi Phil,
My checking is based on whether the record is being booked, by checking whether the field "owner_id" contains anything.
The server gets a lock for record X. Before any updates, the system checks whether the owner id with the record X is empty string or not. If it is empty string, then the system updates it. Otherwise, the system throws a RecordAlreadyReservedException to the client.
Since the only field that can be updated is owner id, thus, I think the data string can be composd in the client side, as it is the only difference of the data, and there is NO unbook function.
Does this make sense?
Nick.
 
Ranch Hand
Posts: 319
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


Since the only field that can be updated is owner id, thus, I think the data string can be composd in the client side, as it is the only difference of the data, and there is NO unbook function.


But this doesn't allow for the future functionality of the system to be implemented. Remember you have create, update, and delete methods too that might come in to use in the future.
So, let's say you don't do another read (because only the owner field is changing), and your record gets deleted right before you update/book it. What then?
The extra read is to make sure you have the latest valid info in the record.
(Hope I'm making sense. I just scanned through quickly and jumped in).
J
 
Philippe Maquet
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,

My checking is based on whether the record is being booked, by checking whether the field "owner_id" contains anything.
The server gets a lock for record X. Before any updates, the system checks whether the owner id with the record X is empty string or not. If it is empty string, then the system updates it. Otherwise, the system throws a RecordAlreadyReservedException to the client.
Since the only field that can be updated is owner id, thus, I think the data string can be composd in the client side, as it is the only difference of the data, and there is NO unbook function.
Does this make sense?


Yes, it does make sense, but only if the record is read again. But if you did, why not comparing *all* the fields instead of the owner one only, maybe through a standard helper method? I think it's the typical way of doing in systems which use optimistic locking. You're right that the owner field is currently the only one that can be changed, but checking that the whole record changed or not is an easier to maintain and safer solution.
Regards,
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
Hi Jacques,


But this doesn't allow for the future functionality of the system to be implemented. Remember you have create, update, and delete methods too that might come in to use in the future.


If those functions are potential used, of course, having an additional read is better. In fact, if we are doing the real system, the database will do that for us.


So, let's say you don't do another read (because only the owner field is changing), and your record gets deleted right before you update/book it. What then?


This case does not happen.
Before the system update the record, it will acquire a record lock, if the record is deleted before the system updates it, RecordNotFoundException will be encountered.


The extra read is to make sure you have the latest valid info in the record.


Yes, by assuming that there are other operations that the actors can perform. But in this case, since the only field can be updated in a record is "owner id", I simply make this assumption and documented it.
Of course, the more we did, the system will be more robust.
Nick.
 
Leo Tien
Ranch Hand
Posts: 156
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Philippe,Nicholas,Nicholas:
Thanx for your reply.
After read your comments, I think before update I will do three validation:
1. Whether this record is valid ? -- this have be done in lock method.
2. Whether this record is booked ? -- this check is similar with Nicholas. But it will raise three questions.
2.1 Whether should we show booked record to client ? From the statement above, we all show it, because it seems we all do booked check. If we don't show booked record to client, we don't need do this check, exactly ?
2.2 Whether should we show owner field to client ? From the satement above, we all don't show it, because if we show it, the client will see it whether is empty, so our program don't need check it, exactly ?
2.3 Whether should booked record can be booked again ? I'v seen someone allowed this, which option is better, pls comment.
3. Check whether the whole fields are equally ? Such as name, location and so on. In other words, this check whether this record has been modified.
The 2 and 3 check must use read method, so I decide use this sequence: lock -- read -- update -- unlock
[ March 01, 2004: Message edited by: Leo Tien ]
 
Leo Tien
Ranch Hand
Posts: 156
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Philippe:
What do you think on my find method design ?
 
Philippe Maquet
Bartender
Posts: 1872
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Leo,
Sorry, but I couldn't connect yesteday night and I'm going to work now. Hope it will be better tonight.

Regards,
Phil.
[ March 02, 2004: Message edited by: Philippe Maquet ]
 
Philippe Maquet
Bartender
Posts: 1872
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Leo,

Two : About find method of Data
On the find() method of DBMain that sun support interface, the statement like this:
quote:A non-null value in criteria[n] matches any field
// value that begins with criteria[n]. (For example, "Fred"
// matches "Fred" or "Freddy".)

So I think this method's search mechanism is case-sensitive. Because the statement is "Fred" matches "Fred" or "Freddy, not "Fred" matches "Fred" or "Freddy or "freddy". In my design, search mechanism is case-insensitive defaultly, this means that this find method isn't fit me. So I create another method findByCondition() method and use it in my application. I implements find() method but don't use it at all. Whether this break SUN's requirements? And what do you think and solution on this?
Pls comments, thanx?


I am unsure to understand why you'd need some case-insensitive find method. Now the fact that you develop an additional find() method is not bad per se. So the question is: do you really need it?
Regards,
Phil.
 
Leo Tien
Ranch Hand
Posts: 156
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Philippe:
Because I want to supply a Flexible search mechanism, like my assignment said -- "A data access system that provides record locking and a flexible search mechanism"; So I support case-insensitive search and use it in default.
In GUI, I support a checkbox named "case-sensitive" like Ken's solution.

Make sense?
 
Ranch Hand
Posts: 697
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Leo Tien:
Hi Philippe:
Because I want to supply a Flexible search mechanism, like my assignment said -- "A data access system that provides record locking and a flexible search mechanism"; So I support case-insensitive search and use it in default.
In GUI, I support a checkbox named "case-sensitive" like Ken's solution.

Make sense?


Hi Leo, I think find mechanism on following grounds.
1-> Find exact matches. Ex: "Fred" matches "Fred". Do not match "Freddy",
"Fredo", "fred", "freddy".(This is the "User Interface" requirement)
2-> Other search is as this. Ex: "Fred" matches "Freddy", "Fredo", "Fred",
"fred", "fredo". Do not match "free", "freeze" like that.(This is the
additional function we are providing, right?)
As you can see above, 1 is the "exact" match. But the second match does'nt only "ignore case", but it also tries to find records with "startsWith" mathes. So by giving a check-box with just case-sensitive, how can you co-relate with above 2 matching operations?
As you can see, the find() method given in interface do not suffice for both both the requirements.
And is the check-box case-sensitive is unchecked condition same as 2 above?
Please comment. Thanks.
 
Leo Tien
Ranch Hand
Posts: 156
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Satish:
Thank you reply.

1-> Find exact matches. Ex: "Fred" matches "Fred". Do not match "Freddy",
"Fredo", "fred", "freddy".(This is the "User Interface" requirement)


Very exactly.

2-> Other search is as this. Ex: "Fred" matches "Freddy", "Fredo", "Fred",
"fred", "fredo". Do not match "free", "freeze" like that.(This is the
additional function we are providing, right?)


Exactly too, but I don't support "Fred" match "free", "freeze" at all, even never think of it.
I'm sorry I didn't say my solution detailly, in my design, I use two check box to support additional search mechanism: one is "Exact" and the other is "case-sensitive".
So my solution is :
1. By default, "Fred" will match "Fred", "Freddy", "freddy" and so on. This is base on "flexible search" and "start with" statement in the assignment.
2. When the use select "Exact" check box only, "Fred" will match "Fred" and "fred" only.
3. When the use select "Case-sensitive" check box only, "Fread" will match "Fred", "Freddy" ....
4. When 2 and 3, "Fred" only match "Fred", this is equals "exact match" in assignment.
I don't know whether this solution have some problem. Pls comments.
Thanx.
 
Satish Avadhanam
Ranch Hand
Posts: 697
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Leo Tien:
Hi Satish:
Thank you reply.
So my solution is :
1. By default, "Fred" will match "Fred", "Freddy", "freddy" and so on. This is base on "flexible search" and "start with" statement in the assignment.

Sounds good to me and as a matter of fact I am doing the same.

2. When the use select "Exact" check box only, "Fred" will match "Fred" and "fred" only.

If you can document that "Exact" is case-insensitive, then I think it should be fine. Because, when we say "Exact", its "Exact", that's what I think. Here my implementation would be "Fred" only matches with "Fred", but not "fred".

3. When the use select "Case-sensitive" check box only, "Fread" will match "Fred", "Freddy" ....
4. When 2 and 3, "Fred" only match "Fred", this is equals "exact match" in assignment.

This is OK.

I don't know whether this solution have some problem. Pls comments.
Thanx.
The solution as I said, looks perfect


Hi Leo, I would like to implement only the following two as I said before.
1. Exact(check-box): "Fred" matchs with ONLY "Fred", that's it.
2. If user de-selects it then: "Fred" matches "fred", "freddy", "Fredo".
I am not considering case-sensitive as a seperate one. I will consider either exact or not. I will document it accordingly.
The main point that we should remember is -- The way we intrepret the logic and implemented it should be very well documented so that the grader will look through our eyes. Or else his way of intrepretation of things might be different, you know.
The main difference between your implementation and mine is that am providing only one check-box "Exact" and you are providing two "Exact" and "Case-sensitive". And in your solution if you select both check-boxes, the result obtained is similar to the one if the check-box is selected in mine. You are providing additional search mechanisms, which is good. But I want to stick with what I implemented.
Hope this helps.
 
Leo Tien
Ranch Hand
Posts: 156
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Satish:
May be you are right.

2. If user de-selects it then: "Fred" matches "fred", "freddy", "Fredo".


My question is which find() did you use ? The find() that given by sun or your owns like my design.
If you use suns, do you believe that method should support case-insensitive?
Because the statement on it like this:

For example, "Fred" matches "Fred" or "Freddy".)


I think this method is case-sensitive, what do you think??
Thanx.
 
Philippe Maquet
Bartender
Posts: 1872
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Leo,
I believe that by "flexible" SUN means what they describe and nothing more.
At the client level, the records found *must* match *exactly*, and I think it's clear enough. So why both your checkboxes ?
Especially if you use comboboxes to present possible field values to the user. In case there is a "fRed" and a "Fred" in the databases, they would appear as separate entries in the combos anyway, right? But maybe you don't use comboboxes...
Regards,
Phil.
 
Leo Tien
Ranch Hand
Posts: 156
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Philippe:
I use combo box too.
I think you are right. But in Ken's design, he use combo box and support these two checkbox too, what you think about his design??

Especially if you use comboboxes to present possible field values to the user. In case there is a "fRed" and a "Fred" in the databases, they would appear as separate entries in the combos anyway, right? But maybe you don't use comboboxes...


If there's "fRed", "Fred", "fReddy" and "Freddy" in the databases, then when the user select "Fred", in flexible mode, which of these record will be shown??
Pls comments, thanx and waiting...
 
Satish Avadhanam
Ranch Hand
Posts: 697
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Leo

Originally posted by Leo Tien:
Hi Satish:
May be you are right.

My question is which find() did you use ? The find() that given by sun or your owns like my design.

I used a different method than Sun's. But I implemented it.

If you use suns, do you believe that method should support case-insensitive?

No. They exclusively specified "Fred" matches with "Fred", "Freddy". We cannot assume case insensitive there. More over I have only one find method which performs all sort of search depending on the condition.

Because the statement on it like this:

I think this method is case-sensitive, what do you think??

Its Case-sensitive that's what I think. Fred does'nt match fred there.

Thanx.


Hope this helps.
 
Satish Avadhanam
Ranch Hand
Posts: 697
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Leo,

Originally posted by Leo Tien:
Hi Philippe:
If there's "fRed", "Fred", "fReddy" and "Freddy" in the databases, then when the user select "Fred", in flexible mode, which of these record will be shown??
Pls comments, thanx and waiting...


If you ask me, I would say "all" the four here
 
Leo Tien
Ranch Hand
Posts: 156
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Satish:
Our find() method design is very similar, thanx your reply.
 
Leo Tien
Ranch Hand
Posts: 156
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Philippe:
Now my book method is like this:

Pls comments.
I don't use any synch in this method because I use lock mechanism, it's right ? Whether I should write this sequence(if someone want use update() API, he must use this sequence) in my choise document??
Waiting your help,
[ March 03, 2004: Message edited by: Leo Tien ]
 
Satish Avadhanam
Ranch Hand
Posts: 697
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Leo,

Originally posted by Leo Tien:
Hi Philippe:
Now my book method is like this:


It seems that you are hiding the class variable data(of type Data) with local variable data(of type String[]). I was confused at first of how you are comparing String object with that of Data(I assumed at first that data is only Data type) in the for loop. As I was reading "Code Conventions", I came through a line "Avoid local declarations that hide declarations at higher levels". Its just for your information as there is potential for confusion here. You may stick with what you have already done.

Pls comments.
I don't use any synch in this method because I use lock mechanism, it's right ? Whether I should write this sequence(if someone want use update() API, he must use this sequence) in my choise document??
Waiting your help,
[ March 03, 2004: Message edited by: Leo Tien ]

 
Philippe Maquet
Bartender
Posts: 1872
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Leo,


Originally posted by Leo Tien:
Hi Philippe:
Now my book method is like this:
code:

this.data.lock(recNo);
String[] readRecord = this.data.read(recNo);
if ( !readRecord[readRecord.length].equals("") ) {
throw new RecordNotFoundException("This record is booked already !");
}
for ( int i = 0; i < readRecord.length - 1; i++ ) {
if ( !readRecord[i].equals(data[i]) ) {
throw new RecordNotFoundException("This record is modified already !");
}
}
this.data.update(recNo, data);
this.data.unlock(recNo);
Pls comments.
I don't use any synch in this method because I use lock mechanism, it's right ? Whether I should write this sequence(if someone want use update() API, he must use this sequence) in my choise document??
Waiting your help,


Same comment as Satish, plus these:
  • As you couldn't reasonably book a modified record (even in the case owner is still blank), I wouldn't perform the first test.
  • Even if you keep it, I wouldn't bet as you do that the owner field will stay the last one in the record, forever.
  • RecordNotFoundException is an exception declared in the db package for very specific uses in the db context. Is it a good idea to reuse it in the business layer?


  • I don't use any synch in this method because I use lock mechanism, it's right ?


    I don't see any reason to synnchronize that method, provided that your Data implementation is threadsafe.
    Regards,
    Phil.
     
    Leo Tien
    Ranch Hand
    Posts: 156
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Hi Satish:

    It seems that you are hiding the class variable data(of type Data) with local variable data(of type String[]). I was confused at first of how you are comparing String object with that of Data(I assumed at first that data is only Data type) in the for loop. As I was reading "Code Conventions", I came through a line "Avoid local declarations that hide declarations at higher levels". Its just for your information as there is potential for confusion here. You may stick with what you have already done.


    Yes, you are right, I have class variable data and local variable data that is passed as book() method parameter. I will change this, thanx for your comments.
    Hi Philippe:

    1. As you couldn't reasonably book a modified record (even in the case owner is still blank), I wouldn't perform the first test.


    Whether you said that one record could be booked again? If I don't check it, when the record have been booked and the owner field haven't been empty, then you can book it again. Am I right, pls comments?

    2. Even if you keep it, I wouldn't bet as you do that the owner field will stay the last one in the record, forever.


    Yes, I will get owner field index in the string array first in my real code, but it must know the owner field name, is this way right ?

    3. RecordNotFoundException is an exception declared in the db package for very specific uses in the db context. Is it a good idea to reuse it in the business layer?


    Yes, Yes . I'm sorry first, because I don't say the code above is only my test code. In real code, I will construct RecordHaveBookedException in 1 and RecordHaveModifiedException in 2.
    Pls comments. Thanx.
     
    Satish Avadhanam
    Ranch Hand
    Posts: 697
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Hey Leo,
    I think you are checking if the record that the user sees is same as the record in the database. If not you are throwing an exception.
    For this, you need to keep the complete database in a static varible and whenever any thread modifies the database, you need to change the static varible accordingly right. So, for each update/delete/create/book operations you must change the static varibale. Is that how you are doing?
    Its just like having the whole db as a cache, is'nt it?
    Thanks.
     
    Leo Tien
    Ranch Hand
    Posts: 156
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Hi Satish:
    Thanx for your reply.
    I don't do any db cache in my design. I think it will let us to do much more works. In my design, every user can use "search" mechanism to get the newest record information of the db. But when these information is display on the client, I don't ensure that these information is same as in the db file. So when the user want to book one record, I must check whether this record is valid, in other words, perhaps the records that user have seen have been deleted or modified.
    I don't know whether this design miss some requirement of the assignment, but I really don't see any statemnt on the assignment to must do synch(db cache) on the db.
    Pls comments. Thanx.
     
    Satish Avadhanam
    Ranch Hand
    Posts: 697
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Hi Leo, I misunderstood it at first. You are right.

    Originally posted by Leo Tien:
    Hi Satish:
    Thanx for your reply.
    I don't do any db cache in my design. I think it will let us to do much more works. In my design, every user can use "search" mechanism to get the newest record information of the db. But when these information is display on the client, I don't ensure that these information is same as in the db file. So when the user want to book one record, I must check whether this record is valid, in other words, perhaps the records that user have seen have been deleted or modified.
    I don't know whether this design miss some requirement of the assignment, but I really don't see any statemnt on the assignment to must do synch(db cache) on the db.
    Pls comments. Thanx.


    This is exactly what am doing, too. It seems we both are on the same page. GoodLuck
     
    Philippe Maquet
    Bartender
    Posts: 1872
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Hi Leo,


    Hi Philippe:
    quote: 1. As you couldn't reasonably book a modified record (even in the case owner is still blank), I wouldn't perform the first test.
    Whether you said that one record could be booked again? If I don't check it, when the record have been booked and the owner field haven't been empty, then you can book it again. Am I right, pls comments?


    In my opinion, the user shouldn't even have the opportunity at the GUI level to book a already booked room. That's why I think it's enough to just check that the record didn't change between the time the user got it (as a result of a search for instance) and the time he tries to book it.

    Yes, I will get owner field index in the string array first in my real code, but it must know the owner field name, is this way right ?


    Either by using numeric constants mapped to the field indexes, or by name, but for sure not "the last field" as you did above (IMO)

    Yes, Yes . I'm sorry first, because I don't say the code above is only my test code. In real code, I will construct RecordHaveBookedException in 1 and RecordHaveModifiedException in 2.


    Much better!
    Best regards,
    Phil.
     
    Leo Tien
    Ranch Hand
    Posts: 156
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Hi Philippe:

    In my opinion, the user shouldn't even have the opportunity at the GUI level to book a already booked room. That's why I think it's enough to just check that the record didn't change between the time the user got it (as a result of a search for instance) and the time he tries to book it.


    Whether you mean that you never show the booked record to the user??
    If this, I have a confuse here. Let's look this condition: when two client want to book one record at the same time, they want to lock the record at first, but client 1 get it and lock it and client 2 must wait. Then client 1 do read, book and unlock at last, now client 2 get the record lock and out waiting pool and do read, book and unlock too. I think if you don't check whether this record is booked, in other words the owner field is empty, then client 2 will cover client 1.
    Right?? Pls comments,
    Thanx.
     
    Philippe Maquet
    Bartender
    Posts: 1872
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Hi Leo,

    If this, I have a confuse here. Let's look this condition: when two client want to book one record at the same time, they want to lock the record at first, but client 1 get it and lock it and client 2 must wait. Then client 1 do read, book and unlock at last, now client 2 get the record lock and out waiting pool and do read, book and unlock too. I think if you don't check whether this record is booked, in other words the owner field is empty, then client 2 will cover client 1.


    If client 1 booked the record, than the record changed, right?
    Regards,
    Phil.
     
    Leo Tien
    Ranch Hand
    Posts: 156
    • Mark post as helpful
    • send pies
      Number of slices to send:
      Optional 'thank-you' note:
    • Quote
    • Report post to moderator
    Hi Philippe:

    Yes, Yes, in fact, I separate your check into two steps, like above. Now I will change it to one, thank you Philippe, thank you.
     
    reply
      Bookmark Topic Watch Topic
    • New Topic