Forums Register Login

about the data model

+Pie Number of slices to send: Send
Hi
I am working on displaying data into JTable, using the DataModel extends AbstractTableModel.
In order to get table data from db file, I going to create an instance of Data class in this DataModel class, and do all the data processing in there as well.
I am wondering it is a good idea or not.
please help,

lili
+Pie Number of slices to send: Send
Hi li li
I feel creating the instance of the Data class directly in your view class is a bad design. Better u read Factory pattern, Abstract pattern, Facade pattern, which will help u design ur project well.
-rameshkumar
+Pie Number of slices to send: Send
 

Originally posted by Ramesh kumaar:
Hi li li
I feel creating the instance of the Data class directly in your view class is a bad design. Better u read Factory pattern, Abstract pattern, Facade pattern, which will help u design ur project well.
-rameshkumar


Hi Ramesh,
Can you give more details?
The way I have implemented is as follows: (not sure where design pattern can be applied !)
(a) CSR (Serice Representative) searches for a "Specialty"
(b) The Data class finds for all "Contractors" who match the specified specialty
(c) The Data class returns an array of objects - of type "DBResultSet" (I have given the definition below).
public class DBResultSet {
public int recno;
public String name;
public String location;
public String specialties;
public String size;
public String rate;
public String owner;
}
I added the following method in the Data class :
public DBResultSet[] find(String criteria) throws RecordNotFoundException {
...
}
(d) In the Swing application, read all the elements from the DBResultSet array and update the JTable model.
With the Beta almost over, I need to complete the assignment faster and start documentation !
Your advice on using design patterns in above code / functionality would be great !
Regards,
Dayanand.
+Pie Number of slices to send: Send
Hi li li
I feel creating the instance of the Data class directly in your view class is a bad design. Better u read Factory pattern, Abstract pattern, Facade pattern, which will help u design ur project well.
-rameshkumar
+Pie Number of slices to send: Send
Hi Daya,
I think there is no need of having DataResultSet class as u have, because read() method of DBMain returns String[] which can be used strightaway in DefaultTableModel without
any change.
In my case DBMain.java is the interface which has all the methods that was given by sun. I have an implementation class which is named as DBMainImpl.java. Now to access the DB i have a class DBAccess.java which extends DBMainImpl.java and implements DBAccessInterface.java which has the following methods update, lock,unlock,search. The above interface is implemented by another interface named RemoteDBAccessInterface which acts as the remote interface in our project. Here i just instantiate DataAccess.java for remote clients.
Hope this may help.
Goodluck.
rameshkumar
"Don't believe every tiny ad you see on the internet. But this one is rock solid." - George Washington
a bit of art, as a gift, that will fit in a stocking
https://gardener-gift.com


reply
reply
This thread has been viewed 849 times.
Similar Threads
Models & Arrays
Models & Arrays
doubts on MVC
JTable refreshment -- or was that 7up?
[JSF 2] Update the total of a column from a dataTable
More...

All times above are in ranch (not your local) time.
The current ranch time is
Mar 28, 2024 10:23:37.