1 big string or lots of little strings.which is the best way?

hey,

I would like to know if theres a big difference when sending data across a network.
Suppose i have a list of data packaged as a string e.g(“string1/string2/string3/string4”)
on my server end i unpack the string e.g first string i treat as string load into variable the second i parse as an int…etc etc

is it better to do this

out.println(string1);
out.print etc etc

and on server end

in.readline(etc etc)
in.readline

loading the data into variables as i read them.

I actually use both ways but wanted to know if theres any major difference peformance wise ?
Thanks in advance

All depends on the underlying schematics.

depending on if stuff is buffered, flush strategy and package size protocol etc. depending on the factors they could be as fast or one or the other could be faster in specific cases.

You want to pass stuff to your lower layers in such a way that the lower layer can figure out the best strategy on it’s own. (adleast that sounds very java-like to me)

In a general simplified world; small as-soon-as-possible data handoff is good for latency. Aggregated stuff good for bandwidth utilisation. Considering the former can be turned into the latter by buffering i’d use a api/interface that allows for the former and simply swap implementations or trigger strategies as needed.

Now while the above is great and correct it might not be what your looking for, so in an attempt to be helpful: set targets/goal and profile your application as needed should you not ‘normally’ reach them. Don’t worry about it earlier… and apply normal software developing practices to ensure the process of implementing solutions doesn’t get tedious.

Thanks that was what i needed to know and thats exactly how i have implemented my strategy.