Howdy, y'all.
Originally posted by Mary John:
can I make following assumption while writing create method
1. make sure that name and location fields are not null
2. make sure that the combination of name and location fields are unique.
Well, I don't have the B&S, I have the URLyBird, but I think no field can be null. I check it in the create method. If the
String array sent is null or if any of the fields is null, I throw an IllegalArgumentException.
Also, before making sure if the combination of name and location fields are unique, make sure that it doesn't make sense to have this combination. In other words, be sure that it wouldn't make sense to have 2 different records with same name and location. But if having 2 records with the same name and location makes sense, then you can't do it. By the way, I think you made this combination your primary key, right? If so, make sure to throw a DuplicateKeyException there.
Originally posted by Simon Hogg:
This means that validation in the database class is just simple checks on field size, etc.
Perfect.
Originally posted by Simon Hogg:
I decided that a better choice would be to put in minimum and maximum price search fields.
Honestly, I think your idea is great, I really do. But in my opinion, you are going too far. Remember that "you will not receive extra credit points for work beyond the requirements of the specification" (from the specifications document). This is required for your GUI:
- It must be composed exclusively with components from the
Java Foundation Classes (Swing components).
- 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.
- It must present search results in a JTable.
- It must allow the user to book a selected record, updating the database file accordingly.
So you must allow the user to search only for name and location. I just put in the project exactly what was asked. For example, I did not add logging because, it wasn't asked, and also, the more code you write, the bigger are your chances of making mistakes and having points taken from your final score. So in a nutshell, your idea is really great, but I wouldn't do that.