On 3 avr, 02:53, asianCoolz <[email protected]> wrote:
> when using GWT.create(..) for image bundle, i18n or service
>
> 1.should i put the GWT.create() as global variable private final in
> the main class (entry point) and pass as reference to all my composite
> class files that required it?
> 2. should I just put the GWT.create() in every constructor of each
> composite class that required?
> 3. should I put as global variable private final in every composite
> class that required to use it?
>
> which approuch is best prastice? currently i using technique "1"
> because I saw it is used in the 'sample mail' source code. what do you
> think?

Tend to prefer the singleton approach.

I'm actually using a 4th approach: use a public static final field in
the ImageBundle-derived interface:

interface MyImages extends ImageBundle {
    static final MyImages INSTANCE = GWT.create(MyImages.class);

    AbstractImagePrototype my_image();
}

I haven't checked how much it differs from using a singleton at the
EntryPoint level (or some other class) and pass it down as a
constructor argument.

The only advantage to approach 1 is that it's a bit easier to replace
the actual instance being passed, when you have several interfaces
extending from one another (e.g. CommonImages extends ImageBundle,
ComponentAImages extends CommonImages, ComponentBImages extends
CommonImages, AllImages extends ComponentAImages, ComponentBImages,
CommonImages; you have a single instance of AllImages and pass it down
when you need a ComponentAImages or ComponentBImages). That's
particularly handy when developping components as distinct modules,
using an entrypoint per component when developping (too make
compilation faster, as you don't need to compile ComponentA when
you're developping on ComponentB) but a "main" entrypoint for
production/deployment: components are loosely coupled to the actual
instance of the imagebundle the depend on. It all because even more
obvious as you start to use dependency injection with tools like
Google Gin.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Google Web Toolkit" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/Google-Web-Toolkit?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to