[DataBinding] Best practices on creating the DataBindingContext [message #311665] |
Thu, 18 January 2007 20:43  |
Eclipse User |
|
|
|
Originally posted by: mbayly.nospam.telus.net
Sorry, today seems to be the day for databinding questions!
I noticed that creating a DataBindingContext, particularly the DefaultBindSupportFactory,
is quite a slow operation.
I have a view with a number of panels/components in it and initially I had
each component setting up their own DataBindingContext.
But this seems to add quite a lot to the time it takes to display the view.
So now I've modified it to use a single context for the whole view. However,
its a view that gets opened and closed quite a lot so I decided to make the
DefaultBindSupportFactory static which may not be a good thing.
But in general - what are the guidelines for creating contexts in a Rich
Client app with many windows etc. Is it a good idea to try and tie the contexts
closely to the windows that are using them - otherwise could you end up storing
a lot of binding information for controls that are now destroyed. i.e. leak
memory over time. Are some of the factories relatively stateless e.g. the
DefaultBindSupportFactory and could potentially be shared?
Thanks for any insights
Martin
|
|
|
|
Re: [DataBinding] Best practices on creating the DataBindingContext [message #311677 is a reply to message #311665] |
Fri, 19 January 2007 01:07  |
Eclipse User |
|
|
|
martin wrote:
> Sorry, today seems to be the day for databinding questions!
>
> I noticed that creating a DataBindingContext, particularly the
> DefaultBindSupportFactory, is quite a slow operation.
> I have a view with a number of panels/components in it and initially I
> had each component setting up their own DataBindingContext.
> But this seems to add quite a lot to the time it takes to display the view.
>
> So now I've modified it to use a single context for the whole view.
Yes!
> However, its a view that gets opened and closed quite a lot so I decided
> to make the DefaultBindSupportFactory static which may not be a good thing.
This is how we do it. (our app is 3 million lines long now)
> But in general - what are the guidelines for creating contexts in a Rich
> Client app with many windows etc. Is it a good idea to try and tie the
> contexts closely to the windows that are using them - otherwise could
> you end up storing a lot of binding information for controls that are
> now destroyed. i.e. leak memory over time. Are some of the factories
> relatively stateless e.g. the DefaultBindSupportFactory and could
> potentially be shared?
A few thoughts:
1) Have a single factory and make it static.
2) If you're concerned about performance, you can have your factory
create and hold a "patriarch" DBC. Then when someone asks for a new
one, the factory can:
DataBindingContext result = new DataBindingContext(rootContext);
return result;
This avoids the overhead of adding the factories to every DBC.
3) You definitely did the right thing creating one DBC for your entire
view. :-)
Best regards,
Dave Orme
|
|
|
Powered by
FUDForum. Page generated in 0.02537 seconds