Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » UML2 » defining a new data type
defining a new data type [message #1384732] Fri, 30 May 2014 21:11 Go to next message
Jeni Martin is currently offline Jeni MartinFriend
Messages: 42
Registered: November 2012
Member
Hi,

My question is that how Boolean as data type is defined so that it has the operation of equality? Does it have any attributes? How the operands are shown?
I want to use a similar concept for defining a new datatype that its operation is to sum the value of attributes for two instances of a class.

So I have a class which the type of one of its attributes is a data type that I have defined.
This data type has the operation of addition. But I don't know how this operation can be defined while this data type does not have any specific attributes.

Thank you very much,
Mahin
Re: defining a new data type [message #1384745 is a reply to message #1384732] Sat, 31 May 2014 07:14 Go to previous messageGo to next message
Ed Willink is currently offline Ed WillinkFriend
Messages: 7655
Registered: July 2009
Senior Member
Hi

DataTypes are opaque values and so a Date has an obvious value that may
be partitioned into smaller values. How it is implemented is not relevant.

DataTypes cannot be instantiated so they are always compared by deep
equality of value, whereas Classes are compared (in OCL) by object
identity/address.

In UML you can define operations for DataTypes and in OCL you can define
additional operations for DataTypes.

In order for an addition operator to be meaningful there needs to be
agreement on how 'add' is spelled. Since UML supports arbitrary names
'+' is obvious but it doesn't convert to Java so other names have been
used and I think the OCL UML/Ecore support looks for 'add'. Then there
is the problem of the argument type; is it polymorphic or not. Eclipse
OCL adds the polymorphic type OclSelf to repeat the source type. As
specification get firmer hopefully XXXX::_'+'(OclSelf) will standardize;
_'xxxx' is the OCL escape for names with awkward characters.

In the case of Date, you could implement all your operations by
delegating to java.lang.Date and so need no detailed attributes.

For your own type if you actually implement then you need attributes, so
you could delegate to a Class, or use a Class in the first place.

Regards

Ed Willink


On 30/05/2014 22:11, Jeni Martin wrote:
> Hi,
>
> My question is that how Boolean as data type is defined so that it has
> the operation of equality? Does it have any attributes? How the
> operands are shown?
> I want to use a similar concept for defining a new datatype that its
> operation is to sum the value of attributes for two instances of a class.
>
> So I have a class which the type of one of its attributes is a data
> type that I have defined.
> This data type has the operation of addition. But I don't know how
> this operation can be defined while this data type does not have any
> specific attributes.
>
> Thank you very much,
> Mahin
Re: defining a new data type [message #1400936 is a reply to message #1384745] Mon, 14 July 2014 23:28 Go to previous messageGo to next message
Jeni Martin is currently offline Jeni MartinFriend
Messages: 42
Registered: November 2012
Member
Thank you very much for your reply. But I am not sure if I got it. Maybe I have asked wrongly. Suppose in a profile, I have defined two stereotypes (A and B) that extend the metaclass "Class". They both have an attribute called "a" and "b". Now, for instances of Stereotype A, I want to add the the values of attribute "a" altogether, while for any instances of stereotype B, I want to take the maximum of attribute "b" among them.
I thought maybe one solution is to define two different Data types for the type of "a" and "b" that each have their own operations. But I don't know how to define their operations while they don't have specific attributes. If I want to do it in a uml profile, How should I do that?

Thank you.
Re: defining a new data type [message #1438630 is a reply to message #1400936] Mon, 06 October 2014 09:45 Go to previous message
Evan Raymonds is currently offline Evan RaymondsFriend
Messages: 5
Registered: August 2013
Junior Member
In UML 2 defining data is different refer uml.org for more details
Previous Topic:exception when creating genmodel (Juno)
Next Topic:Anyone developing Professional Software using UML diagrams and Eclipse?
Goto Forum:
  


Current Time: Fri Mar 29 13:00:23 GMT 2024

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

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

Back to the top