Its a business rule that must be implemented. Basically it means if the availability date of the room is today, tomorrow, or the day after tomorrow, the user can book the room. Otherwise the system should not allow the room to be booked. [ March 23, 2006: Message edited by: B Chen ]
I guess it depends on your design... I decided to implemented a Business Layer as I think it's good practice to separate the business logic from the presentation layer (in our case a Swing GUI).
Imagine if the IT director came to you in a few months with a requirement to Web enable the application, if you have seperated out your logic it would be quite straightforward to create a Front Controller for the web application and then reuse all the existing logic.
if so, i should send my searchEvent code to this layer who will filter the results returned by the data layer before sending my gui the long of acceptable records?
Yes, your searchEvent method in the GUI controller class should call the business layer to retrieve matching records. I would recommend that your business layer doesn't just provide the long back to the GUI layer, but instead call the read method for each record and return this information back to the GUI.
The more you abstract the functionality from the different layers the more flexible your design will be.
Originally posted by Jason Moors: I think there are two ways you can handle this requirement.
1) Filter Records in the business layer (not in the DB layer), so that only rooms that are available within the next 48 hours are displayed in the GUI.
2) Display all records but if a user selects a room that is not available in the next 48 hours, display an error message. Jason.
(the english is my second foreign language too) I would prefer another option based on the first one. I would display all records matching user's search criteria, but the unavailable ones could be marked for instance with red color. The tray to book these records should invoke an error message. (The "booking button can bee disabled as well) The reason: User can bee confused with an empty search result especially when he knows that such a record exists.
If I understand correctly, I think you are recommending filtering the rooms based upon the 48 hour availability rule, but then displaying the booked rooms?
I personally think this would be more confusing for a user, displaying a large number of records, when they can actually only book a few. If you compared this to the real world, if you tried to search for a room for on Expedia for the 28th March, you wouldn't expect it to display hunderds of booked rooms, only the ones that are available.
I guess you could argue that the system is for agents not end customers and therefore they may want to unbooked rooms etc, but I think this is outside of the requirements.
Jason [ March 28, 2006: Message edited by: Jason Moors ]
I implemented the int find(String criteria) method in tha Data class to return all records that match the criteria. However in my business layer I filter on date and records that have booked.
I guess it depends on how you interpret the requirements.
They take bookings only within 48 hours of the start of room occupancy
The GUI does not support searching by date, so I have decided to filter based upon the 48 hour requirement as there could be records in the database for rooms that were available 3 months ago, and I don't think it makes sense to display these rooms.
I'm not saying my approach is right, but personally think having hundreds of records that are not available is not very user friendly, i.e date of availability in the past or in the future, or already booked.
I'm sure you approach is also valid, it's just that I think it will not be clear to the user which rooms are available or not.
As long as you can justify the reason for your decision I'm sure you will not lose marks.
[ March 31, 2006: Message edited by: Jason Moors ] [ March 31, 2006: Message edited by: Jason Moors ]