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

URLyBird: The Data File

Roel De Nijs
Bartender

Joined: Jul 19, 2004
Posts: 5266
    
  13

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 ]

    SCJA, SCJP (1.4 | 5.0 | 6.0), SCJD
    http://www.javaroe.be/
    Herman Schelti
    Ranch Hand

    Joined: Jul 17, 2006
    Posts: 387
    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
    Bartender

    Joined: Jul 19, 2004
    Posts: 5266
        
      13

    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

    Joined: Jul 17, 2006
    Posts: 387
    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
     
    It is sorta covered in the JavaRanch Style Guide.
     
    subject: URLyBird: The Data File