Re: add a single byte to byte()
On 2004-09-10, Cor Ligthert <notfirstname@p lanet.nl> wrote:[color=blue]
> David,
>[color=green]
>> Aren't you the one who constantly posts the 80/20 rule here, or am I
>> confusing you with somebody else?[/color]
>
> And the other one in other words is me. I am the one who uses almost the
> arraylist in samples for everything while others point mostly than too the
> hashtable, (where I use than when it is needed earlier the sortedlist).
>
> When it is about a byte array, than there should be a reason why it is a
> byte array, because it is in my opinion an archaic piece of storage, altough
> very good for serializing and deserializing. For those you loads the
> bytearray streaming and you do not need to set a byte by byte to an array.
>
> You can see in this thread a message from me which describes a bytearray
> with ASCI chareacter, however for what I would directly use an arraylist
> when it was really needed to get the full unicode in a char. (Although I
> really cannot find a reason for that)
>
> In my idea in this case when there is really a bytearray needed, than we
> should never go to the arraylist, because than the one who does that has
> never investigated his problem. Because the byte is the value type you take
> as last to choose from when it is not streaming.[/color]
OK, I'm honestly not sure if I'm understanding this correctly, but...
I don't see your reasoning here, largely because you don't seem to have
any. The issue is that you need to accumulate bytes, regardless of
where they're coming from (so streaming or not isn't really relevant).
Why do you think an arraylist shouldn't be used for accumulation here?
You state this as an absolute ("one who does that has never
investigated"), but never say why. If it's the performance issue, I'd
suggest that your concerns are misplaced, since it's highly unlikely the
performance hit is going to be noticeable.
[color=blue]
> However when it should be a bytearray and you do not know the size however
> know that the maximum is 400bytes, than you should not even redim it.
> Probably you will loose with the code to redim more bytes than what you can
> earn with that.[/color]
OK, now that I understand, and disagree with completely. Passing around
an incomplete array, one whose length is not the same as the number of
valid entries, is a recipe for disaster. Sure, you'll remember what's
going on while you write this code, but six months later it's incredibly
easy to forget that you've got some other variable someplace telling you
what the "real length" of the array is.
This is the sort of premature optimization that the 80/20 rule is meant
to address. This suggested "fix" would greatly harm readability, and
add to performance only slightly, and I'd profile the hell out of an app
before I went that direction.
On 2004-09-10, Cor Ligthert <notfirstname@p lanet.nl> wrote:[color=blue]
> David,
>[color=green]
>> Aren't you the one who constantly posts the 80/20 rule here, or am I
>> confusing you with somebody else?[/color]
>
> And the other one in other words is me. I am the one who uses almost the
> arraylist in samples for everything while others point mostly than too the
> hashtable, (where I use than when it is needed earlier the sortedlist).
>
> When it is about a byte array, than there should be a reason why it is a
> byte array, because it is in my opinion an archaic piece of storage, altough
> very good for serializing and deserializing. For those you loads the
> bytearray streaming and you do not need to set a byte by byte to an array.
>
> You can see in this thread a message from me which describes a bytearray
> with ASCI chareacter, however for what I would directly use an arraylist
> when it was really needed to get the full unicode in a char. (Although I
> really cannot find a reason for that)
>
> In my idea in this case when there is really a bytearray needed, than we
> should never go to the arraylist, because than the one who does that has
> never investigated his problem. Because the byte is the value type you take
> as last to choose from when it is not streaming.[/color]
OK, I'm honestly not sure if I'm understanding this correctly, but...
I don't see your reasoning here, largely because you don't seem to have
any. The issue is that you need to accumulate bytes, regardless of
where they're coming from (so streaming or not isn't really relevant).
Why do you think an arraylist shouldn't be used for accumulation here?
You state this as an absolute ("one who does that has never
investigated"), but never say why. If it's the performance issue, I'd
suggest that your concerns are misplaced, since it's highly unlikely the
performance hit is going to be noticeable.
[color=blue]
> However when it should be a bytearray and you do not know the size however
> know that the maximum is 400bytes, than you should not even redim it.
> Probably you will loose with the code to redim more bytes than what you can
> earn with that.[/color]
OK, now that I understand, and disagree with completely. Passing around
an incomplete array, one whose length is not the same as the number of
valid entries, is a recipe for disaster. Sure, you'll remember what's
going on while you write this code, but six months later it's incredibly
easy to forget that you've got some other variable someplace telling you
what the "real length" of the array is.
This is the sort of premature optimization that the 80/20 rule is meant
to address. This suggested "fix" would greatly harm readability, and
add to performance only slightly, and I'd profile the hell out of an app
before I went that direction.
Comment