You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@myfaces.apache.org by Andy Schwartz <an...@gmail.com> on 2011/03/09 21:55:46 UTC

[Trinidad] ChangeManagerWrapper API

Gang -

I would like to add a new base class for ChangeManager wrapper classes
to extend as discussed here:

https://issues.apache.org/jira/browse/TRINIDAD-2055

I have attached an implementation to the issue:

https://issues.apache.org/jira/secure/attachment/12473198/ChangeManagerWrapper.java

Fairly simple stuff, but would appreciate if someone could review.

On a related note...

As a new committer, I am a bit fuzzy on what the process is for
introducing new APIs. My guess is that any significant APIs require
discussion/community approval (maybe even a vote?).  Is the same true
of simple/small APIs like this?  (If there is documentation on this
that I need to read, please let me know!)

Thanks,
Andy

Re: [Trinidad] ChangeManagerWrapper API

Posted by Scott O'Bryan <da...@gmail.com>.
+1

On Mar 10, 2011, at 4:05 PM, Pavitra Subramaniam
<pa...@oracle.com> wrote:

> +1 for the current approach :).
>
> Pavitra
>
> On 3/10/2011 2:34 PM, Andy Schwartz wrote:
>> I am thinking that I will roll with my current approach since we can
>> always transparently implement FacesWrapper later if we decide that
>> this is an important thing to do.  If anyone thinks that it is
>> important to do this now, please let me know!
>>
>> Thanks,
>> Andy
>>

Re: [Trinidad] ChangeManagerWrapper API

Posted by Pavitra Subramaniam <pa...@oracle.com>.
+1 for the current approach :).

Pavitra

On 3/10/2011 2:34 PM, Andy Schwartz wrote:
> I am thinking that I will roll with my current approach since we can
> always transparently implement FacesWrapper later if we decide that
> this is an important thing to do.  If anyone thinks that it is
> important to do this now, please let me know!
>
> Thanks,
> Andy
>    

Re: [Trinidad] ChangeManagerWrapper API

Posted by Andy Schwartz <an...@gmail.com>.
I am thinking that I will roll with my current approach since we can
always transparently implement FacesWrapper later if we decide that
this is an important thing to do.  If anyone thinks that it is
important to do this now, please let me know!

Thanks,
Andy

Re: [Trinidad] ChangeManagerWrapper API

Posted by Blake Sullivan <bl...@oracle.com>.
The names can't be the same because if we implemented the Wrapper 
interface, the new method would have to be public, however if someone 
had subclassed the protected method, keeping it protected, that change 
would break their code because you can't subclass a method and reduce 
its visibility.

-- Blake Sullivan

On 3/10/11 12:20 PM, Scott O'Bryan wrote:
> I suppose I don't mind the currently implementation but I'm not sure I 
> understand Point #2.  Adding an interface does not change binary 
> backward compatibility does it?  Likewise, having a public 
> getWrapped() method wouldn't have any conflicts if the interface was 
> applied later.
>
> From a "pretty code" POV, I like the idea of wrappers being 
> implemented in a consistent fashion.  Takes away a lot of confusion.  
> In the end though, Trinidad has a lot of wrappers which are already 
> implemented in different ways.  What's one more going to hurt.. :D
>
> Scott
>
> On 03/10/2011 11:37 AM, Andy Schwartz wrote:
>> Thanks for the review Pavitra.  I too was debating whether to follow
>> the FacesWrapper approach.  In the end I leaned towards keeping the
>> get*Wrapper method protected, since I couldn't think of any non-hacky
>> reason for exposing this publicly.
>>
>> On Wed, Mar 9, 2011 at 6:13 PM, Blake Sullivan
>> <bl...@oracle.com>  wrote:
>>> 1) Is because there is currently no good reason for developers to 
>>> burrow
>>> into the ChangeManager implementations
>> Right.
>>
>>> 2) Is because if we did come up with a good reason to implement
>>> FacesWrapper<T>, we need to be able to do so in a backwards compatible
>>> manner
>> Exactly.  My initial implementation contained a protected getWrapped()
>> method, though I ended up picking a different name for this protected
>> hook since I wanted to leave open the possibility of implementing
>> FacesWrapper (and exposing a public getWrapped() method) in the future
>> should the need arise.
>>
>> Andy
>


Re: [Trinidad] ChangeManagerWrapper API

Posted by Scott O'Bryan <da...@gmail.com>.
I suppose I don't mind the currently implementation but I'm not sure I 
understand Point #2.  Adding an interface does not change binary 
backward compatibility does it?  Likewise, having a public getWrapped() 
method wouldn't have any conflicts if the interface was applied later.

 From a "pretty code" POV, I like the idea of wrappers being implemented 
