This week's book giveaway is in the OCAJP forum.
We're giving away four copies of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) and have Khalid A Mughal & Rolf W Rasmussen on-line!
See this thread for details.
Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

design problem

 
Omar Kalaldeh
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi all,
I am having I design problem, and it�s as following.

In implementing Data class I needed public methods not found in DB interface, and that's create maintainability problem if I want in the future to replace the Data class, I can continue my work with the following Decisions:

1-Let the other objects communicate with Data class interface not DB.
Data data = new Data();
Not DB data = new Data();
ant that's creates a problem with maintainability, some of the classes will depend on my new public methods.

2- Create an Interface extends DB interface (DBExtended) and let Data implements DBExtended, by that I don�t think I am breaking the rule "must implement DB interface" because by implementing DBExtended I am implementing DB (not sure) .

3- Remove the public methods, witch will effect my whole design and remove many of the good thing about it.

4- using an Adapter class, and this choice can't be done, because some of public methods I need, has to communicate directly with data file, such us getSchema().


as I see it the second choice is best one, but the MUST word makes me hesitates.




any second Opinion.
[ June 10, 2004: Message edited by: Omar Kalaldeh ]
 
Andrew Monkhouse
author and jackaroo
Marshal Commander
Pie
Posts: 11914
209
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Omar,

With option 2, your data class will still meet the rule that it implements the interface.

Alternatively you might want to consider what it is that the Data class provides, and then decide whether your other methods truly belong in the Data class. You may find that it may make more sense to move your extra methods to some other class which your server and standalone client can call.

Regards, Andrew
 
Omar Kalaldeh
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Andrew,

Thanks for your reply, but I just want to be sure, do you know any one has extended the DB interface and succeed in the assignment.

I hate to fail in the assignment for trying to make my design more general.

As for your suggestion to add the new methods in class other than Data, that not possible because the method I need has to talk directly with file.
 
Andrew Monkhouse
author and jackaroo
Marshal Commander
Pie
Posts: 11914
209
C++ Firefox Browser IntelliJ IDE Java Mac Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Omar,

There were several people saying that they were creating their own interfaces which extended the provided interface about 6 months ago and they have since passed.

Regards, Andrew
 
yang wulong
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi, omar

your option 2 is ok, I have the same problem the last week, and I asked the Sun, they reply me that is OK.
 
Omar Kalaldeh
Ranch Hand
Posts: 58
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi yang,

Thank you very much, now I can start implementing my design, and I am relieved.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic