Static dependency Injection vs Direct deferred binding

2013-05-24 Thread QuanC
Hi every,

Recently I am working on a i18n project in which I created some utility 
class to provide localized content like the following:

public class Foo {

@Inject
private static MyConstantsWithLookup constants;
   

public static String getLocalizedContent(String rawContent) {
return constants.getString(rawContent);
}

}

Where MyConstantsWithLookup is an interface extending ConstantsWithLookup. 
And I have the following in my GinModule:

requestStaticInjection(Foo.class);

@Provides
@Singleton
public MyConstantsWithLookup getMyConstantsWithLookup() {
MyConstantsWithLookup constants = 
GWT.create(MyConstantsWithLookup.class);
return constants;
}




However, my teammate doesn't agree my use of @Inject here, he argued that I 
should use GWT.create(MyConstantsWithLookup.class) in Foo directly so 
MyConstantsWithLookup can be resolved in compile time and got certain 
optimizations from deferred binding,  instead of letting it be handled in 
runtime by Gin. He also said it's generally undesired to do static 
injection. But I do like the brevity of @inject and MyConstantsWithLookup 
is not something I usually need to mock out. So I wonder what are the exact 
pros and cons here? Thanks a lot! 

-- 
You received this message because you are subscribed to the Google Groups 
Google Web Toolkit group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-web-toolkit+unsubscr...@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Static dependency Injection vs Direct deferred binding

2013-05-24 Thread Mohammad Al-Quraian
There's no runtime overhead from using Gin, actually Gin does exactly 
what's your teammate is telling you to do, read here:
https://code.google.com/p/google-gin/wiki/GinTutorial#Gin_Magic;https://code.google.com/p/google-gin/wiki/GinTutorial#Gin_
https://code.google.com/p/google-gin/wiki/GinFaq#Does_GIN_have_runtime_overhead?

Also, you don't have to added any configurations for things such as 
Constants and RPC interfaces, because will automate the deferred binding. 
You just need to inject them when you need to use them. This is also 
explained in the links above.

-- 
You received this message because you are subscribed to the Google Groups 
Google Web Toolkit group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to google-web-toolkit+unsubscr...@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.