in a consistent fashion.  Takes away a lot of confusion.  In the end 
though, Trinidad has a lot of wrappers which are already implemented in 
different ways.  What's one more going to hurt.. :D

Scott

On 03/10/2011 11:37 AM, Andy Schwartz wrote:
> Thanks for the review Pavitra.  I too was debating whether to follow
> the FacesWrapper approach.  In the end I leaned towards keeping the
> get*Wrapper method protected, since I couldn't think of any non-hacky
> reason for exposing this publicly.
>
> On Wed, Mar 9, 2011 at 6:13 PM, Blake Sullivan
> <bl...@oracle.com>  wrote:
>> 1) Is because there is currently no good reason for developers to burrow
>> into the ChangeManager implementations
> Right.
>
>> 2) Is because if we did come up with a good reason to implement
>> FacesWrapper<T>, we need to be able to do so in a backwards compatible
>> manner
> Exactly.  My initial implementation contained a protected getWrapped()
> method, though I ended up picking a different name for this protected
> hook since I wanted to leave open the possibility of implementing
> FacesWrapper (and exposing a public getWrapped() method) in the future
> should the need arise.
>
> Andy


Re: [Trinidad] ChangeManagerWrapper API

Posted by Andy Schwartz <an...@gmail.com>.
Thanks for the review Pavitra.  I too was debating whether to follow
the FacesWrapper approach.  In the end I leaned towards keeping the
get*Wrapper method protected, since I couldn't think of any non-hacky
reason for exposing this publicly.

On Wed, Mar 9, 2011 at 6:13 PM, Blake Sullivan
<bl...@oracle.com> wrote:
> 1) Is because there is currently no good reason for developers to burrow
> into the ChangeManager implementations

Right.

> 2) Is because if we did come up with a good reason to implement
> FacesWrapper<T>, we need to be able to do so in a backwards compatible
> manner

Exactly.  My initial implementation contained a protected getWrapped()
method, though I ended up picking a different name for this protected
hook since I wanted to leave open the possibility of implementing
FacesWrapper (and exposing a public getWrapped() method) in the future
should the need arise.

Andy

Re: [Trinidad] ChangeManagerWrapper API

Posted by Blake Sullivan <bl...@oracle.com>.
1) Is because there is currently no good reason for developers to burrow 
into the ChangeManager implementations
2) Is because if we did come up with a good reason to implement 
FacesWrapper<T>, we need to be able to do so in a backwards compatible 
manner

-- Blake Sullivan

On 3/9/11 3:09 PM, Pavitra Subramaniam wrote:
> Hello Andy,
>
> Just minor comments.
>
> 1. Can ChangeManagerWrapper implement the FacesWrapper<T> interface?
> 2. I would just call the delegate getter "getWrapped()" instead of 
> getWrappedChangeManager() if we don't use 1 or a similar variant. wdyt?
>
> Thanks
> Pavitra
>
> On 3/9/2011 12:55 PM, Andy Schwartz wrote:
>> Gang -
>>
>> I would like to add a new base class for ChangeManager wrapper classes
>> to extend as discussed here:
>>
>> https://issues.apache.org/jira/browse/TRINIDAD-2055
>>
>> I have attached an implementation to the issue:
>>
>> https://issues.apache.org/jira/secure/attachment/12473198/ChangeManagerWrapper.java 
>>
>>
>> Fairly simple stuff, but would appreciate if someone could review.
>>
>> On a related note...
>>
>> As a new committer, I am a bit fuzzy on what the process is for
>> introducing new APIs. My guess is that any significant APIs require
>> discussion/community approval (maybe even a vote?).  Is the same true
>> of simple/small APIs like this?  (If there is documentation on this
>> that I need to read, please let me know!)
>>
>> Thanks,
>> Andy


Re: [Trinidad] ChangeManagerWrapper API

Posted by Pavitra Subramaniam <pa...@oracle.com>.
Hello Andy,

Just minor comments.

1. Can ChangeManagerWrapper implement the FacesWrapper<T> interface?
2. I would just call the delegate getter "getWrapped()" instead of 
getWrappedChangeManager() if we don't use 1 or a similar variant. wdyt?

Thanks
Pavitra

On 3/9/2011 12:55 PM, Andy Schwartz wrote:
> Gang -
>
> I would like to add a new base class for ChangeManager wrapper classes
> to extend as discussed here:
>
> https://issues.apache.org/jira/browse/TRINIDAD-2055
>
> I have attached an implementation to the issue:
>
> https://issues.apache.org/jira/secure/attachment/12473198/ChangeManagerWrapper.java
>
> Fairly simple stuff, but would appreciate if someone could review.
>
> On a related note...
>
> As a new committer, I am a bit fuzzy on what the process is for
> introducing new APIs. My guess is that any significant APIs require
> discussion/community approval (maybe even a vote?).  Is the same true
> of simple/small APIs like this?  (If there is documentation on this
> that I need to read, please let me know!)
>
> Thanks,
> Andy
>    

