You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@shindig.apache.org by Kevin Brown <et...@google.com> on 2009/01/08 22:00:51 UTC

Re: svn commit: r732453 [1/3] - in /incubator/shindig/branches/1.0.x-incubating: ./ java/common/ java/common/src/main/java/org/apache/shindig/auth/ java/common/src/main/java/org/apache/shindig/common/ java/common/src/main/java/org/apache/shindig/comm

On Thu, Jan 8, 2009 at 11:52 AM, Eric Tschetter <ec...@gmail.com> wrote:

> >> I  -1 this patch unless you can sufficiently explain why e.g.
> >>
> >>> -    tokenData = new HashMap<String, String>(5,1);
> >>> +    tokenData = Maps.newHashMapWithExpectedSize(5);
> >>
> >> is better readable to someone with knowledge of the standard Java APIs
> >> and no knowledge of Google Collections.
> >
> > Is it really that hard to understand?  Really?  Some Junior Devs looked
> at
> > that code and easily understood the intent.
>
> Did those Junior Devs also understand the initial incantation?
>
>
> >> All that this huge patch IMHO does is making the code harder to read
> >> for no particular reasons.
> >
> > There are reasons. In this case you use the factory methods to not repeat
> > yourself.  Consider the degenerate case:
> >
> >  Map<Integer, List<Map<Foo,Bar>>> = new
> > HashMap<Integer,List<Map<Foo,Bar>>>(5,1);
> >
> > you can replace the RHS with Maps.newHashMapWithExpectedSize(5)
>
> We are entering the realm of religious minutia here, but what is the
> benefit of taking a mathematical language and replacing it with a
> natural language?  Sure, it makes sense for a small group of people
> (i.e. internal/personal development) to create and introduce
> "languages" that they find easier to understand, but when something is
> being consumed by some unknown plurality, it doesn't make sense to
> force that plurality to learn your way of doing things when there is a
> common, accepted way of doing it that they will already know.


I think you're missing the point. It's not about using 'natural' language,
it's about reducing line length.

Of course, in this particular case the line length argument doesn't hold
because the second form is actually 1 character longer than the first.
Unless you do a static import, new HashMap<String, String(5, 1); is shorter.

It's really relevant in places where you see things like this:

Map<String, Map<String, Callable<? extends Future<? extends CharSequence>>>>
callbacks = new HashMap<String, Map<String, Callable<? extends Future<?
extends CharSequence>>>>()

vs.

Map<String, Map<String, Callable<? extends Future<? extends CharSequence>>>>
callbacks = Maps.newHashMap();



>
> In math, it doesn't make sense to replace ∏ with
> "multiply-all-numbers-in-the-series" and ∑ with
> "sum-all-numbers-in-the-series", because the symbols are a part of the
> "universal" mathematical language.  People who understand math will
> understand the symbols.  Switching the names to
> "multiply-all-numbers-in-the-series" might work well for introducing
> English speakers to the idea of ∏, but it will do very little for
> anyone who doesn't speak English.  While it's probably true that
> English permeates Java enough that anyone who can program Java has at
> least some understanding of English, I don't know why replacing the
> instantiation of a HashMap with a more flowing, "natural" English
> method call (i.e. replacing a mathematical language with natural
> language) is beneficial in an open source project.
>
> Of course, if the object it creates isn't just a Java HashMap<...>,
> then the change isn't related to language but to the actual runtime
> properties of the system.  My understanding, however, is that the Maps
> method above is just a wrapper around "new HashMap<...>()"
>
> --Eric
>

Re: svn commit: r732453 [1/3] - in /incubator/shindig/branches/1.0.x-incubating: ./ java/common/ java/common/src/main/java/org/apache/shindig/auth/ java/common/src/main/java/org/apache/shindig/common/ java/common/src/main/java/org/apache/shindig/comm

Posted by Henning Schmiedehausen <hg...@googlemail.com>.
Expand your line wrap. The days of 80x25 are gone. ;-) And yes, Java
developers can read and understand

Map<String, Map<String, Callable<? extends Future<? extends
CharSequence>>>>callbacks = new HashMap<String, Map<String, Callable<?
extends Future<? extends CharSequence>>>>()

    Ciao
        Henning

