byte[] buff = new byte[8192];
byte[] buff = new byte[SOME_BUFFER_LENGTH];
Monique Y. Mudama said:
Seems like you're dodging the issue here by giving a poor example.
The fact is that you must have chosen 8192 for a reason, and that
reason can be documented with a well-chosen variable name.
Nah, I don't see that that's necessarily the case. When choosing
buffer sizes, it's generally a matter of taking a guess. Usually,
the guess is a power of two, because it works better with MMU/paging
architectures where memory is typically allocated in pages of a
power of two in size. Tuning can be done later if it becomes a
performance problem of some kind. If there's some other kind of
ultimate method of calculating ideal buffer sizes, then most of us
haven't yet been informed.
I typically choose buffers of size 32768 unless I have some reason
not to. Obviously, Thomas Hawtin commonly uses 8192. Why? No
particular reason. If it starts mattering in a measurable way, then
I'm sure they'll get tuned, and then a comment will be added
explaining the method used to choose the buffer size and the
observed consequences of making it too large/small.
In any case, even if the buffer size is carefully tuned, I very much
doubt that you could explain the method or logic behind the choice
in a reasonable identifier name.