• Post Reply Bookmark Topic Watch Topic
  • New Topic

Writing client-server code more smoothly  RSS feed

 
martin ramboäpple
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Im having sort of an issue when creating client-server applications.
When doing so, I always sit and have both sourcecodes next to eachother.
Then for example, I tell the client to send a message. Then I switch to the server's code and code in a receivement.

is there a way to get around this, not needing to programming it this way?
It takes time and moere importantly creates quite often buggy code.

Ive looked a litte bit into having a input- and output-stream running on separate threads in both the client and server application.
It works fine when working with text, with files and so on Im not sure.

Anyhow; is there a more general solution to these kind of problems? A designpattern maybe?

(Btw, tried google for solution to this matter, since its unlikely a unique problem, but don't know what to really search for!)

Cheers // martin
 
Jelle Klap
Bartender
Posts: 1952
7
Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How about working out a communication protocol first and then either start developing the server with a suitable client test double, or vice versa.
 
martin ramboäpple
Greenhorn
Posts: 12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jelle Klap wrote:How about working out a communication protocol first and then either start developing the server with a suitable client test double, or vice versa.


Hello,

Yeah, I forgot to mention; I have thought about protocols as well. Hmm let me google a little.

Ok, I found a tutorial about this, Ill check it out.

Thanks
 
William Brogden
Author and all-around good cowpoke
Rancher
Posts: 13078
6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I think you are working way too close to the details without a big picture!

Look into Use Case Diagrams - If you can create a complete set of use cases then where each client and server method fit should become obvious.

We used to call this the "10,000 foot view"

Bill
 
Campbell Ritchie
Marshal
Posts: 56592
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And welcome to the Ranch
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16060
88
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When you develop the client code and the server code, you should write unit tests for each of them, so that you can test your client and server code independently from each other.

The de-facto tool for unit testing in Java is JUnit.

Another advantage of having automatic unit tests is that when you or someone else later makes changes to the code, you can quickly find out if they have not broken any existing functionality by just running the unit tests again.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!