aspose file tools*
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Question regarding data class and extending data Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "Question regarding data class and extending data" Watch "Question regarding data class and extending data" New topic
Author

Question regarding data class and extending data

Lisa Foster
Ranch Hand

Joined: Feb 28, 2001
Posts: 116
I have added 3 methods to my Data class and I am also using a class called
package suncertify.db;
import java.io.*;
import java.util.*;
public class DataClientLocal extends Data implements DataClient
{
public DataClientLocal(String dbName)throws IOException{
super(dbName);
}


}
In my DataClient I implement all public methods
package suncertify.db;
import java.io.*;
import java.util.*;
import java.rmi.*;
public interface DataClient extends Remote
{
public FieldInfo [] getFieldInfo()throws RemoteException;
public DataInfo getRecord(int recNum)throws DatabaseException, RemoteException;
public DataInfo find(String toMatch)throws DatabaseException, RemoteException;
public void add(String [] newData)throws DatabaseException, RemoteException;
public void modify(DataInfo newData)throws DatabaseException, RemoteException;
public void delete(DataInfo toDelete)throws DatabaseException, RemoteException;
public void close() throws RemoteException;
public void lock(int record)throws IOException, RemoteException;
public void unlock(int record)throws RemoteException;
public DataInfo[] criteriaFind(String criteria) throws DatabaseException , RemoteException;
public String[] getComboValues(int fieldNum) throws DatabaseException, RemoteException;
public int getMatchCount(String matchCount) throws DatabaseException,RemoteException;
}
Is my design Ok??? I am extending Data class and I have added 3 of my own methods to Data class is this OK???
Thanks Lisa
Karthik Guru
Ranch Hand

Joined: Mar 06, 2001
Posts: 1209
i was just wondering, u need to throw RemoteExceptions as well / u may not.Yes you can definitely promise to throw an exception in the interface and not throw it in Data (which infact does'nt throw a RemoteException.
>public String[] getComboValues(int fieldNum) throws >DatabaseException, RemoteException;
My opinion : this method does'nt look good in the interface, we are trying to design a generic database, so having methods like this which are needed for the client is'nt good design.
Data class needs to be generic. again i'm not sure what it does but if not anything try changing the name of the function. I feel, personally that such methods should remain on the client and can make use of the Data class to provide the functionality.
Try creating stubs using -keep option. U'll see the java file for the stub, lots of things to be learnt there. Atleast I did.
and let me add, i have been working on Java for just over 6 months, and I may be wrong, probably u can wait for others opinions as well.
rgds,
karthik.
Lisa Foster
Ranch Hand

Joined: Feb 28, 2001
Posts: 116
public String[] getComboValues(int fieldNum) throws >DatabaseException, RemoteException;
Thanks for your feedback I am throwing remote because I will use thhis interface for local and remote rmi to save the expense of another interface the other method just populates the origin and destination I am using treeSort to build this..
Thanks for your feedback
Lisa
Karthik Guru
Ranch Hand

Joined: Mar 06, 2001
Posts: 1209
hi lisa,
I strongly feel the following methods s'd not be in the Data class and s'd'nt be throwing RemoteException in Data class/ for that matter none of the methods s'd be throwing RemoteException in Data class.Data class s'd'nt be aware if it's being used in Remote/ Local mode. Also today Combo boxes are being used, tomorrow it c'd be something else.
I do appreciate the fact that you want to use the same interface in local / remote mode.
public String[] getComboValues(int fieldNum) throws DatabaseException, RemoteException;
public int getMatchCount(String matchCount) throws DatabaseException,RemoteException;

regards,
karthik.
Lisa Foster
Ranch Hand

Joined: Feb 28, 2001
Posts: 116
I am beginnong to see the picture it can be too abstract and it is not as eloquent so I will have one for rmi and one for local
Thanks Lisa
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Question regarding data class and extending data
 
Similar Threads
OO Design issue with Data and RMI instance??
Problem at run time see code??????
creating an Adapter for my interface??
Naming.Lookup and Rebind
Error compiling DataClientLocal