This week's book giveaway is in the Other Languages forum.
We're giving away four copies of Functional Reactive Programming and have Stephen Blackheath and Anthony Jones on-line!
See this thread for details.
Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

URLyBird: The Data File

 
Roel De Nijs
Sheriff
Posts: 10593
142
AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 one
  • Primary 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 ]
     
    Herman Schelti
    Ranch Hand
    Posts: 387
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    hi Roel,

    here's what I did:
    -magic cookie: I only used the fact that it's 4 bytes long.
    -I used hardcoded values (constants) for all header names and lengths
    -I extended the given interfaces with a few methods that use a value object instead of String[]
    -I used recNo for primary key.

    My advice: keep it simple, and document your decisions.

    Herman
     
    Roel De Nijs
    Sheriff
    Posts: 10593
    142
    AngularJS Chrome Eclipse IDE Hibernate Java jQuery MySQL Database Spring Tomcat Server
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Originally posted by Herman Scheltinga:
    hi Roel,

    here's what I did:
    -magic cookie: I only used the fact that it's 4 bytes long.
    -I used hardcoded values (constants) for all header names and lengths
    -I extended the given interfaces with a few methods that use a value object instead of String[]
    -I used recNo for primary key.

    My advice: keep it simple, and document your decisions.

    Herman


    Thanks for your answer.

    I noticed you passed your exam with 385/400 --> congrats

    you extended the given interfaces with a few methods that use value object: i thought that you never may extend the given interface and have to implement it as such to pass and not automatically fail? and did you use in your value object all strings or also ints and dates?
     
    Herman Schelti
    Ranch Hand
    Posts: 387
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    hi Roel,

    i thought that you never may extend the given interface

    By extending I mean: create a new interface, that extends the given interface.
    There's nothing in the specs that disallow that.
    The class that implements the extended interface will always implement the given interface as well.

    did you use in your value object all strings or also ints and dates

    Mostly Strings, just one int (or was it a long?) for the recordnumber.

    Herman
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic