[weld-dev] Java SE extension

Dan Allen dan.j.allen at gmail.com
Tue Nov 24 08:11:17 EST 2009


>
> > WeldContainer weld = new Weld().initialize();
> > weld.instance().select(Foo.class).get();
>
> Yes, this seems sensible to me, as it will allow us to provide flexibility
> with the configuration in the future.


Emmanuel, master of fluent APIs, has made an important point that we should
keep in mind when designing a sequential call chain. Think twice before
returning "this" and think if there is a more specific type that you can
return that narrows the options based on where you are in the sequence. That
way, you prevent being able to invoke methods out of sequence.

You can now prevent:

new Weld().event()

Returning a more specific type is also self documenting.

-Dan

-- 
Dan Allen
Senior Software Engineer, Red Hat | Author of Seam in Action
Registered Linux User #231597

http://mojavelinux.com
http://mojavelinux.com/seaminaction
http://www.google.com/profiles/dan.j.allen
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/weld-dev/attachments/20091124/f130d5c7/attachment.html 


More information about the weld-dev mailing list