Monday, October 27, 2014

Re: Modify the property of an object via Deferred Binding

Sure, thats one way to do it and I know that is the pattern in most uses of the rebinder mechanism, but to me, it almost seems to be an anti-pattern that is neglecting the power that exists under the hood.  The reason is that you aren't really creating a new implementation of the logic, so i feel that having to create a class to set a property is a bit redundant/ridiculous.

I could see if you programmatically caused the object to be replaced and GWT did not provide for any kind of property configuration already that having it done all in code would be sound a sound process.  However, gwt provides facilities for setting compiler and configuration properties that could be leveraged and seeing as you have to maintain the rebinding and the class that overrides the properties and the class that is the actual implementation, I think the simplification is to allow setting properties of rebound objects through the rebind process.  Then you only have to maintain the .gwt.xml where the rebind occurs, then the interface, then 1..x implementations of logic instead of y * (1...x) implementations of logic -> property configurations.  It would also make rebound classes more reusable in that if both you and I wanted to set the property on a rebound object, we both wouldn't have to override the class in the same manner in order to do so.


Jonathon Lamon
Principle Software Engineer
Perceptronics Solutions Inc.
Tel  703-485-2922
Cell 269-205-4649
www.percsolutions.com

On Mon, Oct 27, 2014 at 10:36 AM, Jens <jens.nehlmeier@gmail.com> wrote:
It would be awesome if the gwt compiler would support something along these lines:

<replace-with class="com.my.FavoriteImplementation">
<when-type-is class="com.SomeInterface"/>
                <set-object-property type="boolean" value="false" name="turnFeatureOn"/>
                <set-object-property type="string" value="MyPrimaryStyle" name="defaultStyle"/>
                <set-object-property name="complexProperty" provider="com.my.ComplexPropertyProvider"/>
</replace-with>

This might actually reduce the need for custom generators and make customization via GWT.create a bit more powerful.

What about:


public abstract class AbstractImplementation implements SomeInterface {

  public AbstractImplementation(boolean turnFeatureOn, String defaultStyle, ComplexProperty complexProperty) {
     // store as fields
  }


public class FavoriteImplementation extends AbstractImplementation {
  
  public FavoriteImplementation() {
    super(false, "MyPrimaryStyle", new DefaultComplexProperty);
  }

}

public class SometimesDifferentImplementation extends AbstractImplementation {
  
  public FavoriteImplementation() {
    super(true, "MySecondaryStyle", new CustomComplexProperty);
  }

}

<replace-with class="com.my.FavoriteImplementation">
  <when-type-is class="com.SomeInterface"/>
</replace-with>

<replace-with class="com.my.SometimesDifferentImplementation">
  <when-type-is class="com.SomeInterface"/>
  <when-property-is name="sometimes" value="different" />
</replace-with>



-- J.

--
You received this message because you are subscribed to a topic in the Google Groups "Google Web Toolkit" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/google-web-toolkit/_MBUHniKSI8/unsubscribe.
To unsubscribe from this group and all its topics, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment