Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Use Cases For Stateful and Singleton Adapters(Differentiation between Stateful and Singleton Adapters with some examples)
Use Cases For Stateful and Singleton Adapters [message #557091] Sat, 04 September 2010 07:25 Go to next message
Animesh Kumar is currently offline Animesh KumarFriend
Messages: 18
Registered: September 2010
Location: Bangalore
Junior Member
Hi,
I am new to EMF and was reading about different patterns of Adapters,
i.e., Stateful and Singleton Adapters. I understood there definitions something like this:-
1.Stateful adapters - every object in a model has a one-to-one correspondence with its adapter. One adapter is created for each object. This pattern doubles the number of objects in the application, and the instances are needed to carry additional state.
2.Singleton adapters - use a single adapter for all the items of the same type(or for one class). State is not saved.
I wanted to know what are the different use cases in which we can use stateful adapters and where it is required to use singleton or stateless adapters. I need some examples such that it can clearly differentiate between them.


Regards,
Animesh
Re: Use Cases For Stateful and Singleton Adapters [message #557108 is a reply to message #557091] Sat, 04 September 2010 14:15 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33113
Registered: July 2009
Senior Member
Animesh,

Comments below.

Animesh Kumar wrote:
> Hi,
> I am new to EMF and was reading about different patterns of Adapters,
> i.e., Stateful and Singleton Adapters. I understood there definitions
> something like this:-
> 1.Stateful adapters - every object in a model has a one-to-one
> correspondence with its adapter. One adapter is created for each
> object. This pattern doubles the number of objects in the application,
> and the instances are needed to carry additional state. 2.Singleton
> adapters - use a single adapter for all the items of the same type(or
> for one class). State is not saved.
> I wanted to know what are the different use cases in which we can use
> stateful adapters and where it is required to use singleton or
> stateless adapters. I need some examples such that it can clearly
> differentiate between them.
It's never required to use singletons. It's good to use them when
possible. It's possible when all the adapters methods produce results
that depends only on the arguments passed to them, i.e., when there is
no need to cache or retain information that must be different for each
thing being adapters. When there are no fields, you know you can use a
singleton. If there are fields that cache information, you might still
be able to use a singleton, if for example, that state depends only on
the type of the object, not on the instance data on the object, and you
have a singleton per type (as we do for the generated item providers).
My advice would be, start with a singleton, and when that doesn't work,
you'll notice and need to switch to using stateful ones.


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Use Cases For Stateful and Singleton Adapters [message #557110 is a reply to message #557108] Sat, 04 September 2010 14:24 Go to previous messageGo to next message
Animesh Kumar is currently offline Animesh KumarFriend
Messages: 18
Registered: September 2010
Location: Bangalore
Junior Member
Ok. But the main reason for posting here was to get some examples of both the types. I have got only the theoretical concepts but i haven't got any practical examples differentiating the two. Can you please give me a practical example for both of them so that i can proceed.

Regards,
Animesh
Re: Use Cases For Stateful and Singleton Adapters [message #557115 is a reply to message #557110] Sat, 04 September 2010 14:51 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33113
Registered: July 2009
Senior Member
Animesh,

You'll find all the generated item providers follow the stateless
pattern, so there are endless examples of those. In
EClassImpl.getESuperAdapter you'll find a statetful use case. Here we
maintain modifiedState, to keep track of which derived features need to
be recomputed based on changes to a particular class' own features and
super class's features.


Animesh Kumar wrote:
> Ok. But the main reason for posting here was to get some examples of
> both the types. I have got only the theoretical concepts but i haven't
> got any practical examples differentiating the two. Can you please
> give me a practical example for both of them so that i can proceed.


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Use Cases For Stateful and Singleton Adapters [message #557120 is a reply to message #557115] Sat, 04 September 2010 15:46 Go to previous message
Animesh Kumar is currently offline Animesh KumarFriend
Messages: 18
Registered: September 2010
Location: Bangalore
Junior Member
Ok. Thanks.. I got it Smile

Regards,
Animesh
Previous Topic:Turning off Mint
Next Topic:3.7.x stream EMF versions and p2 repositories
Goto Forum:
  


Current Time: Thu Mar 28 19:58:27 GMT 2024

Powered by FUDForum. Page generated in 0.05728 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top