Best practices for using modules

682 views
Skip to first unread message

Efi Merdler

unread,
Aug 19, 2011, 2:32:29 PM8/19/11
to google-guice
What are the best practices for using modules:
1. Should I define all my bindings in a single module ?
2. In case not how would you suggest separating them ?

Thanks.

Fred Faber

unread,
Aug 19, 2011, 2:52:42 PM8/19/11
to google...@googlegroups.com

Simple answer: have one module per package and bind only the classes implemented in the corresponding package with each module.  Of course there will be exceptions. Then build top-level modules that exist primarily to install your implementation-based modules. For instance you might have a ServerModule that installs the modules that a server depends on. That is the module you'd use to create the Injector.

> --
> You received this message because you are subscribed to the Google Groups "google-guice" group.
> To post to this group, send email to google...@googlegroups.com.
> To unsubscribe from this group, send email to google-guice...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/google-guice?hl=en.
>

Aekold

unread,
Aug 22, 2011, 4:07:23 AM8/22/11
to google-guice
I used it together with ServiceLocator. I had separate jar with models
and interfaces as global dependency, and separate jars for
implementations of those interfaces, with Guice module to bind them.
Worked great for back-end, but have no idea how to make it work with
front-end.

Mike Grove

unread,
Aug 22, 2011, 7:24:22 AM8/22/11
to google...@googlegroups.com
On Mon, Aug 22, 2011 at 4:07 AM, Aekold <helb...@gmail.com> wrote:
> I used it together with ServiceLocator. I had separate jar with models
> and interfaces as global dependency, and separate jars for
> implementations of those interfaces, with Guice module to bind them.
> Worked great for back-end, but have no idea how to make it work with
> front-end.

This is the same design I've been using, works well thus far.

>
>> On Aug 19, 2011 2:36 PM, "Efi Merdler" <efi.merd...@gmail.com> wrote:> What are the best practices for using modules:
>> > 1. Should I define all my bindings in a single module ?
>> > 2. In case not how would you suggest separating them ?
>

Reply all
Reply to author
Forward
0 new messages