• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

NX: Some question about the assignment

 
fei xiao
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am new to do with my assignment and want to get some advice about my assignment. My assignment is about URLBird. Now, I want to RMI to realize the network connect and have some question about the interface.
1. Is the interface of DBAccess must be extended and implemented?
2. If not, how to get the information about the column name of DB?
3. If we have a interface to extends DBAccess. As we know, if we want to realize RMI. We must have one interface to extends Remote. But at the same time, the DBAccess will not throws RemoteException. There will be compile error.
4. About the OOP. Do you have some advice to pay attention to this point?
 
Nicholas Cheung
Ranch Hand
Posts: 4982
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Fei,

1. Is the interface of DBAccess must be extended and implemented?

YES. You cannot change the given *definition* of the interface, however, you are feel free to change it by extending your new interface to this interface, and implement the new interface.

2. If not, how to get the information about the column name of DB?

For example, DBAccess contains 10 methods, which you may not change it. But your class, say A, which implements this interface, can have more than 10 methods, which one of them is for reading the name from DB file.
In addition, I read the *DB schema* in the constructor of class A.

3. If we have a interface to extends DBAccess. As we know, if we want to realize RMI. We must have one interface to extends Remote. But at the same time, the DBAccess will not throws RemoteException. There will be compile error.

You may have 2 independent interfaces, one for backend database access, like the given one (DBAccess), and another one for the client server interactions, say DBServices interface.

4. About the OOP. Do you have some advice to pay attention to this point?

For this part, I take Andrew's advice that starting with use cases, and class diagrams at the beginning. i.e. I write no codes until I compile out my class diagram, make necessary modifications, and that start coding. If you find any problems, e.g. coupling, etc, you can change it before you actually write the code. Finally, you can convert your design into implementation details, which makes life easier.
It is not a requirement for the exam, but it is a good way for this SCJD learning processes.
Nick.
 
fei xiao
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Nicholas Cheung:
Hi Fei,

For this part, I take Andrew's advice that starting with use cases, and class diagrams at the beginning. i.e. I write no codes until I compile out my class diagram, make necessary modifications, and that start coding. If you find any problems, e.g. coupling, etc, you can change it before you actually write the code. Finally, you can convert your design into implementation details, which makes life easier.
It is not a requirement for the exam, but it is a good way for this SCJD learning processes.
Nick.

Thank you for your answer.
You have mention two interfaces. That is to say you have two independent interface such as one is [DBAccess] and another is [DBService].
public interface DBAccess{
public void method1() throws Exception1;
public void method2() throws Exception1, Exception2;
}
public interface DBService extends Remote{
public void method1() throws Exception1, RemoteException;
public void method2() throws Exception1, Exception2, RemoteException;
public void method3() throws Exception1, Exception3, RemoteException;
}
public class Data implements DBAccess, DBService {
public void method1() throws Exception1;
public void method2() throws Exception1, Exception2;
public void method3() throws Exception1, Exception3;
}
And the DBService will be used by the client and server.
Are these class will meet the requirement of the assignment? Becuase in this way, the DBAccess will not be used by any one. But I just can find this kind of way to solve this problem and I don't know whether it is right or not. Do you have some other idea about this?
Thank you.
 
Nicholas Cheung
Ranch Hand
Posts: 4982
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Fei,

Are these class will meet the requirement of the assignment? Becuase in this way, the DBAccess will not be used by any one.

My implementation is a bit difference with what you mention.
My simplified class diagram look like:

So, the Services interface is for the client to call the server for some actions. And Data class (implements DBAccess) is the ONLY class that access with the DB.

But I just can find this kind of way to solve this problem and I don't know whether it is right or not. Do you have some other idea about this?

Since the instructions do not limit that the client must access the server via DBAccess, it only limits that Data class is the only class to access the DB while Data class must implement DBAccess, thus I think this has not violate the rules.
Nick.
 
fei xiao
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
[Client]--[Services Interface]--[DatabaseServer]--[Data (implements DBAccess)]

As you have mentioned, what the relation between [Data] and [DattabaseServer]? Is [DataBaserver] a class or interface? What is your relation between [DatabaseServer] and [Data], [Databaserver] and [DBAccess]
Would you please give me some detail about the relation?
This is my relation of the interface:
[Client]--[{DataService}]--[Data]--[{DBAccess}]
DataService and DBAccess are interfaces. DataService extends interface Remote. Data implements two interfaces:[DataService] and [DBAccess]
[ January 15, 2004: Message edited by: fei xiao ]
[ January 15, 2004: Message edited by: fei xiao ]
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic