aspose file tools*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes NX: [URLyBird] Search result 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 "NX: [URLyBird] Search result" Watch "NX: [URLyBird] Search result" New topic
Author

NX: [URLyBird] Search result

Maksim Golubkow
Greenhorn

Joined: Jun 04, 2003
Posts: 22
In the "The User Interface" section there is following criteria to satisfy:
It must allow the user to search the data for all records, or for records where the name and/or location fields exactly match values specified by the user.

Does it mean i have to return also records that booked already or does not satisfy the 48 hours rule?
PS: Do You convert the fields values to appropriate types (for examlple smoking to boolean)? (Joshua says: Item 32 - Avoid strings where other types are more appropriate.)
Regards, Maksim
Mark Spritzler
ranger
Sheriff

Joined: Feb 05, 2001
Posts: 17250
    
    6

Yes you return all matching values, whether they are already booked or not.
Mark


Perfect World Programming, LLC - Two Laptop Bag - Tube Organizer
How to Ask Questions the Smart Way FAQ
Ta Ri Ki Sun
Ranch Hand

Joined: Mar 26, 2002
Posts: 442
PS: Do You convert the fields values to appropriate types (for examlple smoking to boolean)? (Joshua says: Item 32 - Avoid strings where other types are more appropriate.)

since I dont use that field for anything but display , and since true/false isn't really what a user wants to see, I instead display Yes/No, this came out from some of my user feedback, 2 of the 3 testers said they'd prefer to see that
Maksim Golubkow
Greenhorn

Joined: Jun 04, 2003
Posts: 22
Originally posted by Ta Ri Ki Sun:

since I dont use that field for anything but display , and since true/false isn't really what a user wants to see, I instead display Yes/No, this came out from some of my user feedback, 2 of the 3 testers said they'd prefer to see that

Hi TQ, in my case the user would see either checked or unchecked checkbox, but i could also implement it like you. Why i'm asking it? If I would implement the 48 hour rule, than I have to convert the date field to java.util.Date. So why not to do this on the server side and return to the user of my API (DBClient) records with fields of appropriate types?
Regards, Maksim
Rob Pearson
Greenhorn

Joined: Jun 12, 2003
Posts: 19
Yes you return all matching values, whether they are already booked or not

Hmmm... This wasn't what I was planning on doing.
The current requirement is only to be able to book rooms (ie no requirement to cancel a booking). I think its probably unreasonable for users to book a room that has already been sold, so I wasn't planning on displaying rooms that have already been booked. I therefore wasn't even planning on displaying the "owner" column in the table. I don't really see the point in displaying a room thats not available? What do others think?
Also, the requirement They take bookings only within 48 hours of the start of room occupancy. Are people generally ignoring issues with timezones? So if its now 12:30 pm on the 23rd (on the server?), should I only present rooms with dates on 23,24,25?
Cheers
Rob


Assignment: URLyBird 1.3.3, using Java 1.4.0_01<br />Status: Designing, Experimenting, Reading.
Andrew Monkhouse
author and jackaroo
Marshal Commander

Joined: Mar 28, 2003
Posts: 11424
    
  85

Hi Rob,
I think it is better to show all the rooms, whether they are available or not.
The alternative is if you come back with a blank screen, does that mean that there are no rooms available, or that the search criteria was wrong?
I think a travel agent would prefer to be able to say: "sorry there are no rooms on your requested dates, shall we try another date?" rather than "sorry, I cant find any hotels matching your request".
Some thoughts on the 48 hours can be found in this thread
Regards, Andrew


The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
Rob Pearson
Greenhorn

Joined: Jun 12, 2003
Posts: 19
G'Day Andrew,
Sorry, but I'm not sure if I agree.
1. In my assignment (URLyBird), they can only filter on Name/Location and not Date, so they will never be able to "try another date?".
2. If they enter a bad name they will get no results; if they enter a good name but there are no rooms available in the last 48 hours they will also get no results; so in this case there is no distinction between good and bad search criteria.
3. If they don't enter any search criteria, ie a "show all", then I don't see the point in showing unavailable rooms (possible waste of bandwidth/cpu/etc depending on volumes).
4. If I did show unavailable rooms, then I'd need to handle the case of the users selecting and attampting to re-book one of these.
Having said all that, I guess either way is probably OK as long as you document why you designed it a particular way. Since I'm still at the design stage (I assume you've finished?), I may completely change my mind once I have something up and running!
Cheers
Rob
Maksim Golubkow
Greenhorn

