On Friday 11 October 2002 07:49 pm, Henri Yandell wrote: > On Fri, 11 Oct 2002, Steve Downey wrote: > > > 2) Mutable primitive classes. Pondered this at the hospital today. Do > > > we want such things? new MutableInteger(); mi.setValue(42); etc. Same > > > for MutableString. > > > > I'm not so sure about Mutable value classes. I'd want to see a use case > > for them first. IOW, what does it gain over this.value = new Integer(42)? > > If there's shared mutable state, I think it's usually within the same > > class. I don't see the utility of a mutable Integer that's shared between > > unrelated classes. And within the same class, I'd think just using > > members is more natural. > > Yeah, my reaction was to think no. But then I decided that discussion on > it would be very interesting :) > I figured out what they are for. Let's say you have something observing a String, for display or whatever. If the value changes, you want the new value displayed. The entity doing the display shouldn't care what the String represents. So if it has a MutableString, and registers for notifications of changes of the MutableString, it can update whenever the String changes.
They're kind of like Delegates for properties. What do you think? -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>
