• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

NX: Data access class

 
Maria Lepschy
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi ranchers,
Please give me a reponse about my design.
I have following:
-the Data class implements the Sun interface DB.
-the Database interface that looks quite like the DB with 2 additional methods, book and search but throwing also IOException.
- the DataAdapter extends Data implements Database with only the 2 additional methods search and books.
So the GUI will access the db through DataAdapter.
Sun requires that data access class is Data. Because DataAdapter extends Data, I think is it Ok, but I am not sure. What is your meaning?
Regards,
Maria
 
Greg Till
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Maria,
You say the GUI accesses the data file through the DataAdapter class. The DataAdapter class has all the methods of the Data class as well as search() and book().
Some of the questions you need to ask yourself are - does the gui need to access all those extra methods? What will happen to the locking if the gui calls some of the other methods the DataAdapter inherits from the Data class?
It is generally good practice to only expose as much functionality as is required / useful. Obviously you are restricted by the requirements in what you MUST deliver for some of your classes, but perhaps
you could have a look at what the purpose of DataAdapter is in your design.
To me, saying that you must access resource x through class Y means you DO have to use class Y, but it doesn't say whether you must use it directly or you can access it via inheritance (IS A) or via aggregation (HAS A).
Hope this is helpful.
Greg
 
Maria Lepschy
Ranch Hand
Posts: 78
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you, Greg!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic