This week's book giveaway is in the OCAJP 8 forum. We're giving away four copies of OCA Java SE 8 Programmer I Study Guide and have Edward Finegan & Robert Liguori on-line! See this thread for details.
I am a little bit unsettled: In the B&S assignment I got that not so nice interface with a lot of String arrays in it. Naturally I don't like untyped information, so I am going to eliminate them as soon as I get them.
Solution: My (dirty) interface --> Adapter(Design Pattern) --> nice Interface (without String arrays) --> DB
Now the reason for my unsettled feelings: Sun defines in my assignment "Your data access class must called "Data.java", must be in a package called "suncertify.db", and must implementt following interface:"
In my clean design (I guess) my Implementation of the specified interface would be my adapter (I could call the Adapter Data.java). Normally I wouldn't even think about that, but I don't want to fail in any automatic tests, Sun is going to run after my uploading.
Has anyone had similar thoughts before me and had no problem during validation?? I would like to keep my design clean, but I am not sure how strict sun is going to evaluate all the 'MUSTs' in the assignment.
Best Regrads, R
PS: I am not talking about an adapter, so that the client don't see the lock/unlock methods. I am talking about the upper tier to the used DB.
Sun treats any must statements very seriously. I think with this design you would probably fail as Data must implement the interface no matter how much you dislike it. I am confused as to why you would want a clean interface to the DB and then expose the supplied interface to the client via the Adapter class. Surely the otherway around would the better solution.
I thing the DB interface is quite a good generic interface (stupid Exceptions and find method apart). My data class accepts any String once it contains ASCII charchters with the correct number of fields of the proper length, according to the schema. It is up to higher layers to apply the application specific data validation.
Joined: Nov 17, 2006
Okay, thanks for the wakeup ;-) To be sure I am going to follow you advice. No Adapter in that way.
>It is up to higher layers to apply the application specific data validation.
That a good idea. So I can use my design almost as wanted, but still have a validation tier. I like it.