my dog learned polymorphism*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Adapter for supplied Interface to DB Implementation OR how strict is sun? 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 "Adapter for supplied Interface to DB Implementation OR how strict is sun?" Watch "Adapter for supplied Interface to DB Implementation OR how strict is sun?" New topic
Author

Adapter for supplied Interface to DB Implementation OR how strict is sun?

Rudolph Jen
Ranch Hand

Joined: Nov 17, 2006
Posts: 37
Hi there.

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.

Any tips?

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.


SCJP<br />SCJD (in progress)
Mark Smyth
Ranch Hand

Joined: Feb 04, 2004
Posts: 288
Hi,

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.

Mark.


SCJP<br />SCJD
Rudolph Jen
Ranch Hand

Joined: Nov 17, 2006
Posts: 37
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.

Tanks.

Best Regards,
R
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Adapter for supplied Interface to DB Implementation OR how strict is sun?
 
Similar Threads
Adapter pattern and DB interface
URLyBird 1.2.1 Passed!
NX: Adapter class
Interface provided by Sun
NX: Two questions