Skip to main content

Screens caching mechanism

3 replies [Last post]
Anonymous

Hi,

Maybe I'm a litle off topic here as this is maybe not exclusively lwuit
related but I thought you might have a good answer ^^

I wanted to know what screens/forms caching mechanism you would suggest so
that :

1. I can keep a reference of previously instanciated Forms and avoid to
recreate these screens everytime I need them.
2. I can provide a "BACK" button in my application that will allow the user
to ge back in the history of the screens they saw.

For now I'm using a Stack to which I add my Forms up to a certain amount
(10).

I was wondering if this was a correct approach in LWUIT and the kind of
performance problem I might run into

Thanks for any suggestion and again sorry if you think this wasn't an
appropriate place to post.
[att1.html]

Reply viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
Shai Almog

Hi,
> Maybe I'm a litle off topic here as this is maybe not exclusively
> lwuit related but I thought you might have a good answer ^^

This is a legitimate question and was asked here once before, it
bares repeating...

LWUIT is designed for the case of form recreation and doesn't cope
well with caching, your current approach will probably crash an S40
device pretty fast unless your theme is very simple.

We generally use a state machine to determine the point in the system
and create an instance of the form on the fly, the cost for that is
very low (allocation in Java even in Java ME is really fast).
The main complexity in form creation is fetching data all over again,
generally fetching from RMS especially if your model supports
streaming should be pretty fast...
When recreating a form on the back command make sure to update the
selection as well, this can be a bit difficult in LWUIT since you can
cache the selected component either.

BTW one huge advantage of this approach is that you can serialize the
state machine to RMS. This allows the application to startup from
where you last left...

Shai Almog
http://lwuit.blogspot.com/

[att1.html]

Alex

OK thank you for your answer.
I understand the mechanism you describe.but what do you call a "state
machine" ?

On Wed, Jul 23, 2008 at 6:06 AM, Shai Almog wrote:

> Hi,
>
> Maybe I'm a litle off topic here as this is maybe not exclusively lwuit
> related but I thought you might have a good answer ^^
>
>
> This is a legitimate question and was asked here once before, it bares
> repeating...
>
> LWUIT is designed for the case of form recreation and doesn't cope well
> with caching, your current approach will probably crash an S40 device pretty
> fast unless your theme is very simple.
>
> We generally use a state machine to determine the point in the system and
> create an instance of the form on the fly, the cost for that is very low
> (allocation in Java even in Java ME is really fast).
> The main complexity in form creation is fetching data all over again,
> generally fetching from RMS especially if your model supports streaming
> should be pretty fast...
> When recreating a form on the back command make sure to update the
> selection as well, this can be a bit difficult in LWUIT since you can cache
> the selected component either.
>
> BTW one huge advantage of this approach is that you can serialize the state
> machine to RMS. This allows the application to startup from where you last
> left...
>
> Shai Almog
> http://lwuit.blogspot.com/
>
>
[att1.html]

Alex

ok forget about my last question. Just found about state machines here
http://www.agilemodeling.com/artifacts/stateMachineDiagram.htm

On Wed, Jul 23, 2008 at 6:10 AM, Alex wrote:

> OK thank you for your answer.
> I understand the mechanism you describe.but what do you call a "state
> machine" ?
>
>
>
>
> On Wed, Jul 23, 2008 at 6:06 AM, Shai Almog wrote:
>
>> Hi,
>>
>> Maybe I'm a litle off topic here as this is maybe not exclusively lwuit
>> related but I thought you might have a good answer ^^
>>
>>
>> This is a legitimate question and was asked here once before, it bares
>> repeating...
>>
>> LWUIT is designed for the case of form recreation and doesn't cope well
>> with caching, your current approach will probably crash an S40 device pretty
>> fast unless your theme is very simple.
>>
>> We generally use a state machine to determine the point in the system and
>> create an instance of the form on the fly, the cost for that is very low
>> (allocation in Java even in Java ME is really fast).
>> The main complexity in form creation is fetching data all over again,
>> generally fetching from RMS especially if your model supports streaming
>> should be pretty fast...
>> When recreating a form on the back command make sure to update the
>> selection as well, this can be a bit difficult in LWUIT since you can cache
>> the selected component either.
>>
>> BTW one huge advantage of this approach is that you can serialize the
>> state machine to RMS. This allows the application to startup from where you
>> last left...
>>
>> Shai Almog
>> http://lwuit.blogspot.com/
>>
>>
>
[att1.html]