Joined: Jun 04, 2003
Posts: 22
Hi Rob,
I have had the same thoughts that in the real world application I would not return booked rooms. But this is not a real world application. Thus return all rooms would be safer and the implementation is also more simply.
Regards, Maksim
Ta Ri Ki Sun
Ranch Hand

Joined: Mar 26, 2002
Posts: 442
Originally posted by Maksim Golubkow:

Hi TQ, in my case the user would see either checked or unchecked checkbox, but i could also implement it like you. Why i'm asking it? If I would implement the 48 hour rule, than I have to convert the date field to java.util.Date. So why not to do this on the server side and return to the user of my API (DBClient) records with fields of appropriate types?
Regards, Maksim


Hi Maksim, in my implementation the read method returns all rooms matching the criteria, but the methods on the client side doesn't, it re-uses the read method but filters the results so no rooms in the past are displayed, I used to also filter booked rooms but removed it since future implementation may be include cancellations, this is ofcourse documented.
as for converting it to a date, I dont, because its display only, and wont even be returned to the server, only the recordNo and clientId is needed for the reservation, so thats all I send back.
one more thing, be careful about the Date validation, unless you ask the server for the current date or implement it on the server side(not recommended), my Facade/Adapter classes get the server date and validate before booking, anyhat, unless this is done, the client can change his system date and reserve any room he wishes, and as a bonus having the server return its current date allows control of rooms available in various times zones in future, noting that in your choices doc might score you an extra point in general considerations, or maybe not, either way, I thought that was necessary
Andrew Monkhouse
author and jackaroo
Marshal Commander

Joined: Mar 28, 2003
Posts: 11424
    
  85

G'day Rob
I guess either way is probably OK as long as you document why you designed it a particular way.

Yep - I think the documentation of your decisions is the most important bit.
Since I'm still at the design stage (I assume you've finished?), I may completely change my mind once I have something up and running!

Yes, I have completed my assignment, however I had the Fly By Night Services, so my choices dont necessarily apply.
Regards, Andrew
Maksim Golubkow
Greenhorn

Joined: Jun 04, 2003
Posts: 22
Hi TQ,
my first search implementation has returned all room records. But after deciding to convert field values to appropriate types (int, boolean, java.util.Currency, double and java.util.Date) I have thought it would be nice to filter out all records that the user may be won't see. But after rereading the spec and the reply from Mark I have decided to left it as is.
Why we should convert field values to appropriate types? Have you planned some internationalization in your GUI (using ResourceBundle)? If so, than I would say that you could internationalize your GUI only to the half. Why? The date format in German for example is dd.mm.yyyy and not yyyy/mm/dd. Peoples in German would also prefer to see rates as $220,05 and not $220.05 (the last could be interpreted in German as twenty two thousand and five).
To date validation:
I have a class RoomRecord. The objects of this class will be returned from the server as a search result. There are two methods isBookable() where I'm going to implement the 48 hour rule. The conventional implementation will use the current system date to validate the date of the record. The second will use a parameter that represents the current system date.
Why you not recommend to implement it on the server side?
Regards, Maksim
Ta Ri Ki Sun
Ranch Hand

Joined: Mar 26, 2002
Posts: 442
Originally posted by Maksim Golubkow:
Hi TQ,
Why we should convert field values to appropriate types? Have you planned some internationalization in your GUI (using ResourceBundle)? If so, than I would say that you could internationalize your GUI only to the half. Why? The date format in German for example is dd.mm.yyyy and not yyyy/mm/dd. Peoples in German would also prefer to see rates as $220,05 and not $220.05 (the last could be interpreted in German as twenty two thousand and five).

good point, and taken as such.

To date validation:
I have a class RoomRecord. The objects of this class will be returned from the server as a search result. There are two methods isBookable() where I'm going to implement the 48 hour rule. The conventional implementation will use the current system date to validate the date of the record. The second will use a parameter that represents the current system date.

