You are viewing a plain text version of this content. The canonical link for it is here.
Posted to proton@qpid.apache.org by Rafael Schloming <rh...@alum.mit.edu> on 2014/04/29 20:57:29 UTC
simplified factory pattern for proton-j
Hi Everyone,
I've put together a patch that makes the proton-j factory usage a bit
simpler and more consistent. You can review it here if you like:
- https://reviews.apache.org/r/20854/
The main point of the patch is to make all the factories consistently
follow this pattern:
package.Interface iface = package.Interface.Factory.create(...);
I like this because it is simple and easy to remember and doesn't require
importing the impl packages directly.
The patch preserves the convenience constructors, e.g. Proton.connection()
and so forth, but it does remove the old factory APIs. I think this is a
reasonable thing to do because the old factories were cumbersome enough to
use that I don't think anyone actually bothered (including our own
exmaples).
In any case, please shout if this patch will be troublesome for you. If I
don't hear anything I'll go ahead and commit it later this week.
Thanks,
--Rafael
Re: simplified factory pattern for proton-j
Posted by Clebert Suconic <cs...@redhat.com>.
Ah.. I see.
I looked at the patch and I liked it.
One thing I don't like on the current codebase is the implementations as inner classes on Interfaces.. (e.g. WriteableBuffer)... I would suggest making it a separate class.
but on this case it makes a lot of sense.... I looked at the patch and I liked it.
On Apr 30, 2014, at 9:08 AM, Rafael Schloming <rh...@alum.mit.edu> wrote:
> Right, I wasn't suggesting the proton codebase use Java 8 anytime soon (I
> would think not until Java 7 is EOLed), just that if a Java 8 codebase uses
> proton-j then the idioms will be a little bit closer to each other.
>
> --Rafael
>
>
> On Wed, Apr 30, 2014 at 8:33 AM, Clebert Suconic <cs...@redhat.com>wrote:
>
>> The only issue is that all the users using Proton-j would have to be at
>> least Java8.
>> For instance, I can have maybe my users using Java8 on the server, but
>> they won't migrate all their clients.
>>
>>
>> On Apr 30, 2014, at 6:48 AM, Rafael Schloming <rh...@alum.mit.edu> wrote:
>>
>>> I forgot to mention, but another part of the reasoning here is that Java
>> 8
>>> is (finally!!!) allowing static methods in interfaces, so the "natural"
>>> pattern for this sort of thing would just be Interface.create(...), and
>>> while we won't be able to use that for a while, the
>>> Interface.Factory.create(...) option is about as idiomatically close to
>>> that as we can get in Java 7.
>>>
>>> --Rafael
>>>
>>>
>>> On Tue, Apr 29, 2014 at 2:57 PM, Rafael Schloming <rh...@alum.mit.edu>
>> wrote:
>>>
>>>> Hi Everyone,
>>>>
>>>> I've put together a patch that makes the proton-j factory usage a bit
>>>> simpler and more consistent. You can review it here if you like:
>>>>
>>>> - https://reviews.apache.org/r/20854/
>>>>
>>>> The main point of the patch is to make all the factories consistently
>>>> follow this pattern:
>>>>
>>>> package.Interface iface = package.Interface.Factory.create(...);
>>>>
>>>> I like this because it is simple and easy to remember and doesn't
>> require
>>>> importing the impl packages directly.
>>>>
>>>> The patch preserves the convenience constructors, e.g.
>> Proton.connection()
>>>> and so forth, but it does remove the old factory APIs. I think this is a
>>>> reasonable thing to do because the old factories were cumbersome enough
>> to
>>>> use that I don't think anyone actually bothered (including our own
>>>> exmaples).
>>>>
>>>> In any case, please shout if this patch will be troublesome for you. If
>> I
>>>> don't hear anything I'll go ahead and commit it later this week.
>>>>
>>>> Thanks,
>>>>
>>>> --Rafael
>>>>
>>>>
>>
>>
Re: simplified factory pattern for proton-j
Posted by Rafael Schloming <rh...@alum.mit.edu>.
Right, I wasn't suggesting the proton codebase use Java 8 anytime soon (I
would think not until Java 7 is EOLed), just that if a Java 8 codebase uses
proton-j then the idioms will be a little bit closer to each other.
--Rafael
On Wed, Apr 30, 2014 at 8:33 AM, Clebert Suconic <cs...@redhat.com>wrote:
> The only issue is that all the users using Proton-j would have to be at
> least Java8.
> For instance, I can have maybe my users using Java8 on the server, but
> they won't migrate all their clients.
>
>
> On Apr 30, 2014, at 6:48 AM, Rafael Schloming <rh...@alum.mit.edu> wrote:
>
> > I forgot to mention, but another part of the reasoning here is that Java
> 8
> > is (finally!!!) allowing static methods in interfaces, so the "natural"
> > pattern for this sort of thing would just be Interface.create(...), and
> > while we won't be able to use that for a while, the
> > Interface.Factory.create(...) option is about as idiomatically close to
> > that as we can get in Java 7.
> >
> > --Rafael
> >
> >
> > On Tue, Apr 29, 2014 at 2:57 PM, Rafael Schloming <rh...@alum.mit.edu>
> wrote:
> >
> >> Hi Everyone,
> >>
> >> I've put together a patch that makes the proton-j factory usage a bit
> >> simpler and more consistent. You can review it here if you like:
> >>
> >> - https://reviews.apache.org/r/20854/
> >>
> >> The main point of the patch is to make all the factories consistently
> >> follow this pattern:
> >>
> >> package.Interface iface = package.Interface.Factory.create(...);
> >>
> >> I like this because it is simple and easy to remember and doesn't
> require
> >> importing the impl packages directly.
> >>
> >> The patch preserves the convenience constructors, e.g.
> Proton.connection()
> >> and so forth, but it does remove the old factory APIs. I think this is a
> >> reasonable thing to do because the old factories were cumbersome enough
> to
> >> use that I don't think anyone actually bothered (including our own
> >> exmaples).
> >>
> >> In any case, please shout if this patch will be troublesome for you. If
> I
> >> don't hear anything I'll go ahead and commit it later this week.
> >>
> >> Thanks,
> >>
> >> --Rafael
> >>
> >>
>
>
Re: simplified factory pattern for proton-j
Posted by Clebert Suconic <cs...@redhat.com>.
The only issue is that all the users using Proton-j would have to be at least Java8.
For instance, I can have maybe my users using Java8 on the server, but they won't migrate all their clients.
On Apr 30, 2014, at 6:48 AM, Rafael Schloming <rh...@alum.mit.edu> wrote:
> I forgot to mention, but another part of the reasoning here is that Java 8
> is (finally!!!) allowing static methods in interfaces, so the "natural"
> pattern for this sort of thing would just be Interface.create(...), and
> while we won't be able to use that for a while, the
> Interface.Factory.create(...) option is about as idiomatically close to
> that as we can get in Java 7.
>
> --Rafael
>
>
> On Tue, Apr 29, 2014 at 2:57 PM, Rafael Schloming <rh...@alum.mit.edu> wrote:
>
>> Hi Everyone,
>>
>> I've put together a patch that makes the proton-j factory usage a bit
>> simpler and more consistent. You can review it here if you like:
>>
>> - https://reviews.apache.org/r/20854/
>>
>> The main point of the patch is to make all the factories consistently
>> follow this pattern:
>>
>> package.Interface iface = package.Interface.Factory.create(...);
>>
>> I like this because it is simple and easy to remember and doesn't require
>> importing the impl packages directly.
>>
>> The patch preserves the convenience constructors, e.g. Proton.connection()
>> and so forth, but it does remove the old factory APIs. I think this is a
>> reasonable thing to do because the old factories were cumbersome enough to
>> use that I don't think anyone actually bothered (including our own
>> exmaples).
>>
>> In any case, please shout if this patch will be troublesome for you. If I
>> don't hear anything I'll go ahead and commit it later this week.
>>
>> Thanks,
>>
>> --Rafael
>>
>>
Re: simplified factory pattern for proton-j
Posted by Rafael Schloming <rh...@alum.mit.edu>.
I forgot to mention, but another part of the reasoning here is that Java 8
is (finally!!!) allowing static methods in interfaces, so the "natural"
pattern for this sort of thing would just be Interface.create(...), and
while we won't be able to use that for a while, the
Interface.Factory.create(...) option is about as idiomatically close to
that as we can get in Java 7.
--Rafael
On Tue, Apr 29, 2014 at 2:57 PM, Rafael Schloming <rh...@alum.mit.edu> wrote:
> Hi Everyone,
>
> I've put together a patch that makes the proton-j factory usage a bit
> simpler and more consistent. You can review it here if you like:
>
> - https://reviews.apache.org/r/20854/
>
> The main point of the patch is to make all the factories consistently
> follow this pattern:
>
> package.Interface iface = package.Interface.Factory.create(...);
>
> I like this because it is simple and easy to remember and doesn't require
> importing the impl packages directly.
>
> The patch preserves the convenience constructors, e.g. Proton.connection()
> and so forth, but it does remove the old factory APIs. I think this is a
> reasonable thing to do because the old factories were cumbersome enough to
> use that I don't think anyone actually bothered (including our own
> exmaples).
>
> In any case, please shout if this patch will be troublesome for you. If I
> don't hear anything I'll go ahead and commit it later this week.
>
> Thanks,
>
> --Rafael
>
>
Re: simplified factory pattern for proton-j
Posted by Clebert Suconic <cs...@redhat.com>.
-- Clebert Suconic typing on the iPhone.
> On Jun 24, 2014, at 11:44 PM, Clebert Suconic <cs...@redhat.com> wrote:
>
> I just bumped into one issue (actually two issues) after this:
>
>
> I - First HAWT-JMS is not working with trunk because the API is changed here. I could change the API but now I have an issue that we can't commit the change since there is no commit for this yet.
>
I meant. There is no version for this yet.
> II - Using this Factory on the interface makes it very tight to use any other factory. I mean.. why use a factory at all if the only factory available is the one described on the Interface? you could just use new MessageImpl.
> The advantage of the factory would be to plug other message implementations. For instance I just came up with a message implementation on my JMS parser that doesn't parse the body (since my server doesn't need to do it). I'm not using any of the factories here because of this.
> I don't want to make a big deal about this.. but I guess I would prefer the old factories back.
>
>
>
>
>> On May 1, 2014, at 3:39 PM, Rafael Schloming <rh...@alum.mit.edu> wrote:
>>
>> Just a heads up, I've committed this to trunk. Please let me know if it
>> causes any problems.
>>
>> --Rafael
>>
>>
>>> On Tue, Apr 29, 2014 at 2:57 PM, Rafael Schloming <rh...@alum.mit.edu> wrote:
>>>
>>> Hi Everyone,
>>>
>>> I've put together a patch that makes the proton-j factory usage a bit
>>> simpler and more consistent. You can review it here if you like:
>>>
>>> - https://reviews.apache.org/r/20854/
>>>
>>> The main point of the patch is to make all the factories consistently
>>> follow this pattern:
>>>
>>> package.Interface iface = package.Interface.Factory.create(...);
>>>
>>> I like this because it is simple and easy to remember and doesn't require
>>> importing the impl packages directly.
>>>
>>> The patch preserves the convenience constructors, e.g. Proton.connection()
>>> and so forth, but it does remove the old factory APIs. I think this is a
>>> reasonable thing to do because the old factories were cumbersome enough to
>>> use that I don't think anyone actually bothered (including our own
>>> exmaples).
>>>
>>> In any case, please shout if this patch will be troublesome for you. If I
>>> don't hear anything I'll go ahead and commit it later this week.
>>>
>>> Thanks,
>>>
>>> --Rafael
>
Re: simplified factory pattern for proton-j
Posted by Clebert Suconic <cs...@redhat.com>.
I just bumped into one issue (actually two issues) after this:
I - First HAWT-JMS is not working with trunk because the API is changed here. I could change the API but now I have an issue that we can't commit the change since there is no commit for this yet.
II - Using this Factory on the interface makes it very tight to use any other factory. I mean.. why use a factory at all if the only factory available is the one described on the Interface? you could just use new MessageImpl.
The advantage of the factory would be to plug other message implementations. For instance I just came up with a message implementation on my JMS parser that doesn't parse the body (since my server doesn't need to do it). I'm not using any of the factories here because of this.
I don't want to make a big deal about this.. but I guess I would prefer the old factories back.
On May 1, 2014, at 3:39 PM, Rafael Schloming <rh...@alum.mit.edu> wrote:
> Just a heads up, I've committed this to trunk. Please let me know if it
> causes any problems.
>
> --Rafael
>
>
> On Tue, Apr 29, 2014 at 2:57 PM, Rafael Schloming <rh...@alum.mit.edu> wrote:
>
>> Hi Everyone,
>>
>> I've put together a patch that makes the proton-j factory usage a bit
>> simpler and more consistent. You can review it here if you like:
>>
>> - https://reviews.apache.org/r/20854/
>>
>> The main point of the patch is to make all the factories consistently
>> follow this pattern:
>>
>> package.Interface iface = package.Interface.Factory.create(...);
>>
>> I like this because it is simple and easy to remember and doesn't require
>> importing the impl packages directly.
>>
>> The patch preserves the convenience constructors, e.g. Proton.connection()
>> and so forth, but it does remove the old factory APIs. I think this is a
>> reasonable thing to do because the old factories were cumbersome enough to
>> use that I don't think anyone actually bothered (including our own
>> exmaples).
>>
>> In any case, please shout if this patch will be troublesome for you. If I
>> don't hear anything I'll go ahead and commit it later this week.
>>
>> Thanks,
>>
>> --Rafael
>>
>>
Re: simplified factory pattern for proton-j
Posted by Rafael Schloming <rh...@alum.mit.edu>.
Just a heads up, I've committed this to trunk. Please let me know if it
causes any problems.
--Rafael
On Tue, Apr 29, 2014 at 2:57 PM, Rafael Schloming <rh...@alum.mit.edu> wrote:
> Hi Everyone,
>
> I've put together a patch that makes the proton-j factory usage a bit
> simpler and more consistent. You can review it here if you like:
>
> - https://reviews.apache.org/r/20854/
>
> The main point of the patch is to make all the factories consistently
> follow this pattern:
>
> package.Interface iface = package.Interface.Factory.create(...);
>
> I like this because it is simple and easy to remember and doesn't require
> importing the impl packages directly.
>
> The patch preserves the convenience constructors, e.g. Proton.connection()
> and so forth, but it does remove the old factory APIs. I think this is a
> reasonable thing to do because the old factories were cumbersome enough to
> use that I don't think anyone actually bothered (including our own
> exmaples).
>
> In any case, please shout if this patch will be troublesome for you. If I
> don't hear anything I'll go ahead and commit it later this week.
>
> Thanks,
>
> --Rafael
>
>