aspose file tools*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes B&S: Handling different data files (format, schema)? 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 "B&S: Handling different data files (format, schema)?" Watch "B&S: Handling different data files (format, schema)?" New topic
Author

B&S: Handling different data files (format, schema)?

Darya Akbari
Ranch Hand

Joined: Aug 21, 2004
Posts: 1855
Hi all,

I've recently downloaded my assignment (Bodgitt & Scarper Version 2.1.3) and have my first question concerning the provided data file issue.

My assignment says:


... a data file that contains essential information for the company, but because the data must be manipulated ... the new system must reimplement the database code from scratch without altering the data file format.


Would these be right interpretations :

  • The original data file can be replaced by another data file.
  • The data file format in a new data file however remains the same.
  • The schema description section in a new data file can change.


  • Any clarification on this would really help.

    Regards,
    Darya
    [ March 16, 2005: Message edited by: Darya Akbari ]

    SCJP, SCJD, SCWCD, SCBCD
    joe lin
    Greenhorn

    Joined: Dec 07, 2004
    Posts: 28
    hi Darya,


    The original data file can be replaced by another data file.

    replace the original data file with another data file?why?!

    The data file format in a new datafile however remains the same.

    the same as above.

    The schema description section in a new data file can change.

    you can't change the db file's schema,you only need to read out the schema and then handle the following data of the db file according to the achema.
    hope this hleps!


    Looking for better solution...<br />SCJP1.4
    Frans Janssen
    Ranch Hand

    Joined: Dec 29, 2004
    Posts: 357
    Hi Darya,

    Originally posted by Darya Akbari:

    Would these be right interpretations :

  • The original data file can be replaced by another data file.

  • This would be a safe assumption. I even think you really must assume this. The instructions state that your application must provide a means to select a location of the database. This hints that it should work for any valid database file.

  • The data file format in a new data file however remains the same.

  • Yes, you can safely assume this.

  • The schema description section in a new data file can change.

  • I don't think you will need to assume this. Although the schema is located inside the file, the format is also specified in your instructions. I think you therefore can assume that you only need to handle the specific schema as described in the instructions.

    You could make your code such that it can handle different schemas, but this will probably not give you any extra points.

    Frans.


    SCJP 1.4, SCJD
    Darya Akbari
    Ranch Hand

    Joined: Aug 21, 2004
    Posts: 1855
    Hi Joe,

    you ask me why ? Because I understand the assignment quote this way .

    I hope more of you can help me clarify this issue, so I can weight for a path I'll follow for the modelling.

    Thanks,
    Darya
    [ March 16, 2005: Message edited by: Darya Akbari ]
    joe lin
    Greenhorn

    Joined: Dec 07, 2004
    Posts: 28
    hi Darya ,
    the db file contains header data,schema data and some record datas.
    you can't modify the header data and schema data,these data only provide you some information to handle the record datas.so you can modify the record datas.also ,you can replace the original db file with another db file
    which has the same header data and same schema data with the original db file(the record datas can be different certainly).
    hope this helps!
    Darya Akbari
    Ranch Hand

    Joined: Aug 21, 2004
    Posts: 1855
    Hi Frans,

    I could think of that B&S gives me a new data file with additional fields. However they must take care to provide the essential information as my assignment quote says.

    However your conclusion that the schema description is separately specified in the assignment sounds reasonable. It really wouldn't be necessary because the schema description is already specified through the data file format. So why should they mentioned it twice?

    If others agree to it I can go for the modelling based on the schema description.

    By the way Frans, is it possible that you are a native german speaker ?

    Thanks,
    Darya
    [ March 16, 2005: Message edited by: Darya Akbari ]
    Frans Janssen
    Ranch Hand

    Joined: Dec 29, 2004
    Posts: 357
    Originally posted by Darya Akbari:
    However your conclusion that the schema description is separately specified in the assignment sounds reasonable. It really wouldn't be necessary because the schema description is already specified through the data file format. So why should they mentioned it twice?


    Yes, that bothered me too. In my implementation I did use the field lengths and descriptions from the schema, but I assumed that the number and order of the fields would not change. Sounds a bit like a compromise, but I just made the choices that were convenient for me

    By the way, I received the full score for the server part, so I guess that my assumptions were not a problem.

    [QB]By the way Frans, is it possible that you are a native german speaker ?

    You're close, but in fact I am a native Dutch speaker.

    Frans.
    Darya Akbari
    Ranch Hand

    Joined: Aug 21, 2004
    Posts: 1855
    Thanks Frans and Joe for your responses. I feel now more comfortable to continue with a first model.

    Regards,
    Darya
    Darya Akbari
    Ranch Hand

    Joined: Aug 21, 2004
    Posts: 1855
    Hi all,

    after reviewing the assignment and some of the threads here and reading Max Habibi's SCJD book and ... I come to the conclusion that the Adapter Pattern fit best to the requirement of handling different data files.

    Talking in the terms of the Adapter Pattern I would use the given DB interface as my Target interface and the data access class Data.java as my Adapter class.

    So if B&S came up with a different data file we would have to write a new Adapter class Data.java

    The real data file I would hide into a new class Database which would be the Adaptee class and would have also to be written again.

    So the Adapter and Adaptee classes must be rewritten in case another file with a different format and/or schema is provided by B&S.

    I will propagate a Message to the user (Customer Service Representative) that the choosen data file does not match the required format. I think that should be enough.

    Is that correct
    Vengan Krish
    Ranch Hand

    Joined: Mar 05, 2005
    Posts: 32
    Darya,
    The whole Adapter pattern comes into play in this project only when a class has to handle two different implementations - one being Data.java and the other one being RMI stuff.
    I feel you are thinking overly about handling multiple data files. The first and foremost assumption in this project is that the application would handle only same data file or one of similar nature. You can rest assured that they are not going to test your submission with a different data file.

    Regards


    SCJP 1.4<br />SCJD 1.4<br />SCWCD 1.4<br />SWBCD (Preparing)
    Darya Akbari
    Ranch Hand

    Joined: Aug 21, 2004
    Posts: 1855
    I know that I must handle only the given data file :roll:

    But isn't the concept of the Adapter Pattern to handle multiple Adaptees (data files). To me it says that for each new data format and schema I had to write a new Adapter class.

    Of course in our assignment I do it once for the given data file. Now I want to make sure about the right use of the Adapter Pattern for the db layer only. In my assignment it's stated that my data access class is Data.java which must implement the DB.java interface.

    Talking in the terms of the Adapter Pattern, would the following assumptions be correct?

  • DB interface as my Target interface
  • data access class Data as my Adapter class.
  • the data file as class Database as my Adaptee class



  • Regards,
    Darya
    Andrew Monkhouse
    author and jackaroo
    Marshal Commander

    Joined: Mar 28, 2003
    Posts: 11279
        
      59

    Hi Darya,

    Personally, I don't think this is required for the assignment, however it is an interesting exercise in it's own right.

    Originally posted by Darya Akbari:
    Talking in the terms of the Adapter Pattern, would the following assumptions be correct?
  • DB interface as my Target interface
  • data access class Data as my Adapter class.
  • the data file as class Database as my Adaptee class


  • Yes, this would fit the Adapter Pattern into the data retrieval.

    For these assignments, it appears that the Magic Cookie in the data file corresponds to the version number of the assignment. You might be able to use this in your Adapter class' constructor - open the file, read the cookie, then load an Adaptee class that knows how to process the specified version of the database file (or throw a suitable exception if the Magic Cookie value is not recognised).

    Since we are talking about patterns - have you considered whether your locking code really belongs in the Data class? Since you are moving the data access methods into an Adaptee class, you might want to move the locking code into a class that is specifically designed for locking. In which case, your Data class might also be a Fa�ade .

    Regards, Andrew
    [ March 18, 2005: Message edited by: Andrew Monkhouse ]

    The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
    Darya Akbari
    Ranch Hand

    Joined: Aug 21, 2004
    Posts: 1855
    Hi Andrew,

    thanks for your response.


    Since we are talking about patterns - have you considered whether your locking code really belongs in the Data class? Since you are moving the data access methods into an Adaptee class, you might want to move the locking code into a class that is specifically designed for locking. In which case, your Data class might also be a Fa�ade .


    It took me some days to figure out my locking mechanism and I decided for a seperate locking class due to the fact that I have to implement a locking mechanism on a record handling scope. Having now a class that implements the locking mechanism I view the Adapter class Data
    also as a Facade.

    What confuse me is what my assignment says about the Data class:



    Hence my Adapter/Facade class Data does not free the client of Data from handling the lockCookie variable.

    How can I hide the lockCookie from the clients eye? Or is the client of Data supposed to handle lockCookie?

    Regards,
    Darya
    Andrew Monkhouse
    author and jackaroo
    Marshal Commander

    Joined: Mar 28, 2003
    Posts: 11279
        
      59

    Hi Darya,
    How can I hide the lockCookie from the clients eye? Or is the client of Data supposed to handle lockCookie?
    The client of Data must get the cookie when it calls the lock method, then use it in the calls to update and unlock.

    Regards, Andrew
    Darya Akbari
    Ranch Hand

    Joined: Aug 21, 2004
    Posts: 1855
    Hi,

    I continue my data layer design in this new thread.

    Regards,
    Darya
    [ March 28, 2005: Message edited by: Darya Akbari ]
     
    I agree. Here's the link: http://aspose.com/file-tools
     
    subject: B&S: Handling different data files (format, schema)?
     
    Similar Threads
    database schema B&S
    B&S: How to make Booking method atomic?
    B&S: Do you show the Flag field and what is really meant by it?
    B&S: How to use suncertify.properties ?
    SecurityException