Monday, June 11, 2012

Re: Having domain objects implement EntityProxy - bad idea?

I can't see any reason it wouldn't work, but I think you'd rather extract an interface, implemented by your domain object, and extended by your proxy (in addition to EntityProxy).

interface Domain { /* getters and setters */ }

class DomainImpl implements Domain { … }

interface DomainProxy extends Domain, EntityProxy { … }

In case you were wondering, this approach has been proven to work.
One exception is currently if your Domain interface references another interface (as opposed to "simple value types"), where you'd face http://code.google.com/p/google-web-toolkit/issues/detail?id=5926
This issue will be fixed in GWT 2.5.1, which we expect to release by the end of the summer.

On Monday, June 11, 2012 9:35:02 PM UTC+2, Ryan McFall wrote:
One of the things I don't like about the design of the RequestFactory
is the fact that client-side proxies need to extend EntityProxy; I
think I understand why this is needed, but it makes it more difficult
to write code that can operate on both proxies and actual domain
objects.

One way of getting around this is to have the domain objects implement
the proxy interface.  This means that the domain objects must
implement EntityProxy, giving a stableId method that shouldn't
actually be called, but allows utility code to treat proxies and
domain objects in the same way.

Before going down this route, I'm wondering if there are reasons it
won't work that I haven't thought about.

Thanks!
Ryan

On Monday, June 11, 2012 9:35:02 PM UTC+2, Ryan McFall wrote:
One of the things I don't like about the design of the RequestFactory
is the fact that client-side proxies need to extend EntityProxy; I
think I understand why this is needed, but it makes it more difficult
to write code that can operate on both proxies and actual domain
objects.

One way of getting around this is to have the domain objects implement
the proxy interface.  This means that the domain objects must
implement EntityProxy, giving a stableId method that shouldn't
actually be called, but allows utility code to treat proxies and
domain objects in the same way.

Before going down this route, I'm wondering if there are reasons it
won't work that I haven't thought about.

Thanks!
Ryan

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To view this discussion on the web visit https://groups.google.com/d/msg/google-web-toolkit/-/cli1V_TJFYUJ.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate