Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » UML2 » Is it possible to alias types
Is it possible to alias types [message #477466] Mon, 02 June 2008 21:19 Go to next message
Felix Dorner is currently offline Felix DornerFriend
Messages: 676
Registered: July 2009
Senior Member
Hi,

Is it somehow possible to create an alias for a type, say I want to use
"Year" instead of "Integer". The only way I find is via ElementImport,
but I don't know if its alias field is meant for such purposes..

Felix
Re: Is it possible to alias types [message #477467 is a reply to message #477466] Tue, 03 June 2008 00:04 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 33142
Registered: July 2009
Senior Member
Felix,

I don't think so. What's ElementImport?


Felix Dorner wrote:
> Hi,
>
> Is it somehow possible to create an alias for a type, say I want to
> use "Year" instead of "Integer". The only way I find is via
> ElementImport, but I don't know if its alias field is meant for such
> purposes..
>
> Felix


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Is it possible to alias types [message #477468 is a reply to message #477466] Tue, 03 June 2008 00:36 Go to previous messageGo to next message
Kenn Hussey is currently offline Kenn HusseyFriend
Messages: 1620
Registered: July 2009
Senior Member
Felix,

This property is typically used to disamiguate between members of a
namespace when there is a naming conflict...

Kenn

"Felix Dorner" <felix_do@web.de> wrote in message
news:g21o4v$kvm$1@build.eclipse.org...
> Hi,
>
> Is it somehow possible to create an alias for a type, say I want to use
> "Year" instead of "Integer". The only way I find is via ElementImport, but
> I don't know if its alias field is meant for such purposes..
>
> Felix
Re: Is it possible to alias types [message #477471 is a reply to message #477468] Tue, 03 June 2008 10:20 Go to previous messageGo to next message
Felix Dorner is currently offline Felix DornerFriend
Messages: 676
Registered: July 2009
Senior Member
Kenn Hussey wrote:
> Felix,
>
> This property is typically used to disamiguate between members of a
> namespace when there is a naming conflict...

Yes, thats what i thought. It would also look stupid to import an
element into its own namespace (dont even know if its possible) just to
give it an alias. But are you understanding what I want to do?(I guess I
want something like in c typedefs)

Felix
Re: Is it possible to alias types [message #477472 is a reply to message #477467] Tue, 03 June 2008 10:23 Go to previous messageGo to next message
Felix Dorner is currently offline Felix DornerFriend
Messages: 676
Registered: July 2009
Senior Member
Ed Merks wrote:
> Felix,
>
> I don't think so. What's ElementImport?

Small brother of PackageImport. Instead of a package, imports a single
Element into a namespace. You can give the imported element an alias,
but that is how Kenn said intended to be used to avoid name clashes. It
would be interesting to check out how OCL handles aliased imported elements.

Felix
Re: Is it possible to alias types [message #477473 is a reply to message #477472] Tue, 03 June 2008 10:55 Go to previous messageGo to next message
Eclipse UserFriend
Originally posted by: cdamus.zeligsoft.com

--=-Rw+jCRj8lhtiA1lzhSP+
Content-Type: text/plain
Content-Transfer-Encoding: 7bit

Hi, Felix,

AFAIK, the MDT OCL binding for UML uses the
Namespace.getMember(String, ...) API to look up elements in a namespace
by name. This should handle imports with aliases, but you'd best try it
and see. I don't think we have any JUnit tests covering it.

cW

On Tue, 2008-06-03 at 12:23 +0200, Felix Dorner wrote:

> Ed Merks wrote:
> > Felix,
> >
> > I don't think so. What's ElementImport?
>
> Small brother of PackageImport. Instead of a package, imports a single
> Element into a namespace. You can give the imported element an alias,
> but that is how Kenn said intended to be used to avoid name clashes. It
> would be interesting to check out how OCL handles aliased imported elements.
>
> Felix

--=-Rw+jCRj8lhtiA1lzhSP+
Content-Type: text/html; charset=utf-8

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 TRANSITIONAL//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=UTF-8">
<META NAME="GENERATOR" CONTENT="GtkHTML/3.16.0">
</HEAD>
<BODY>
Hi, Felix,<BR>
<BR>
AFAIK, the MDT OCL binding for UML uses the Namespace.getMember(String, ...) API to look up elements in a namespace by name.&nbsp; This should handle imports with aliases, but you'd best try it and see.&nbsp; I don't think we have any JUnit tests covering it.<BR>
<BR>
cW<BR>
<BR>
On Tue, 2008-06-03 at 12:23 +0200, Felix Dorner wrote:
<BLOCKQUOTE TYPE=CITE>
<PRE>
<FONT COLOR="#000000">Ed Merks wrote:</FONT>
<FONT COLOR="#000000">&gt; Felix,</FONT>
<FONT COLOR="#000000">&gt; </FONT>
<FONT COLOR="#000000">&gt; I don't think so. What's ElementImport?</FONT>

<FONT COLOR="#000000">Small brother of PackageImport. Instead of a package, imports a single </FONT>
<FONT COLOR="#000000">Element into a namespace. You can give the imported element an alias, </FONT>
<FONT COLOR="#000000">but that is how Kenn said intended to be used to avoid name clashes. It </FONT>
<FONT COLOR="#000000">would be interesting to check out how OCL handles aliased imported elements.</FONT>

<FONT COLOR="#000000">Felix</FONT>
</PRE>
</BLOCKQUOTE>
</BODY>
</HTML>

--=-Rw+jCRj8lhtiA1lzhSP+--
Re: Is it possible to alias types [message #477482 is a reply to message #477471] Wed, 04 June 2008 03:48 Go to previous messageGo to next message
Rafael Chaves is currently offline Rafael ChavesFriend
Messages: 362
Registered: July 2009
Senior Member
I have never seen anything like that, Felix. I can't see how it would be
useful in UML anyway. Multiplicity, for instance, does not apply to the
type itself, but to the typed element (if it happens to be a
MultiplicityElement).

Cheers,

Rafael

Felix Dorner wrote:
> Kenn Hussey wrote:
>> Felix,
>>
>> This property is typically used to disamiguate between members of a
>> namespace when there is a naming conflict...
>
> Yes, thats what i thought. It would also look stupid to import an
> element into its own namespace (dont even know if its possible) just to
> give it an alias. But are you understanding what I want to do?(I guess I
> want something like in c typedefs)
>
> Felix
Re: Is it possible to alias types [message #477484 is a reply to message #477482] Wed, 04 June 2008 06:33 Go to previous messageGo to next message
Felix Dorner is currently offline Felix DornerFriend
Messages: 676
Registered: July 2009
Senior Member
Rafael Chaves wrote:
> I have never seen anything like that, Felix. I can't see how it would be
> useful in UML anyway.

So C has a higher abstraction level than UML regarding this? :-)

I think it is certainly be useful to abstract over names, we do it all
the time in the real life.. Giving a "thing", such as a type, an alias
that fits better in the domain context can definitely help to obtain a
more abstract or seamless view on what is being represented.

> Multiplicity, for instance, does not apply to the
> type itself, but to the typed element (if it happens to be a
> MultiplicityElement).

I don't see how this is related. Can you explain further?

Greetings,
Felix
Re: Is it possible to alias types [message #477488 is a reply to message #477484] Wed, 04 June 2008 15:24 Go to previous messageGo to next message
Rafael Chaves is currently offline Rafael ChavesFriend
Messages: 362
Registered: July 2009
Senior Member
Hi Felix,

Felix Dorner wrote:
> Rafael Chaves wrote:
>> I have never seen anything like that, Felix. I can't see how it would
>> be useful in UML anyway.
>
> So C has a higher abstraction level than UML regarding this? :-)

Not sure I agree typedefs increase the level of abstraction. Also, even
though UML combines features of many different programming languages, it
certainly omits one or another. That does ot mean you cannot map between
UML and language-specific constructs when generating code or building
models from parsing existing code.

Also, Java certainly has a higher abstraction level than C and does not
have them either... ;)

>
> I think it is certainly be useful to abstract over names, we do it all
> the time in the real life.. Giving a "thing", such as a type, an alias
> that fits better in the domain context can definitely help to obtain a
> more abstract or seamless view on what is being represented.

AFAIK, typedefs have two usages: aliasing existing types and giving
names to types that would otherwise not have a name (typedef int[]
arrayint, for instance).

For the simple aliasing case, you can use element imports, something you
were already considering. Renaming types created in your own package
don't make much sense - why wouldn't you create it using the name you
wanted right away?

>
>> Multiplicity, for instance, does not apply to the type itself, but to
>> the typed element (if it happens to be a MultiplicityElement).
>
> I don't see how this is related. Can you explain further?

For the case of giving a name to a more complex type (for instance,
typedef Account[] accountArray), well, that does not apply to UML,
because the multiplicity is never defined in the type itself, but in the
thing being typed.

So if in C you would have:

typedef Account[] AccountArray;

AccountArray allAccounts;

In UML, if allAccounts were a Property, the property would have Account
as its type and the property itself (and not its type) would have an
upperBound > 1.

Hope that clarified. You might also be interested in this:

http://abstratt.com/wiki/index.php?title=UML_101_Multiplicit y

Cheers,

Rafael
Re: Is it possible to alias types [message #477490 is a reply to message #477488] Wed, 04 June 2008 18:19 Go to previous message
Felix Dorner is currently offline Felix DornerFriend
Messages: 676
Registered: July 2009
Senior Member
Hey Rafa,

> Not sure I agree typedefs increase the level of abstraction.

You mean that it might confuse more than it helps?

>
> Also, Java certainly has a higher abstraction level than C and does not
> have them either... ;)

I have read something in a Java 7 wishlist
(http://blogs.sun.com/ahe/entry/java_se_7_wish_list) that would allow to:


import java.util.List<String> as StringList;

The comments on that idea are well.. shared.

> For the case of giving a name to a more complex type (for instance,
> typedef Account[] accountArray), well, that does not apply to UML,
> because the multiplicity is never defined in the type itself, but in the
> thing being typed.

Right.

seeya,
Felix
Re: Is it possible to alias types [message #626649 is a reply to message #477466] Tue, 03 June 2008 00:04 Go to previous message
Ed Merks is currently offline Ed MerksFriend
Messages: 33142
Registered: July 2009
Senior Member
Felix,

I don't think so. What's ElementImport?


Felix Dorner wrote:
> Hi,
>
> Is it somehow possible to create an alias for a type, say I want to
> use "Year" instead of "Integer". The only way I find is via
> ElementImport, but I don't know if its alias field is meant for such
> purposes..
>
> Felix


Ed Merks
Professional Support: https://www.macromodeling.com/
Re: Is it possible to alias types [message #626650 is a reply to message #477466] Tue, 03 June 2008 00:36 Go to previous message
Kenn Hussey is currently offline Kenn HusseyFriend
Messages: 1620
Registered: July 2009
Senior Member
Felix,

This property is typically used to disamiguate between members of a
namespace when there is a naming conflict...

Kenn

"Felix Dorner" <felix_do@web.de> wrote in message
news:g21o4v$kvm$1@build.eclipse.org...
> Hi,
>
> Is it somehow possible to create an alias for a type, say I want to use
> "Year" instead of "Integer". The only way I find is via ElementImport, but
> I don't know if its alias field is meant for such purposes..
>
> Felix
Re: Is it possible to alias types [message #626653 is a reply to message #477468] Tue, 03 June 2008 10:20 Go to previous message
Felix Dorner is currently offline Felix DornerFriend
Messages: 676
Registered: July 2009
Senior Member
Kenn Hussey wrote:
> Felix,
>
> This property is typically used to disamiguate between members of a
> namespace when there is a naming conflict...

Yes, thats what i thought. It would also look stupid to import an
element into its own namespace (dont even know if its possible) just to
give it an alias. But are you understanding what I want to do?(I guess I
want something like in c typedefs)

Felix
Re: Is it possible to alias types [message #626654 is a reply to message #477467] Tue, 03 June 2008 10:23 Go to previous message
Felix Dorner is currently offline Felix DornerFriend
Messages: 676
Registered: July 2009
Senior Member
Ed Merks wrote:
> Felix,
>
> I don't think so. What's ElementImport?

Small brother of PackageImport. Instead of a package, imports a single
Element into a namespace. You can give the imported element an alias,
but that is how Kenn said intended to be used to avoid name clashes. It
would be interesting to check out how OCL handles aliased imported elements.

Felix
Re: Is it possible to alias types [message #626655 is a reply to message #477472] Tue, 03 June 2008 10:55 Go to previous message
Eclipse UserFriend
Originally posted by: cdamus.zeligsoft.com

--=-Rw+jCRj8lhtiA1lzhSP+
Content-Type: text/plain
Content-Transfer-Encoding: 7bit

Hi, Felix,

AFAIK, the MDT OCL binding for UML uses the
Namespace.getMember(String, ...) API to look up elements in a namespace
by name. This should handle imports with aliases, but you'd best try it
and see. I don't think we have any JUnit tests covering it.

cW

On Tue, 2008-06-03 at 12:23 +0200, Felix Dorner wrote:

> Ed Merks wrote:
> > Felix,
> >
> > I don't think so. What's ElementImport?
>
> Small brother of PackageImport. Instead of a package, imports a single
> Element into a namespace. You can give the imported element an alias,
> but that is how Kenn said intended to be used to avoid name clashes. It
> would be interesting to check out how OCL handles aliased imported elements.
>
> Felix

--=-Rw+jCRj8lhtiA1lzhSP+
Content-Type: text/html; charset=utf-8

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 TRANSITIONAL//EN">
<HTML>
<HEAD>
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; CHARSET=UTF-8">
<META NAME="GENERATOR" CONTENT="GtkHTML/3.16.0">
</HEAD>
<BODY>
Hi, Felix,<BR>
<BR>
AFAIK, the MDT OCL binding for UML uses the Namespace.getMember(String, ...) API to look up elements in a namespace by name.&nbsp; This should handle imports with aliases, but you'd best try it and see.&nbsp; I don't think we have any JUnit tests covering it.<BR>
<BR>
cW<BR>
<BR>
On Tue, 2008-06-03 at 12:23 +0200, Felix Dorner wrote:
<BLOCKQUOTE TYPE=CITE>
<PRE>
<FONT COLOR="#000000">Ed Merks wrote:</FONT>
<FONT COLOR="#000000">&gt; Felix,</FONT>
<FONT COLOR="#000000">&gt; </FONT>
<FONT COLOR="#000000">&gt; I don't think so. What's ElementImport?</FONT>

<FONT COLOR="#000000">Small brother of PackageImport. Instead of a package, imports a single </FONT>
<FONT COLOR="#000000">Element into a namespace. You can give the imported element an alias, </FONT>
<FONT COLOR="#000000">but that is how Kenn said intended to be used to avoid name clashes. It </FONT>
<FONT COLOR="#000000">would be interesting to check out how OCL handles aliased imported elements.</FONT>

<FONT COLOR="#000000">Felix</FONT>
</PRE>
</BLOCKQUOTE>
</BODY>
</HTML>

--=-Rw+jCRj8lhtiA1lzhSP+--
Re: Is it possible to alias types [message #626664 is a reply to message #477471] Wed, 04 June 2008 03:48 Go to previous message
Rafael Chaves is currently offline Rafael ChavesFriend
Messages: 362
Registered: July 2009
Senior Member
I have never seen anything like that, Felix. I can't see how it would be
useful in UML anyway. Multiplicity, for instance, does not apply to the
type itself, but to the typed element (if it happens to be a
MultiplicityElement).

Cheers,

Rafael

Felix Dorner wrote:
> Kenn Hussey wrote:
>> Felix,
>>
>> This property is typically used to disamiguate between members of a
>> namespace when there is a naming conflict...
>
> Yes, thats what i thought. It would also look stupid to import an
> element into its own namespace (dont even know if its possible) just to
> give it an alias. But are you understanding what I want to do?(I guess I
> want something like in c typedefs)
>
> Felix
Re: Is it possible to alias types [message #626666 is a reply to message #477482] Wed, 04 June 2008 06:33 Go to previous message
Felix Dorner is currently offline Felix DornerFriend
Messages: 676
Registered: July 2009
Senior Member
Rafael Chaves wrote:
> I have never seen anything like that, Felix. I can't see how it would be
> useful in UML anyway.

So C has a higher abstraction level than UML regarding this? :-)

I think it is certainly be useful to abstract over names, we do it all
the time in the real life.. Giving a "thing", such as a type, an alias
that fits better in the domain context can definitely help to obtain a
more abstract or seamless view on what is being represented.

> Multiplicity, for instance, does not apply to the
> type itself, but to the typed element (if it happens to be a
> MultiplicityElement).

I don't see how this is related. Can you explain further?

Greetings,
Felix
Re: Is it possible to alias types [message #626670 is a reply to message #477484] Wed, 04 June 2008 15:24 Go to previous message
Rafael Chaves is currently offline Rafael ChavesFriend
Messages: 362
Registered: July 2009
Senior Member
Hi Felix,

Felix Dorner wrote:
> Rafael Chaves wrote:
>> I have never seen anything like that, Felix. I can't see how it would
>> be useful in UML anyway.
>
> So C has a higher abstraction level than UML regarding this? :-)

Not sure I agree typedefs increase the level of abstraction. Also, even
though UML combines features of many different programming languages, it
certainly omits one or another. That does ot mean you cannot map between
UML and language-specific constructs when generating code or building
models from parsing existing code.

Also, Java certainly has a higher abstraction level than C and does not
have them either... ;)

>
> I think it is certainly be useful to abstract over names, we do it all
> the time in the real life.. Giving a "thing", such as a type, an alias
> that fits better in the domain context can definitely help to obtain a
> more abstract or seamless view on what is being represented.

AFAIK, typedefs have two usages: aliasing existing types and giving
names to types that would otherwise not have a name (typedef int[]
arrayint, for instance).

For the simple aliasing case, you can use element imports, something you
were already considering. Renaming types created in your own package
don't make much sense - why wouldn't you create it using the name you
wanted right away?

>
>> Multiplicity, for instance, does not apply to the type itself, but to
>> the typed element (if it happens to be a MultiplicityElement).
>
> I don't see how this is related. Can you explain further?

For the case of giving a name to a more complex type (for instance,
typedef Account[] accountArray), well, that does not apply to UML,
because the multiplicity is never defined in the type itself, but in the
thing being typed.

So if in C you would have:

typedef Account[] AccountArray;

AccountArray allAccounts;

In UML, if allAccounts were a Property, the property would have Account
as its type and the property itself (and not its type) would have an
upperBound > 1.

Hope that clarified. You might also be interested in this:

http://abstratt.com/wiki/index.php?title=UML_101_Multiplicit y

Cheers,

Rafael
Re: Is it possible to alias types [message #626672 is a reply to message #477488] Wed, 04 June 2008 18:19 Go to previous message
Felix Dorner is currently offline Felix DornerFriend
Messages: 676
Registered: July 2009
Senior Member
Hey Rafa,

> Not sure I agree typedefs increase the level of abstraction.

You mean that it might confuse more than it helps?

>
> Also, Java certainly has a higher abstraction level than C and does not
> have them either... ;)

I have read something in a Java 7 wishlist
(http://blogs.sun.com/ahe/entry/java_se_7_wish_list) that would allow to:


import java.util.List<String> as StringList;

The comments on that idea are well.. shared.

> For the case of giving a name to a more complex type (for instance,
> typedef Account[] accountArray), well, that does not apply to UML,
> because the multiplicity is never defined in the type itself, but in the
> thing being typed.

Right.

seeya,
Felix
Previous Topic:[Announce] MDT UML2 2.2.0RC3 is available
Next Topic:Proposed criteria for editing property subsets and element redefinitions
Goto Forum:
  


Current Time: Fri Apr 26 07:42:47 GMT 2024

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

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

Back to the top