ok, now heres what I was warning against, your server returns these RoomRecord objects (btw, mine does too, only they're called Room, nice ), anyhat, so your server returns these, but surely your server doesn't need these sent back to it in order to book a room right?
So I assume you dont send it back, so where is the method called, on the server, in your _stub or on your client?
now for you to add the missing bit here, which "current system date" is that, the date on the server or the client where your _stub is installed?
and if thats the server date then how did you send it?
did you populate all RoomRecord objects with this date just in case it gets booked?
sorry about the 20 questions, I'm sure if you explain your process to me it will answer the ones that matter.

Why you not recommend to implement it on the server side?
Regards, Maksim

well my database server doesn't know business rules, so methods like bookRoom must be implemented and these rules must be considered, now if bookRoom is called in remote connection, and the _stub Adapter simply creates a new Date to compare to, then that would be the clients current system Date, so while the server doesn't know the business rule I felt it needed to provide its current date to compare against.
This was actually a bug I found when testing my remote clients, the clients could change their dates and book rooms, but remember your Data class should only update, only rules it should care about are valid parameters, and update no matter what.
Regards, TQ
Maksim Golubkow
Greenhorn

Joined: Jun 04, 2003
Posts: 22
so your server returns these, but surely your server doesn't need these sent back to it in order to book a room right?

Why not? Allowing to send it back gives me possibility to detect concurent data modifications. BTW my RoomRecord objects are immutable.
which "current system date" is that
It depends where it called because it does nothing else as But I will move this methods to another class. RoomRecord objects are value objects and so the business logic has nothing to do there.
Originally posted by Ta Ri Ki Sun:

well my database server doesn't know business rules, so methods like bookRoom must be implemented and these rules must be considered, now if bookRoom is called in remote connection, and the _stub Adapter simply creates a new Date to compare to, then that would be the clients current system Date, so while the server doesn't know the business rule I felt it needed to provide its current date to compare against.
This was actually a bug I found when testing my remote clients, the clients could change their dates and book rooms, but remember your Data class should only update, only rules it should care about are valid parameters, and update no matter what.

Does it mean that your server/remote class has a method named bookRoom(...)? The name of the method sounds to me like a business operation or use case and therefore I would say you have to implement the business rule in this method.
(Sorry if I have misunderstood something. English is not my native language.)
Regards, Maksim
Ta Ri Ki Sun
Ranch Hand

Joined: Mar 26, 2002
Posts: 442
Originally posted by Maksim Golubkow:
But I will move this methods to another class. RoomRecord objects are value objects and so the business logic has nothing to do there.

what I was keen to know is which JVM that code is executing in, and from what you've said I'm not entirely sure whether or not the clients _stub will be calling the method or not, but if that is the case then new java.util.Date() will give the clients current system date to compare against.

Does it mean that your server/remote class has a method named bookRoom(...)? The name of the method sounds to me like a business operation or use case and therefore I would say you have to implement the business rule in this method.
(Sorry if I have misunderstood something. English is not my native language.)
Regards, Maksim

I have a Data class as required by the instructions , and this class has the same methods yours does, with the exception of params/throws clauses as discovered in another thread, anyway, those methods do not implement the business rules, the bookRoom method you mentioned is in my FacadeImpl class, and this method implements the business rules around booking a room, but at the same time consider that this class will either be asked to book a room locally or remotely, and if remote, then its in the form of RemoteDataAdapter, and thats the class I rmic, so thats the stub the clients are using, now if thats where I create a new Date(), then that date is the clients system Date, so to get around this, I instead ask for the servers Date, , now that happens in DataFacadeImpl, which I think can be refactored to only happen in RemoteDataAdapter, since in standalone mode the Date is one and the same.
Maksim Golubkow
Greenhorn

Joined: Jun 04, 2003
Posts: 22
I have decided to implement the business logic on the client side, although I personaly prefer the thin-client architecture.
Regards, Maksim
Ta Ri Ki Sun
Ranch Hand

Joined: Mar 26, 2002
Posts: 442
Originally posted by Maksim Golubkow:
I have decided to implement the business logic on the client side, although I personaly prefer the thin-client architecture.
Regards, Maksim


Alright then Maksim, given that, your clients can change the date and book rooms in advance or in the past, its a small hole, but better to plug it.
Maksim Golubkow
Greenhorn

Joined: Jun 04, 2003
Posts: 22
Originally posted by Ta Ri Ki Sun:


Alright then Maksim, given that, your clients can change the date and book rooms in advance or in the past, its a small hole, but better to plug it.

I can't solve all problems of the world in my assignment.
Regards, Maksim
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: NX: [URLyBird] Search result