Question about rationale for java.nio.Buffer design.

H

Harald Kirsch

Hi,

asked to write a buffer implementation, I would
go for an array a read pointer and a write pointer
and would just wrap them around at the end of the
array, making sure that they don't overtake each
other.

Writing and reading would be possible at any time
if the buffer is not full or resp. empty.

Compare this with the tedious and confusing
(my opinion) interface of java.nio.Buffer design:

When you want to write to the buffer, do you first
do a flip(), clear() or rewind() or do you first
scratch your head and wonder which one now?

Does remaining() tell you how much room there is or
how much data is available?

Can anyone give me some reason why they choose this
buffer interface and implementation? It probably
would help me to understand when to do what.

Thanks,
Harald.
 

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

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,014
Latest member
BiancaFix3

Latest Threads

Top