• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

your suggestions to make my "design" correct

 
Bhuvan mehra
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All!
Here is my design.
db (pack)
========
1.DataInterface (interface) has all Public methods, all methods throws RemoteException, few throws DBE, IOE
2.Data (class) implements lock(), unlock(), criteriaFind()
(changed sign. Of lock(record_no, id) , unlock(record_no, id) will this reduce marks??)
server (pack)
==========
3.ServerDataInterface (interface) extends Remote, DataInterface
4.ServerData (class) extends Data implements DataInterface, and override lock(), unlock()
(exports �itself� using export() method)
Binder (class) binds ServerData

client (pack)
==========
5.ClientGUI (class)
6.DataFactory (class) return DataInterface (Data or ServerData)
7.ClientAdapter (class) extends DataInterface (is ClientAdapter�s implementation correct ???)
{
        DataFactory df = new DataFactory();
        DataInterface di = df.getData();

        public void add(�..)
        {
        di.add(�.);
        }
        public void delete(�..)
        {
        di.delete (�..);
        }
        public void modify(�..)
        {
        di. modify(�..);
        }
        public void criteriaFind(�..)
        {
        di.criteriaFind (�..);
        }
        public void lock(�..)
        {
        di.lock (�..);
        }
        public void unlock(�..)
        {
        di.unlock (�..);
        }
.
.
.
.
.
.
        searchFlight()
        {
        criteriaFind(�)
        }
        reserveSeats(�.)
        {
        lock(�)
        unlock(�..)
        }
}
ClientGUI
{
        ClientAdapter ca = new CA();
        buttonsearch.addactionListen(����)
        {
        ca.searchFlight(�.)
        }
        buttonreserveSeats.addactionListen(����)
        {
        ca.reserveSeats(�.)
        }
}
need your valuable suggestions. can i clear the exam with this simple design?
Thanks,
Bhuvan.
[ April 01, 2002: Message edited by: Bhuvan ]
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
can i clear the exam with this simple design?

Does it work, and do you feel comfortable with it?
Mark
 
Bhuvan mehra
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi!
Mark, thanks again. it is working. i am able to invoke methods of Data and ServerData(in local and n/w mode). i am new to design patterns that's the reason i am not sure weather this design is good or not. i learnt alot while preparing for scjp and want to learn maximum in preparation of the scjd. i have no person to guide (like all in the forum) and i have no experience of realworld. i make my design, and requested to tell what i am missing and where? i have read a discussion on design but still try to project what i think.
i am comforable with my design because it is working but not sure wheather it is good or not.
quote:
--------------------------------------------------------------------------------
can i clear the exam with this simple design?
--------------------------------------------------------------------------------
i was not comfortable with above statement.
thanks and regards,
Bhuvan.
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
1.DataInterface (interface) has all Public methods, all methods throws RemoteException, few throws DBE, IOE

I would have it throw Exception only, in your implementations of this interface, ahve them throw the more specific Exceptions that are needed for them.
For instance Local implementation does not need to throw RemoteException.
Mark
 
Bhuvan mehra
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi Mark!
i got above point. thanks for that. but overall, is this design is good or ok. i have started implementing this design but will consider to change the design if something you suggest to change.
for GUI, i have a class which create GUI and pass it's reference to GUIHandler, which handle all events. but i used like GUI.button.addActionListener(...){} and you have pointed to use MVC pattern. can you give an exmple of that?
regards,
Bhuvan.
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
but overall, is this design is good or ok

Yes. But I also think that as you go along, you might find some things that you will want to change. Don't worry about it right now. You will also find how easy it will be to change things around.
Example of MVC.


Something like that. I just threw that together, so it is not exactly the code that I used or what you will use. But it is very close. the model is your DataAccess or DataAccessFacade class. The view is the GUI class. That's the gist of the MVC pattern.
Hope that helps
Mark
 
Bhuvan mehra
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mark I don't have proper words for your cooperation, time, sharing knowledge attitude and patience.
Thanks for everything.
Regards,
Bhuvan.
[ April 02, 2002: Message edited by: Bhuvan ]
 
Bhuvan mehra
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi!
Trapped in old problem again.
�Writing Data Client
To connect with your server, you should create a client program. This implementation ---------->should include a class that implements the same public methods as the suncertify.db.Data class, although it will need different constructors to allow it to support the network configuration.

