Hi Petr,
thanks for the links! Now I see that there was a misunderstanding from my side over my “understanding” of reference objects. So, I’ve read some of the posts in the articles and I must admit that it seems to me much more complicated then I actually thought for the first time. I think I’ll need to study it more deeply.
I was actually planning to write a post on the topic - would have avoided the confusion :-).
Changing packets during theire xistence doesn’t make much sense (so they would be immutable) and they can be treated as strings (just an example).
That was something I was thinking about… We currently have situations in Gnutella’s PacketProcessor and similar classes where the packets are modified. For example, before forwarding a Gnutella packet its hops has to be increased and its ttl decreased. One option will be that we modify the object itself, another would be that the setters return a new object (as suggested in one of the linked articles). I’m not certain which one is better… For class Torrent you made a perfect point why its objects should be immutable but we would need to manipulate packets as part of our packet processing… Comments and ideas are welcome!
Best regards,
Peter