2009/1/8 Kevin Brown <et...@google.com>:
> On Thu, Jan 8, 2009 at 11:52 AM, Eric Tschetter <ec...@gmail.com> wrote:
>
>> >> I  -1 this patch unless you can sufficiently explain why e.g.
>> >>
>> >>> -    tokenData = new HashMap<String, String>(5,1);
>> >>> +    tokenData = Maps.newHashMapWithExpectedSize(5);
>> >>
>> >> is better readable to someone with knowledge of the standard Java APIs
>> >> and no knowledge of Google Collections.
>> >
>> > Is it really that hard to understand?  Really?  Some Junior Devs looked
>> at
>> > that code and easily understood the intent.
>>
>> Did those Junior Devs also understand the initial incantation?
>>
>>
>> >> All that this huge patch IMHO does is making the code harder to read
>> >> for no particular reasons.
>> >
>> > There are reasons. In this case you use the factory methods to not repeat
>> > yourself.  Consider the degenerate case:
>> >
>> >  Map<Integer, List<Map<Foo,Bar>>> = new
>> > HashMap<Integer,List<Map<Foo,Bar>>>(5,1);
>> >
>> > you can replace the RHS with Maps.newHashMapWithExpectedSize(5)
>>
>> We are entering the realm of religious minutia here, but what is the
>> benefit of taking a mathematical language and replacing it with a
>> natural language?  Sure, it makes sense for a small group of people
>> (i.e. internal/personal development) to create and introduce
>> "languages" that they find easier to understand, but when something is
>> being consumed by some unknown plurality, it doesn't make sense to
>> force that plurality to learn your way of doing things when there is a
>> common, accepted way of doing it that they will already know.
>
>
> I think you're missing the point. It's not about using 'natural' language,
> it's about reducing line length.
>
> Of course, in this particular case the line length argument doesn't hold
> because the second form is actually 1 character longer than the first.
> Unless you do a static import, new HashMap<String, String(5, 1); is shorter.
>
> It's really relevant in places where you see things like this:
>
> Map<String, Map<String, Callable<? extends Future<? extends CharSequence>>>>
> callbacks = new HashMap<String, Map<String, Callable<? extends Future<?
> extends CharSequence>>>>()
>
> vs.
>
> Map<String, Map<String, Callable<? extends Future<? extends CharSequence>>>>
> callbacks = Maps.newHashMap();
>
>
>
>>
>> In math, it doesn't make sense to replace ∏ with
>> "multiply-all-numbers-in-the-series" and ∑ with
>> "sum-all-numbers-in-the-series", because the symbols are a part of the
>> "universal" mathematical language.  People who understand math will
>> understand the symbols.  Switching the names to
>> "multiply-all-numbers-in-the-series" might work well for introducing
>> English speakers to the idea of ∏, but it will do very little for
>> anyone who doesn't speak English.  While it's probably true that
>> English permeates Java enough that anyone who can program Java has at
>> least some understanding of English, I don't know why replacing the
>> instantiation of a HashMap with a more flowing, "natural" English
>> method call (i.e. replacing a mathematical language with natural
>> language) is beneficial in an open source project.
>>
>> Of course, if the object it creates isn't just a Java HashMap<...>,
>> then the change isn't related to language but to the actual runtime
>> properties of the system.  My understanding, however, is that the Maps
>> method above is just a wrapper around "new HashMap<...>()"
>>
>> --Eric
>>
>

Re: Help needed hooking/injecting my service handlers

Posted by Ian Boston <ie...@tfd.co.uk>.
On 9 Jan 2009, at 08:53, Jordan Zimmerman wrote:

>>> I've also changed the @ImplementedBy for the service interfaces.
>> Why are you changing this? You shouldn't need to modify the  
>> interfaces
>
>> in any way.
>
> ActivityService, PersonService, and AppDataService are all marked with
> the annotation:
> 	@ImplementedBy(JsonDbOpensocialService.class)

Thats just the default, if no binding is defined, its used.
Any binding in a module will override it ( but you can only define it  
once in a module in Guice1.0)

For an sample of how to provide a different module see
http://svn.apache.org/repos/asf/incubator/shindig/trunk/java/samples/src/main/java/org/apache/shindig/social/opensocial/jpa/spi/JPASocialModule.java


Which, to activate the JPA SPI should be added as an independent  
module to

http://svn.apache.org/repos/asf/incubator/shindig/trunk/java/server/src/main/webapp/WEB-INF/web.xml

at the end of the list of 'guice-modules'


HTH
Ian


>
>
> I don't need to change that?
>
> Jordan Zimmerman
> Principal Software Architect
> 831.647.4712
> 831.214.2990 (cell)
> jordanz@shop.com
>
> SHOP*COMTM
> All your favorite stores.
> OneCart(r) convenience.
> www.shop.com
>
>
> This message (including any attachments) is intended only for
> the use of the individual or entity to which it is addressed and
> may contain information that is non-public, proprietary,
> privileged, confidential, and exempt from disclosure under
> applicable law or may constitute as attorney work product.
> If you are not the intended recipient, you are hereby notified
> that any use, dissemination, distribution, or copying of this
> communication is strictly prohibited. If you have received this
> communication in error, notify us immediately by telephone and
> (i) destroy this message if a facsimile or (ii) delete this
> message
> immediately if this is an electronic communication.
>
> Thank you.


