• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

a design confusion to clarify

 
James Du
Ranch Hand
Posts: 186
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I find that many people defined all the public methods of class Data in the interface (DataInterface or DataAccess). well i think many of the public methods of class Data has no need to be knew by other class. such as getRecordCount(), getRecord(), add(), find(), close().
in my case, i just defined 5 methods in the DataInterface, they are
1. public FieldInfo[] getFieldInfo()
2. public DataInfo[] criteriaFind(String criteria)
3. public boolean bookSeat(String FlightNo, int Num)
4. public boolean isRemoteMode();
5. public Vector getFieldItems(String FieldName)
and i find it's sufficent for client to perform the business required. how do you guys think about my design?
what's the value of defining ALL the public methods in the interface, is that a must ? pls post your opinion.
Regards
James
 
Scott Franklin
Greenhorn
Posts: 4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Well, for one thing the requirements say that you should
 
ravindra janapreddy
Ranch Hand
Posts: 84
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That's right as the specification says 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,
 
James Du
Ranch Hand
Posts: 186
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks you all.
But why in the earth sun specify that? it's out what kind of consideration ? do you think the specification is a little weird and those redundent methods is of no use?
 
Suresh Babu Seeram
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi James,
In Sun's Old assignment they haven't given db.db file.. and we have generate db.db file by using methods in the Data Class.
They have changed the assignment but they haven't changed the Data class.
[ June 24, 2002: Message edited by: Suresh Babu Seeram ]
 
Sai Prasad
Ranch Hand
Posts: 560
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by James Du:
But why in the earth sun specify that? it's out what kind of consideration ? do you think the specification is a little weird and those redundent methods is of no use?

My simple answer is that you need to do what it takes to pass the assignment and not dwell in to the quality of requirements by Sun.
 
James Du
Ranch Hand
Posts: 186
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Suresh,
i m very glad to have an idea of its origin.
thanks Sai.
i think i d better simply do what they required and dont think too much else.
James
 
cindy sung
Ranch Hand
Posts: 34
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
I know I should have all the public methods implemented in a client class. My question is:
if I want to book a ticket, which approach should I use:
1. call remoteData.lock()->remoteData.modify()->remoteData.unlock from client
2. implement a complete function 'book()' in RemoteData at server side, and call remoteData.book() from client. Then the lock and unlock methods implemented in the client class will not be invoked anywhere.
Thanks.
cindy
 
James Du
Ranch Hand
Posts: 186
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
the first approach eliminate the need to define 2 different book() methods in each side, it use a unified logic and code the logic
only at the client sides. if the logic need to be changed later, all need to do is to change the client-side code.The drawback is that since the logic has been breaken down into several seperate operations, it requires mutiple interactions between the client and the server, it in turn increases the traffic overhead. the second approach do it oppositely.
what do you think, Mark ?
James
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes James it does make more network traffic. But it really doesn't matter for this assignment. Because the Facade on the client side I think is the most elegant solution we can have for the assignment.
In the real world and with three tier you would limit your network traffic using some of j2ee design patterns, but that is beyond the requirements and can't be used.
I know I should have all the public methods implemented in a client class. My question is:
if I want to book a ticket, which approach should I use:
1. call remoteData.lock()->remoteData.modify()->remoteData.unlock from client
2. implement a complete function 'book()' in RemoteData at server side, and call remoteData.book() from client. Then the lock and unlock methods implemented in the client class will not be invoked anywhere.
Thanks.

try lock-->read-->modiy-->unlock.
Mark
 
James Du
Ranch Hand
Posts: 186
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In my design, i have a book methods in each side for i dont want to be considered of inconsiderate of the network traffic and dont want to lose points for it.
Mark, which approach do you choose?
As for Facade patten, i see many people talk of it but i have very little knowledge of it, what's the benefit of it in this assignment? could you please elaborate it?
thanks
James
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
A Facade basically wraps the complexity of a system, into a few ready to use methods for the user.
For instance, we know that Data has a certain number of methods. However the client is doing what. Searching, Booking, Getting Available Seats, and maybe filling in some JComboBoxes. So you would have a class that has an instance of your DataAccess class, and all the above methods only. Then the client/controller only have to call Book() to book a flight, or just Search() to do a search.
Think of the IO classes as Facades. It hides the complexity of the low level API's for handling IO, all you have to do is create a Stream and use it. You don't know anything about how it creates the stream ,the OS info and such. That is a Facade.
As far as book method, I only had it in my Facade, which is only on the client side.

Mark
 
James Du
Ranch Hand
Posts: 186
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Mark
According to the defination of the Facade you've given, I do have a Facade in my initial design, It is FBNBusiness and the class only provide the minimal necessary set of methods to the user. But afterwards when I reviewed my design i found it did not provide any substantial logic, just forward the command to the lower layer, say, RemoteDataAdapter or LocalDataApter, I think it brought in an extra layer and hurt the readability of the system so i discarded it.
Maybe the the Facade layer shows its value much in the extensiblity for the future rather than for now? and maybe the key idea in the pattern is to hide? and the idea of hide in turn is highly valued by graders?

Thanks
James
 
James Du
Ranch Hand
Posts: 186
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi, Mark, could give more comments please.
Thanks
James
 
Mark Spritzler
ranger
Sheriff
Posts: 17278
6
IntelliJ IDE Mac Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes James, it hides the complexity of the underlying classes. So say you have a GUI programmer, all he needs to know is the methods of the Facade. Which is really nice for the Junior GUI programmer.
You have lots of Facade classes in Java already. All the IO Stream classes are Facades. Can you tell me what is the underlying API calls that the Stream classes use to open the connection, read the binary, etc? No because all of that is hidden from you by the Stream class which is a Facade.
Hence the difference between lower level classes and higher level classes. Complexity.
Mark
 
James Du
Ranch Hand
Posts: 186
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Mark, i got it.
James
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic