Designing for protocol independence

K

Karsten Wutzke

Hello!

I'm currently developing a chat client. I want to design the software
for protocol independence. It ought to be a very simple design, I
don't want to create a general purpose protocol (framework). The
protocol consists mainly of textual data to be put on and read from
the socket In/OutputStream's. For the client to use the software, it
should not be visible, whether the user's chat is running via server X
with protocol X or it runs on server Y using protocol Y. In any case,
the server (or IP range) is expected to know only one protocol.

Maybe there's a simple pattern for it? Maybe something more trivial
(simple subclassing)?

Can you share your experience how I might proceed?

Thanks
Karsten
 
R

Roedy Green

I'm currently developing a chat client. I want to design the software
for protocol independence.

You might have a look at how Sun does things like allow vendors to
plug in JCE implementations, or JDBC drivers.
 
L

Lasse Reichstein Nielsen

Karsten Wutzke said:
Maybe there's a simple pattern for it? Maybe something more trivial
(simple subclassing)?

Yep. Find the best division between the code that is protocol
independent and the code that implements the protocol. Make good
interfaces exposing only the logical operations you need (e.g.,
"send message") in a protocol agnostic way.

Then implement the interface once for each protocol you want
to use.

You'll then need some business logic to select the protocol when
you need it. That might be using the Strategy pattern.

/L
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,982
Messages
2,570,186
Members
46,744
Latest member
CortneyMcK

Latest Threads

Top