what is the differences between class and dataType

Andrew picture Andrew · Apr 3, 2013 · Viewed 8.8k times · Source

As i read through UML specification that:

 class has a set of attributes/operations
and data type has a set of attributes/operations

1)with regards to attributes/operations of data type what this means?

because i don't know how such a data type has attributes and operations?

2)What’s the main difference between a class and a datatype?

Answer

Red Beard picture Red Beard · Apr 3, 2013

according to UML 2.4.1 specification

A data type is a special kind of classifier, similar to a class. It differs from a class in that instances of a data type are identified only by their value. All copies of an instance of a data type and any instances of that data type with the same value are considered to be equal instances. Instances of a data type that have attributes (i.e., is a structured data type) are considered to be equal if the structure is the same and the values of the corresponding attributes are equal. If a data type has attributes, then instances of that data type will contain attribute values matching the attributes.

1)Attributes/operations of data type have the same meaning than attributes/operations of classes i.e. attributes represent the structure of your data type and operations represent the method available on your data type.

2)The main difference between a class and a datatype is that it is not possible to have two instances of a datatype with the same values (these instance would be one unique instance).

Hoping it helps,

RB