Re: Help needed hooking/injecting my service handlers

Posted by Kevin Brown <et...@google.com>.
On Fri, Jan 9, 2009 at 6:59 AM, <ha...@nexgo.de> wrote:

> Hi Jordan,
>
> that's right. You don't need to change the interfaces. Doing this is bad
> style in my mind.
>
> In my tests I have written my own Guice Module and told Shindig to take
> this. You have to put this in the web.xml of Shindig and this works fine. In
> the Shindig installation there are several web.xml files, e.g. web.full.xml.
> I have made the changes everywhere as I don't know which one is the right.


There are comments in the web.xml files indicating what they're for:

- web.gadgets.xml: just the gadget rendering server
- web.social.xml: just the social data / RESTful server
- web.full.xml: both servers in a single container


>
>
> I have provided my sample code in the apache wiki as a zip attachement (
> http://cwiki.apache.org/confluence/display/SHINDIG/Providing+your+own+data+service+implementation
> ).
>
> Cheers
> Harry
>
> ----- Original Nachricht ----
> Von:     Jordan Zimmerman <jo...@shop.com>
> An:      shindig-dev@incubator.apache.org
> Datum:   09.01.2009 09:53
> Betreff: RE: Help needed hooking/injecting my service handlers
>
> > > > I've also changed the @ImplementedBy for the service interfaces.
> > > Why are you changing this? You shouldn't need to modify the interfaces
> >
> > > in any way.
> >
> > ActivityService, PersonService, and AppDataService are all marked with
> > the annotation:
> >       @ImplementedBy(JsonDbOpensocialService.class)
> >
> > I don't need to change that?
> >
> > Jordan Zimmerman
> > Principal Software Architect
> > 831.647.4712
> > 831.214.2990 (cell)
> > jordanz@shop.com
> >
> > SHOP*COMTM
> > All your favorite stores.
> > OneCart(r) convenience.
> > www.shop.com
> >
> >
> > This message (including any attachments) is intended only for
> > the use of the individual or entity to which it is addressed and
> > may contain information that is non-public, proprietary,
> > privileged, confidential, and exempt from disclosure under
> > applicable law or may constitute as attorney work product.
> > If you are not the intended recipient, you are hereby notified
> > that any use, dissemination, distribution, or copying of this
> > communication is strictly prohibited. If you have received this
> > communication in error, notify us immediately by telephone and
> > (i) destroy this message if a facsimile or (ii) delete this
> > message
> > immediately if this is an electronic communication.
> >
> > Thank you.
> >
>
> Jetzt komfortabel bei Arcor-Digital TV einsteigen: Mehr Happy Ends, mehr
> Herzschmerz, mehr Fernsehen! Erleben Sie 50 digitale TV Programme und
> optional 60 Pay TV Sender, einen elektronischen Programmführer mit Movie
> Star Bewertungen von TV Movie. Außerdem, aktuelle Filmhits und spannende
> Dokus in der Arcor-Videothek. Infos unter www.arcor.de/tv
>

RE: Help needed hooking/injecting my service handlers

Posted by ha...@nexgo.de.
Hi Jordan,

that's right. You don't need to change the interfaces. Doing this is bad style in my mind.

In my tests I have written my own Guice Module and told Shindig to take this. You have to put this in the web.xml of Shindig and this works fine. In the Shindig installation there are several web.xml files, e.g. web.full.xml. I have made the changes everywhere as I don't know which one is the right.

