On Mon, Dec 1, 2008 at 3:12 PM, Ray Ryan <[EMAIL PROTECTED]> wrote:
> On Mon, Dec 1, 2008 at 3:02 PM, Ian Petersen <[EMAIL PROTECTED]> wrote:
>> First, I think there should be two interfaces, one that only supports
>> getValue(), and another that inherits from the first and adds
>> setValue(T). I'll let someone else bikeshed over whether HasValue
>> should be the ancestor or descendant. The benefit here is that you
>> can plug into the HasValue architecture without being forced into the
>> corner of supporting arbitrary updates to your data.
>
> There is no HasValue architecture, nor is one expected.
"HasValue architecture" was hand-wavy technobabble. What I meant was,
I'd like to be able to design a Foo that manipulates things that
implement HasValue. My Foo needs to getValue(), but it doesn't need
to setValue(T). Separating the interfaces makes my my Foo more useful
because other people can build arbitrary HasValue implementations
without having to worry about implementing setValue(T).
For a completely contrived example, you could imagine DatePicker
looking like this:
public class DatePicker implements HasSettableValue<Date> {
public Date getValue() {
// return current date
}
public void setValue(Date newDate) {
// update internal state
}
// by returning HasValue instead of HasSettableValue
// you avoid the thorny issue of updating the enclosing
// DatePicker's current date when the caller invokes
// setValue(4) on the returned object
public HasValue<Integer> getDayOfWeekObserver() {
return new HasValue<Integer> {
public Integer getValue() {
// return day of week as computed from enclosing DatePicker's
current date
}
}
}
My point is not whether a day-of-week observer is a useful extension
to DatePicker, but rather that HasValue and HasSettableValue is a
useful separation. I'd also be in favour of HasValue implying
SourcesValueChanged, but I'm a little divorced from the code these
days, so I'm not sure if it's worth the extra complexity.
Ian
--~--~---------~--~----~------------~-------~--~----~
http://groups.google.com/group/Google-Web-Toolkit-Contributors
-~----------~----~----~----~------~----~------~--~---