Re: [Trinidad] ChangeManagerWrapper API

Posted by Prakash Udupa <pr...@oracle.com>.
Yes, the wrapper base is very common pattern.
Thanks for explaining, makes sense to me now, given that we will end up with least impact on delegating implementations 
like yours, when we add a 'contract' method to ChangeManager.

Thanks,
Prakash

On 3/10/2011 9:51 AM, Andy Schwartz wrote:
> Hi Prakash -
>
> On Wed, Mar 9, 2011 at 6:56 PM, Prakash Udupa<pr...@oracle.com>  wrote:
>> How does the wrapper help any more?.
> Let's take a closer look at the use case that I am hoping to address...
>
> I want to write a ChangeManager implementation that:
>
> 1.  Delegates all of the real work to some other ChangeManager.
> 2.  Examines ComponentChanges as they are added and drops certain
> changes that I do not want to save.
>
> I can do this today by writing my own wrapper class that extends
> ChangeManager directly and provides delegating implementations of all
> of the ChangeManager methods.
>
> However, if we later add some new method to the ChangeManager contract
> (as we did with applySimpleComponentChanges()), my wrapper class would
> need to be updated - ie. I would need to add yet another delegating
> method implementation for the new API.  This is annoying and fragile.
>
> On the other hand, if we introduce a base wrapper class in Trinidad,
> my concrete wrapper subclass is not impacted by new additions to the
> ChangeManager API.  Any time we add a new method to the ChangeManager,
> we would add an equivalent implementation to the ChangeManagerWrapper
> base class.  In addition to reducing the amount of work to implement a
> ChangeManager wrapper class (no longer need to re-implement every
> ChangeManager method), we have significantly reduced the risk of
> breaking such classes as the API evolves.
>
> FWIW, this approach of providing a base wrapper class is a very common
> pattern.  (As Pavitra hinted at this, is used all over the place in
> JSF.)
>
> Andy

Re: [Trinidad] ChangeManagerWrapper API

Posted by Andy Schwartz <an...@gmail.com>.
Hi Prakash -

On Wed, Mar 9, 2011 at 6:56 PM, Prakash Udupa <pr...@oracle.com> wrote:
> How does the wrapper help any more?.

Let's take a closer look at the use case that I am hoping to address...

I want to write a ChangeManager implementation that:

1.  Delegates all of the real work to some other ChangeManager.
2.  Examines ComponentChanges as they are added and drops certain
changes that I do not want to save.

I can do this today by writing my own wrapper class that extends
ChangeManager directly and provides delegating implementations of all
of the ChangeManager methods.

However, if we later add some new method to the ChangeManager contract
(as we did with applySimpleComponentChanges()), my wrapper class would
need to be updated - ie. I would need to add yet another delegating
method implementation for the new API.  This is annoying and fragile.

On the other hand, if we introduce a base wrapper class in Trinidad,
my concrete wrapper subclass is not impacted by new additions to the
ChangeManager API.  Any time we add a new method to the ChangeManager,
we would add an equivalent implementation to the ChangeManagerWrapper
base class.  In addition to reducing the amount of work to implement a
ChangeManager wrapper class (no longer need to re-implement every
ChangeManager method), we have significantly reduced the risk of
breaking such classes as the API evolves.

FWIW, this approach of providing a base wrapper class is a very common
pattern.  (As Pavitra hinted at this, is used all over the place in
JSF.)

Andy

Re: [Trinidad] ChangeManagerWrapper API

Posted by Prakash Udupa <pr...@oracle.com>.
Andy,

I could not understand the benefit of this new wrapper API.
If we introduce any new method to ChangeManager, we will need to provide a default implementation in the ChangeManager 
class so that we do not break the existing implementations. How does the wrapper help any more ?.

Thanks,
Prakash

On 3/9/2011 2:55 PM, Andy Schwartz wrote:
> Gang -
>
> I would like to add a new base class for ChangeManager wrapper classes
> to extend as discussed here:
>
> https://issues.apache.org/jira/browse/TRINIDAD-2055
>
> I have attached an implementation to the issue:
>
> https://issues.apache.org/jira/secure/attachment/12473198/ChangeManagerWrapper.java
>
> Fairly simple stuff, but would appreciate if someone could review.
>
> On a related note...
>
> As a new committer, I am a bit fuzzy on what the process is for
> introducing new APIs. My guess is that any significant APIs require
> discussion/community approval (maybe even a vote?).  Is the same true
> of simple/small APIs like this?  (If there is documentation on this
> that I need to read, please let me know!)
>
> Thanks,
> Andy