On Mon, Feb 28, 2011 at 10:30 AM, Jeff Larsen <larse...@gmail.com> wrote:
>
> By forcing the user to do
>
> new DefaultAppearance(Resource)
>
> you're removing their ability to globally change the appearance. You've now
> introduced a much tighter coupling than was there previously. As a for
> instance, lets say I wanted different button styles, I go ahead and extend
> the ClientBundle and apply then everything gets styled to my liking.
> Now lets say there is some html5 new button hotness that we want to have
> access to, or we need to add different Aria support etc. I can swap out the
> Appearance class globally with deferred binding by keeping both constructors
> in its current form. By getting rid of the constructor, I have to find every
> instance of my classes and change them programmatically to not use
> DefaultAppearance, but the new appearance. Now I'm good and I'm in a even
> more difficult refactor if I need to change the appearance based on
> locale/browser etc.

In its current form, I don't think the constructor accepting a
CssResource lets GWT swap the default appearance without impacting the
user's code that relies on it. Let's look at your proposed
implementation for the constructor in question:
  // Replace the styles used by this cell instance.
  public ButtonCell(DefaultAppearance.Resources resources) {
    this(new DefaultAppearance(resources));
  }

This constructor is not using deferred binding. Therefore, if you want
user's code relying on it to switch to the new appearance you have to
roll-out a new implementation of the constructor. Let's say you do
that:
  // Replace the styles used by this cell instance.
  public ButtonCell(DefaultAppearance.Resources resources) {
    this(new NewDefaultAppearance(resources));
  }

The problem, here, is that you are passing DefaultAppearance.Resources
to NewDefaultAppearance. It means that your new appearance
implementation cannot use CSS classes that did not exist in the
original CssResource. In fact, in the current implementation, the
CssResource is defined by the Appearance _implementation_ (it's
DefaultAppearance.Resource, not Appearance.Resource).

The confusion therefore is:
a) Will ButtonCell(DefaultAppearance.Resources resources) update its
appearance automatically when GWT upgrades to a new default
appearance; OR
b) Will it bind me forever to DefaultAppearance?
My proposition of dropping it was assuming you wanted to go with (b),
now I understand that you want the behavior of (a) -- which I agree is
much preferable -- but the current design does not seem to allow for
that goal. Maybe we should discuss ways to decouple the CssResource
from the Appearance implementations instead?

Also: I agree with the rest of your post and your reasoning.

-- 
http://groups.google.com/group/Google-Web-Toolkit-Contributors

Reply via email to