while writing client pack, we are forced to write a class which implements all public methods of Data class. Am I correct?
when we have a ref. of main interface (DataInterface) and can invoke all public the methods of Data or RemoteData then why we need to implement above statement?
I am not able to get importance of above step.
Regards,
Bhuvan.
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
then why we need to implement above statement?

I think that way is implementing that above statement. You are providing a way for the client to access the server and call methods of the Data class. Even if it is filtered through a Facade to a class implementing the DataAccess interface to actual call the Data class methods. That is doing what the above requirement is asking.
Mark
 
Bhuvan mehra
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Mark!
I changed my design little bit. Need your opinion.
db package
�����
-- DataInterface(all public methods of NewData class with lock(rn,id)/unlock(rn, id),bookSeats(rn,seats,id),criteriaFind(Str).
-- Data
-- NewData(implement criteriaFind(Str), lock(rn,id)/unlock(rn,id), and a new method bookSeats(rn,seats,id))
(NewData extends Data and implements DataInterface
server package
������.
-- DataServerInterface extends db.DataInterface , Remote
-- ServerData extends db.NewData.
-- ServerDataAccessProvider extends UnicastRO implements ServerDataInterface
(it contains ServerData)
(in my first Design I was providing ServerData to Client . now I want to change this and want to provide ServerDataAccessProvider. This class will redirect all the requests to object ref. Of ServerData)
this change is to restrict access of ServerData directly.
-- ServerBinder will bind ServerDataAccessProvider
client package
������
-- ClientGUI
(has instance of ClientData)
-- ClientData implements db.DataInterface
(has all public methods and instance of DataInterface through ClientFactory. And will redirect call to either NewData or ServerDataAccessProvider.)
-- Client Factory
(return DataInterface(NewData or ServerDataAccessProvider))
i hope this one is better than prev.
suggestions are always welcome Mark.Thanks.
regards,
Bhuvan.
[ April 04, 2002: Message edited by: Bhuvan ]
 
Bhuvan mehra
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
.
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
bookSeats(rn,seats,id),

Ok does all databases book seats. If you have a database that stores Football scores, does it need a bookSeats method? No, it is not the responsibility of Data to bookseats.

ServerData extends db.NewData.

How many times are you going to extend the Data class?
Ok, here we go.
1. You can either extend or modify the original Data class to implement the lock, unlock, and criteriaFind methods.
2. Make 1 interface that has all the public methods of the new Data class or the modified one, depending on which you chose in statement #1.
Interface extends Remote, throws only Exceptions
3. Have 2 classes implement the interface. One for local, one for remote.
4. Have a factory that will except a host IP, which makes an instane of the Remote implementation, or nothing which makes an instance of Local implementation.
5. Make a DataFacade class that takes the #2 interface, in this class you can make your bookSeats method.
I think you will be able to go from there.
Mark
 
Bhuvan mehra
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
quote:
--------------------------------------------------------------------------------
ServerData extends db.NewData.
--------------------------------------------------------------------------------
How many times are you going to extend the Data class?
Mark, i start my net to delete this step. but ....
:roll:
 
Bhuvan mehra
Ranch Hand
Posts: 69
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mark,
S r r y.
Data ---<-- NewData (have cf(), lock(), unlock())
Remote --<- - DataInterface (have all methods of NewData and all methods throw Exception)
DataInterface --<- - LocalDataAccess(implements all methods and redirect invocation to (new NewData())
DataInterface --<- - RemoteDataAccess(implements all methods and redirect invocation to (naming.lookup("newData"))
Factory (return LocalDataAccess or RemoteDataAccess)
DataFacade (new Factory() and bookSeats() method.)
Thanks for your guidance.
regards,
Bhuvan.
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
 
Eugene Sun
Greenhorn
Posts: 17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
[Mark}
2. Make 1 interface that has all the public methods of the new Data class or the modified one, depending on which you chose in statement #1.
Interface extends Remote, throws only Exceptions

[/Mark]
Why would you want to make the interface extend Remote interface ? It doesn't make sense to me for the LocalDataAccess case.. Could you clarify ?
Thanks,
Eugene
[ November 23, 2003: Message edited by: Eugene Sun ]
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic