• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

FBN Architecture Query

 
Ranch Hand
Posts: 94
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear friends,
I have a design in mind for the FlyByNight system. But would appreciate any feedback / opinions.
Create DataAccess interface, which defines all the public methods of Data. The interface also extends Remote; so all methods are changed to throw Exception.
Modify Data to implement DataAccess. Also the implementation of criteriaFind, lock, unlock etc will be in here. The reason for this is due to the requirement existing, that the remote client must implement all the public methods of Data. Because this has created the need for a DataAccess interface. I think that the DataAccess interface should now not become the master entity regarding data access, and Data should be changed to show that it is only 1 implementation of DataAccess.
Create RemoteData class that implements DataAccess. Not sure whether to extend Data or to just hold an instance of Data as a member, and delegate to this � I have read that as a rule, composition is better than inheritance
DataAccessFactory, depending on the connection mode, will return an implementation of DataAccess. Data if in local mode or RemoteData is in networked mode.
At the client end I am going to use a facade object that totally hides all Data / Network type code, and just presents business type methods, such as getFlights, makeReseration
Thanks a lot for any advice
 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If in local mode the factory returns the Data object, then the facades call to lock will lock the record in local mode, which isn't needed, since in local mode there is ever only one user.
But I wonder if that is a problem at all? I mean it won't hurt the database to actually lock the record in local mode, but on the other hand it is extra work that it doesn't have to do.
Other than that you design is very solid.
I always wonder if Data needs to implement the DataAccess interface, like you intend to do, or not. I did not have it implement the interface. For some reason I thought the Data class and the DataAccess interfaces where different. In that I was separating them. DataAccess interface extends Remote and throws Exception, well the throwing Exception won't have any affect, since all the exceptions thrown in the Data class would be more specific classes. But the Remote part is where I wonder. I mean the purpose of the Data class by itself is to provide Data services to the db.db file only. It does not have any responsibility to know or set up a mode(local or remote), which extending Remote does.
Now here's the catch, in my DataAccess interface I also extended Remote, so my implementation of LocalDataAccess would also be a Remote object, when it doesn't need to be, which is almost like above with Data implementing the DataAccess interface. Some people get around that by creating another interface for RemoteDataAccessInterface, and a LocalDataAccessInterface, and this allows only RemoteDataAccessInterface to extend Remote where LocalDataAccessInterface does not.
I hope I have cleared things up, more than just confuse myself.
Mark
So to answer your question again, I think you have a great design so far.
 
dean tomlinson
Ranch Hand
Posts: 94
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thanks a lot for your comments Mark. I just need some free time now so I can get on with the development.
 
author
Posts: 3252
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Mark, do realise you broke the contract for the Remote interface.
"Deanos", please review our naming policy and change your display name. Thanks.
- Peter
 
Mark Spritzler
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Mark, do realise you broke the contract for the Remote interface.


Where. In the DataAccess interface extending Remote?
Thanks Peter, and welcome back to the SCJD Forum.
Mark
 
Peter den Haan
author
Posts: 3252
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Mark, thanks for the welcome And forget what I said above -- neither your interface nor its implementations break the Remote contract or anything else.
For some reason, I thought that RMI would always try to pass instanceof Remote objects by reference. This is not true. It will pass all objects by value (serialization) unless they have been exported by calling UnicastRemoteObject.exportObject(). Doh.
- Peter
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic