| Author |
design problem
|
Omar Kalaldeh
Ranch Hand
Joined: Jun 08, 2004
Posts: 58
|
|
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 ]
|
Best Regards <br /> <br />Omar F. Kalaldah<br />---------------------<br />SCJP, SCJD, SCBCD
|
 |
Andrew Monkhouse
author and jackaroo
Marshal Commander
Joined: Mar 28, 2003
Posts: 10892
|
|
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
|
The Sun Certified Java Developer Exam with J2SE 5: paper version from Amazon, PDF from Apress, Online reference: Books 24x7 Personal blog
|
 |
Omar Kalaldeh
Ranch Hand
Joined: Jun 08, 2004
Posts: 58
|
|
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
Joined: Mar 28, 2003
Posts: 10892
|
|
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
Joined: Jun 07, 2004
Posts: 5
|
|
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
Joined: Jun 08, 2004
Posts: 58
|
|
Hi yang, Thank you very much, now I can start implementing my design, and I am relieved.
|
 |
 |
|
|
subject: design problem
|
|
|