I have provided my sample code in the apache wiki as a zip attachement (http://cwiki.apache.org/confluence/display/SHINDIG/Providing+your+own+data+service+implementation).

Cheers
Harry

----- Original Nachricht ----
Von:     Jordan Zimmerman <jo...@shop.com>
An:      shindig-dev@incubator.apache.org
Datum:   09.01.2009 09:53
Betreff: RE: Help needed hooking/injecting my service handlers

> > > I've also changed the @ImplementedBy for the service interfaces.
> > Why are you changing this? You shouldn't need to modify the interfaces
> 
> > in any way.
> 
> ActivityService, PersonService, and AppDataService are all marked with
> the annotation:
> 	@ImplementedBy(JsonDbOpensocialService.class)
> 
> I don't need to change that?
> 
> Jordan Zimmerman
> Principal Software Architect
> 831.647.4712
> 831.214.2990 (cell)
> jordanz@shop.com 
> 
> SHOP*COMTM
> All your favorite stores.
> OneCart(r) convenience.
> www.shop.com
> 
> 
> This message (including any attachments) is intended only for
> the use of the individual or entity to which it is addressed and
> may contain information that is non-public, proprietary,
> privileged, confidential, and exempt from disclosure under
> applicable law or may constitute as attorney work product.
> If you are not the intended recipient, you are hereby notified
> that any use, dissemination, distribution, or copying of this
> communication is strictly prohibited. If you have received this
> communication in error, notify us immediately by telephone and
> (i) destroy this message if a facsimile or (ii) delete this
> message
> immediately if this is an electronic communication.
> 
> Thank you.
> 

Jetzt komfortabel bei Arcor-Digital TV einsteigen: Mehr Happy Ends, mehr Herzschmerz, mehr Fernsehen! Erleben Sie 50 digitale TV Programme und optional 60 Pay TV Sender, einen elektronischen Programmführer mit Movie Star Bewertungen von TV Movie. Außerdem, aktuelle Filmhits und spannende Dokus in der Arcor-Videothek. Infos unter www.arcor.de/tv

RE: Help needed hooking/injecting my service handlers

Posted by Jordan Zimmerman <jo...@shop.com>.
> > I've also changed the @ImplementedBy for the service interfaces.
> Why are you changing this? You shouldn't need to modify the interfaces

> in any way.

ActivityService, PersonService, and AppDataService are all marked with
the annotation:
	@ImplementedBy(JsonDbOpensocialService.class)

I don't need to change that?

Jordan Zimmerman
Principal Software Architect
831.647.4712
831.214.2990 (cell)
jordanz@shop.com 

SHOP*COMTM
All your favorite stores.
OneCart(r) convenience.
www.shop.com


This message (including any attachments) is intended only for
the use of the individual or entity to which it is addressed and
may contain information that is non-public, proprietary,
privileged, confidential, and exempt from disclosure under
applicable law or may constitute as attorney work product.
If you are not the intended recipient, you are hereby notified
that any use, dissemination, distribution, or copying of this
communication is strictly prohibited. If you have received this
communication in error, notify us immediately by telephone and
(i) destroy this message if a facsimile or (ii) delete this 
message
immediately if this is an electronic communication.

Thank you.

Re: Help needed hooking/injecting my service handlers

Posted by Kevin Brown <et...@google.com>.
On Fri, Jan 9, 2009 at 12:32 AM, Jordan Zimmerman <jo...@shop.com> wrote:

> I have my own service handler similar to JsonDbOpensocialService (called
> MediatedOpensocialService). It's a class that implements
> ActivityService, PersonService, and AppDataService. The class is marked
> with @Singleton and the constructor with @Inject. I've added binds to
> SocialApiGuiceModule.configure():
>
> bind(PersonService.class).to(MediatedOpensocialService.class);
> bind(AppDataService.class).to(MediatedOpensocialService.class);
> bind(ActivityService.class).to(MediatedOpensocialService.class);


You should be providing your own module, not modifying the default one.
Maintaining patches is painful.


>
> I've also changed the @ImplementedBy for the service interfaces.


Why are you changing this? You shouldn't need to modify the interfaces in
any way.


> However, my class never gets created/called. What else do I need to do
> to inject it into Shindig?


Just make sure that your module is declared in the web.xml (or manually
constructed if doing something not web.xml based).

Help needed hooking/injecting my service handlers

Posted by Jordan Zimmerman <jo...@shop.com>.
I have my own service handler similar to JsonDbOpensocialService (called
MediatedOpensocialService). It's a class that implements
ActivityService, PersonService, and AppDataService. The class is marked
with @Singleton and the constructor with @Inject. I've added binds to
SocialApiGuiceModule.configure():

bind(PersonService.class).to(MediatedOpensocialService.class);
bind(AppDataService.class).to(MediatedOpensocialService.class);
bind(ActivityService.class).to(MediatedOpensocialService.class);

I've also changed the @ImplementedBy for the service interfaces.

However, my class never gets created/called. What else do I need to do
to inject it into Shindig?

Jordan Zimmerman
Principal Software Architect
831.647.4712
831.214.2990 (cell)
jordanz@shop.com 

SHOP*COMTM
All your favorite stores.
OneCart(r) convenience.
www.shop.com


This message (including any attachments) is intended only for
the use of the individual or entity to which it is addressed and
may contain information that is non-public, proprietary,
privileged, confidential, and exempt from disclosure under
applicable law or may constitute as attorney work product.
If you are not the intended recipient, you are hereby notified
that any use, dissemination, distribution, or copying of this
communication is strictly prohibited. If you have received this
communication in error, notify us immediately by telephone and
(i) destroy this message if a facsimile or (ii) delete this 
message
immediately if this is an electronic communication.

Thank you.