This week's book giveaway is in the JavaFX forum.
We're giving away four copies of Introducing JavaFX 8 Programming and have Herbert Schildt on-line!
See this thread for details.
The moose likes Developer Certification (SCJD/OCMJD) and the fly likes Connection Design Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Introducing JavaFX 8 Programming this week in the JavaFX forum!
JavaRanch » Java Forums » Certification » Developer Certification (SCJD/OCMJD)
Bookmark "Connection Design" Watch "Connection Design" New topic

Connection Design

Brian Blignaut
Ranch Hand

Joined: Jan 08, 2003
Posts: 61
My design is as follows :
On the client side I have the following
Connection - Interface which defines all the methods of the data class.
RemoteConnection - Implements Connection and provides remote data access
LocalConenction - Implements Connection and provides local data access.
On the server side I have the following
RemoteConnectionFactory - Interface for a factory that creates connections
RemoteConnectionFactoryImp - Implements RemoteConnectionFactory and creates connections
ClientConnection - Interface which defines all the methods of the data class.
ClientConnectionImp - Implements the ClientConnection interface. Each client that connects will receive it's own instance of this class

My question is, should the ClientConnection interface extend the Connection interface instead of defining it's own methods, this way I could get rid of the RemoteConnection class
Any suggestions would be greatly appreciated
Brian Blignaut
Ranch Hand

Joined: Jan 08, 2003
Posts: 61
Max Habibi
town drunk
( and author)

Joined: Jun 27, 2002
Posts: 4118
Hi Brian,
How does a local client get a connection? Does your GUI have to be smart enough to know that it's using a local connection, or do you want provide a general Connection Factory: one that decides if it, in turn, needs a LocalConnection or a RemoteConnection? I'm not suggesting that one way or another is correct: I'd just like to hear your approach.
All best,
M, author
The Sun Certified Java Developer Exam with J2SE 1.4

Java Regular Expressions
Brian Blignaut
Ranch Hand

Joined: Jan 08, 2003
Posts: 61
The user would select what type of connection they wish to establish. And yes, I do have a connection factory is responsible for creating the actual connection.
Brian Blignaut
Ranch Hand

Joined: Jan 08, 2003
Posts: 61
Sorry to answer the other question, the the GUI does not need to have any concept of what type of connection it is working with, that is totally transparent, all the GUI knows is that it has a connection (Connection Interface)
Qusay Jaafar
Ranch Hand

Joined: May 06, 2002
Posts: 127
In my design, using MVC in GUI. Controller connects to Abstract Factory pattern which returns ConnectionFactory (Local or Remote). LocalConnection class connects to DataAdapter class which connects to Data class. RemoteConnection class connects to RMI using proxy and adapter pattern.
I didn't finish yet from coding but I think the design is alright.
I read your book. A beautiful design there. Although Nobody lost points for not implementing ClientID, I will use ClientID in my design, that's why I used Abstract Factory, proxy and adapter patterns. I think you know many members takling about unlock() method documentaiton, so it is a chance to learn something here.

I agree. Here's the link:
subject: Connection Design
It's not a secret anymore!