Home » Modeling » UML2 » Is it possible to alias types
| | | | |
Re: Is it possible to alias types [message #477473 is a reply to message #477472] |
Tue, 03 June 2008 10:55 |
Eclipse User |
|
|
|
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. 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.<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">> Felix,</FONT>
<FONT COLOR="#000000">> </FONT>
<FONT COLOR="#000000">> 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 #477488 is a reply to message #477484] |
Wed, 04 June 2008 15:24 |
Rafael Chaves 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 #626649 is a reply to message #477466] |
Tue, 03 June 2008 00:04 |
Ed Merks 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 #626655 is a reply to message #477472] |
Tue, 03 June 2008 10:55 |
Eclipse User |
|
|
|
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. 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.<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">> Felix,</FONT>
<FONT COLOR="#000000">> </FONT>
<FONT COLOR="#000000">> 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 #626670 is a reply to message #477484] |
Wed, 04 June 2008 15:24 |
Rafael Chaves 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
|
|
| |
Goto Forum:
Current Time: Fri Apr 26 07:42:47 GMT 2024
Powered by FUDForum. Page generated in 0.04911 seconds
|