Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » [XCORE] How To Design Question: How to model extensible single instances(Model extensible single instance class as if they were an Enum)
[XCORE] How To Design Question: How to model extensible single instances [message #1398737] Fri, 11 July 2014 14:01 Go to next message
xjn Mising nameFriend
Messages: 20
Registered: May 2010
Junior Member
Hi,

i have the following design problem using EMF and/or XCore.

In plain Java it's easy, but i'd like to give EMF/XCore a try
for this.

--

I have an abstract base class : class AbstractDecoderProtocol


I have a (unknown) number of plugins extending
AbstractDecoderProtocol, lets assume :


- plugin "NB" provides
-- DecoderProtocolNB extending AbstractDecoderProtocol


and

- pluging "NX" provides
-- DecoderProtocolN1 extending AbstractDecoderProtocol
-- DecoderProtocolN2 extending AbstractDecoderProtocol


and

- pluging "M1" provides
-- DecoderProtocolM1 extending AbstractDecoderProtocol


But there should be only one available instance for

- DecoderProtocolNB

- DecoderProtocolN1
- DecoderProtocolN2

- DecoderProtocolM1

as if they were Enums.


I don't have any idea how to model this with EMF/XCore ...

Any idea/help welcome Smile

thx


br
xjn
Re: [XCORE] How To Design Question: How to model extensible single instances [message #1398745 is a reply to message #1398737] Fri, 11 July 2014 14:13 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 30559
Registered: July 2009
Senior Member
So you basically want to model singletons. That just doesn't fit well
with the design where there's a factory for creating instances. A
singleton generally has a private constructor and static methods to
ensure that only one instance is created. It's just not a good fit for
what EMF is designed to support.

On 11/07/2014 4:01 PM, xjn Mising name wrote:
> Hi,
>
> i have the following design problem using EMF and/or XCore.
> In plain Java it's easy, but i'd like to give EMF/XCore a try for this.
>
> --
>
> I have an abstract base class : class AbstractDecoderProtocol
>
>
> I have a (unknown) number of plugins extending
> AbstractDecoderProtocol, lets assume :
>
>
> - plugin "NB" provides
> -- DecoderProtocolNB extending AbstractDecoderProtocol
>
>
> and
> - pluging "NX" provides
> -- DecoderProtocolN1 extending AbstractDecoderProtocol
> -- DecoderProtocolN2 extending AbstractDecoderProtocol
>
>
> and
> - pluging "M1" provides
> -- DecoderProtocolM1 extending AbstractDecoderProtocol
>
>
> But there should be only one available instance for
>
> - DecoderProtocolNB
>
> - DecoderProtocolN1
> - DecoderProtocolN2
>
> - DecoderProtocolM1
> as if they were Enums.
>
>
> I don't have any idea how to model this with EMF/XCore ...
>
> Any idea/help welcome :)
>
> thx
Re: [XCORE] How To Design Question: How to model extensible single instances [message #1398768 is a reply to message #1398745] Fri, 11 July 2014 14:59 Go to previous messageGo to next message
xjn Mising nameFriend
Messages: 20
Registered: May 2010
Junior Member
Ed,

yes, i want to model Singletons.


I've already modeled Singleton's in 'asm', in 'C', in 'Java', etc.

---

Singletons, especially extensible Singletons, are all around in real
World.

---

There is a "Car-Type", is a "VW", is a "VW-Golf", is a "VW-Golf-V", is a ...

All these are Singleton Enum's, but with derived properties and derived op's.

---

There is one Singleton "VW-Golf-V"-model, but many bought instances ...

I don't have any idea how to model this ...



br
xjn
Re: [XCORE] How To Design Question: How to model extensible single instances [message #1398786 is a reply to message #1398768] Fri, 11 July 2014 15:36 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 30559
Registered: July 2009
Senior Member
Comments below.

On 11/07/2014 4:59 PM, xjn Mising name wrote:
> Ed,
>
> yes, i want to model Singletons.
>
> I've already modeled Singleton's in 'asm', in 'C', in 'Java', etc.
You've implemented it.
>
> ---
>
> Singletons, especially extensible Singletons, are all around in real
> World.
Yes and you can implement them in pretty much any language.
> ---
>
> There is a "Car-Type", is a "VW", is a "VW-Golf", is a "VW-Golf-V", is
> a ...
>
> All these are Singleton Enum's, but with derived properties and
> derived op's.
>
> ---
>
> There is one Singleton "VW-Golf-V"-model, but many bought instances ...
>
> I don't have any idea how to model this ...
As I said, this is not an appropriate domain in which to model. Some
things are best done in Java. Xcore doesn't aim to replace Java, it
aims to be better (less verbose and more flexible) at certain types of
things than Java and to integrate well with Java. In the end Xcore
maps onto Ecore and there is no such concept as a singleton so you can't
model it (with Ecore).
>
>
Previous Topic:[Teneo] Turn off some logging?
Next Topic:null text generated in editor plugin.xml
Goto Forum:
  


Current Time: Thu Oct 24 04:20:10 GMT 2019

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

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

Back to the top