• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Design Question

 
Bill Bejeck
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am working on URLyBird 1.2.1 and I have come up with a design and I want to see if it too complicated/unecessary. I plan to use my required Data class (implements DBAccess) as a facade to another class that does the "real work" in the database to allow for swapping out to different datastores (from file to relational database etc).
  • First I will create an interface with the basic CRUD methods for data operations. This interface will use generics i.e interface DBService<T> where T will be replaced in the implementation so that it will not be bound to a particular type.
  • Secondly I will implement this interface in a class that will use a RandomAccessFile object to do the database operations. My implementation will look like MyClass implements DBService<String[]> since the required interface works with String arrays.
  • Is this too complex for the SCJD? My intent in writing this new interface is to make modifications very easy by just plugging in a new class that implements DBService. Also, should my DBService interface throw the same exceptions or should I use return values and in my Data class throw the appropriate exceptions(RecordNotFound mainly) based on the return values?
     
    Edwin Dalorzo
    Ranch Hand
    Posts: 961
    • Mark post as helpful
    • send pies
    • Quote
    • Report post to moderator
    Welcome to Javaranch, Bill!

    Look, pal, the Data class must contain an implementation of the DBAccess interface. This interface exposes very primitive methods.

    If I were you I would simply implement the interface. Start by making all the methods work properly with any file conforming to the instructions.html specification. Then make some unit testing, and move on to the next layer.

    There you can worry about how you are going to wrap this Data class into another nice classes like those you said in order to do all that you want.
     
    • Post Reply
    • Bookmark Topic Watch Topic
    • New Topic