On Sat, Jul 6, 2013 at 10:42 PM, Tim Boudreau <[email protected]> wrote:
> Both of the code links were 404s, so no idea what your code looked like.
> So, what are you trying to do?
>

Uh yeah, sorry, since then I have modified the code heavily.

> There's nothing wrong with the builder pattern even if you're using Guice.
> If the parameters don't change for the life of the application, but you're
> writing something extensible, you might just have users pass a
> URLTransformerBuilder to your Module's constructor, and then build and bind
> the result.
>

That is what I am currently doing... In fact, with builders, my API
works pretty well, but DI has shed a new light on my design which
tells me, "not so good". Unlike DI, builders' products are "fixed". DI
allows to inject products on a finer level, easier; and due to the
evolution I envision, it is what I need.

> Either way, classes that want a URLTranformer and are created by Guice
> probably just include it in constructor arguments in a constructor annotated
> with @Inject.
>

Yep, that is the plan. And what I am currently doing, but currently all @Beta.

> If it's supposed to be configured from properties that are part of
> application configuration, you'll need to get them into the application
> somehow (properties files, etc.), perhaps using a library that does that
> such as (shameless plug) https://github.com/timboudreau/giulius
>

I'll have a look into it... My ultimate goal is to only use JSR 330
annotations and allow the user, if that is her wish, to use another
injection mechanism than the one I will propose and which is
Guice-based.

> Generally, if the arguments are bad and the object is configured on startup,
> you probably just want to throw an Exception or Error early enough in
> startup to bail out of the JVM entirely - failing early is a Good Thing[tm].

Yep, that is my philosophy too ;)

> If it's at runtime, there's nothing special you'd do particularly
> differently, just be aware that your exception might be wrappered in one of
> Guice's if it is thrown during object creation.
>

I guess I can live with that; although I put the maximum effort into
catching errors at the module construction time.

Still a beginner with DI... Getting there, slowly...

Thanks for the tips!
--
Francis Galiegue, [email protected]
JSON Schema in Java: http://json-schema-validator.herokuapp.com

-- 
You received this message because you are subscribed to the Google Groups 
"google-guice" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/google-guice.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to