Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(68)

Issue 25084: Extending AssistedInject with multi type factory support (Closed)

Can't Edit
Can't Publish+Mail
Start Review
Created:
17 years, 1 month ago by Aragos
Modified:
16 years, 8 months ago
Reviewers:
jessewilson
CC:
dhanji, fizbin_gmail.com
Base URL:
http://google-guice.googlecode.com/svn/trunk/
Visibility:
Public.

Patch Set 1 #

Patch Set 2 : Merged changes into FactoryProvider2, added configuration, tests #

Patch Set 3 : Corrected diff paths #

Total comments: 6

Patch Set 4 : Introducing FactoryModuleBuilder #

Patch Set 5 : Fixed diffs #

Unified diffs Side-by-side diffs Delta from patch set Stats (+617 lines, -44 lines) Patch
A src/com/google/inject/assistedinject/BindingCollector.java View 1 chunk +49 lines, -0 lines 0 comments Download
A src/com/google/inject/assistedinject/FactoryModuleBuilder.java View 1 chunk +303 lines, -0 lines 0 comments Download
M src/com/google/inject/assistedinject/FactoryProvider.java View 4 chunks +28 lines, -3 lines 0 comments Download
M src/com/google/inject/assistedinject/FactoryProvider2.java View 5 chunks +13 lines, -11 lines 0 comments Download
A test/com/google/inject/assistedinject/FactoryModuleBuilderTest.java View 1 chunk +195 lines, -0 lines 0 comments Download
M test/com/google/inject/assistedinject/FactoryProvider2Test.java View 13 chunks +29 lines, -30 lines 0 comments Download

Messages

Total messages: 1
jessewilson
17 years ago (2009-03-30 18:02:41 UTC) #1
I like this approach, 'cause it's concise.

But it adds lots of new complexity to AssistedInject, and I'm not 100% convinced
that this complexity pays for itself. With FactoryBinder, assistedinject's
Binder sort of competes with Guice's own binder.

From issue 131, we've been here before.
http://code.google.com/p/google-guice/issues/detail?id=131

what if instead of all of this stuff, we did a clean-slate API and called it,
say, 'FactoryModuleBuilder':
  install(new FactoryModuleBuilder()
      .withImplementation(Subcompact.class, Mini.class)
      .withImplementation(Suv.class, Forester.class)
      .build(CarFactory.class));
I'm not sure if this is the exact right API, but I think it'll work better than
introducing a new kind of binder.

With the builder we've got a place to tweak the API later if necessary. For
example, that approach will probably work nicely when we add '.toConstructor'
binding targets.
  http://code.google.com/p/google-guice/issues/detail?id=231

http://codereview.appspot.com/25084/diff/3002/3003
File
extensions/assistedinject/src/com/google/inject/assistedinject/BindingCollector.java
(right):

http://codereview.appspot.com/25084/diff/3002/3003#newcode31
Line 31: class BindingCollector {
I like this interface, it's helpful since the map would be less obvious

http://codereview.appspot.com/25084/diff/3002/3003#newcode33
Line 33: private final Map<Key, TypeLiteral> bindings = Maps.newHashMap();
don't use raw types for key and typeliteral - should be
   Map<Key<?>, TypeLiteral<?>>

similarly in addBinding()

http://codereview.appspot.com/25084/diff/3002/3003#newcode39
Line 39: throw new ConfigurationException(Collections.singleton(new Message("
Binding illegal")));
include the name of the offending key?

http://codereview.appspot.com/25084/diff/3002/3007
File
extensions/assistedinject/src/com/google/inject/assistedinject/FactoryProvider.java
(right):

http://codereview.appspot.com/25084/diff/3002/3007#newcode77
Line 77: * provider (this example assumes that the above factory returns a
{@code RealPayment} and not a
I don't really like for the factory interface to depend on the implementation
class . . . .

http://codereview.appspot.com/25084/diff/3002/3009
File
extensions/assistedinject/test/com/google/inject/assistedinject/FactoryProvider2Test.java
(right):

http://codereview.appspot.com/25084/diff/3002/3009#newcode42
Line 42: public void testNoBindingAssitedInject() {
Assited -> Assisted

http://codereview.appspot.com/25084/diff/3002/3009#newcode252
Line 252: FactoryProvider.newFactory(ColoredCarFactory.class, Porsche.class));
nice fix!
Sign in to reply to this message.

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b