Hi all,
I' ve read already numerous posts on this (excellent) forum/board concerning the data file, but i'm not satisfied with the answers i could find. maybe this has something to do with my personality: always willing and trying to do better than perfect and thus this quite open assignment is hell for me, i'm always wondering if doing this or that won't fail me etc.
I have some questions/concerns concerning the data-file and any comments on these ones are muchly appreciated:
Magic Cookie: it indicates a data file and because every assignment has different data scheme, it seems good practice to me to check if you have a correct data file (because else reading the datafile could result in complete nonsense). but how can you validate your magic cookie, because you don't have any validity rules? The only way i see that's possible is reading in your file, taking note of the cookie-value and make it a hard-coded constant in your code, but hard-coded isn't good practice. or maybe i could make a method checking the validity of the data-file and for now just check against the hard-coded cookie-value. and if in a later stadium a developer gets the exact validity rules he only has to replace the hard-coded cookie-value-check with the appropriate business logic.Header Information: instead of hard-coding the information about the data fields (length, name) you could dynamically retrieve them from the header information. and of course this is better than the hard-coded way, but i'm wondering if this won't needlessly make the code more complex. and how far do you go in this dynamically handling header information. what if a data field is added or removed? does your program have to handle this without making changes (because how can you know from header information that some data-field is a date or a double or ... and that info is needed because somewhere you have to test if data entered is valid) ? will this affect the magic cookie (resulting in another data file)? POJO: my interface contains always arrays in all its methods, so i can't change that. but maybe it's more clear to have a pojo containing all information and in 1 utility-class change from object-to-array and from array-to-object. but if you choose to go for dynamically handling the header information you can't use a pojo because you don't know a thing about the available fields. if you go for the hard-coded way (cfr. denny's dvd) are you choosing for all String data members or for the appropriate ones (String, int, double, Date). so i guess the choice of the previous point influences this onePrimary Key: no primary key available in the data file, so how to identify a record uniquely? the main proposal heard/read is to use the record number. but you can wonder if it is needed to identify records uniquely, because if 2 hotel-rooms have exactly the same info it doesn't matter which one is booked. but would this approach (no PK) doesn't complicate the code, because you don't have no unique identifier and have to do a lot of looping through your hotelroom-collection and comparing hotelrooms to check for equality. but on the other hand: if 2 users search for a same room and there are 2 same rooms available, they both select the first one in the table, with a pk one will be able to book, other one will get error message that it isn't available anymore (but there is still one room available, so that's a bit confusing).if you don't have pk both users will be able to book a room. so that's a lot more user-friendly. but in my interface that i have to implement, nearly each method has a recNo as parameter or return value, so i guess i have to use some unique identifier for each record That's it for now, a whole lot i know, but i've been thinking about it also for a long time
With kind regards,
Roel
[ March 18, 2008: Message edited by: Roel De Nijs ]