Responding to Safa...
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
could you please clarify their semantics ?
because i don't know how such a data type has attributes and
operations?
The proper terminology in OO circles is
abstract data type,
or ADT. An attribute is an abstraction of knowledge; it simply
identifies something that all entities in a class should know. Note
that such a definition is independent of the computing environment.
Data, OTOH, are values and they have a concrete representation in
computer memory. Generally the computer has a very generic set of
valid types for data -- integer, real, character, etc. Using
hardware-based data types ties one to specific computing platforms.
If one wants to move the program to a different computer, one may
have to modify the data types for the new computing environment. To
get around that problem one can define ADTs in UML that abstract the
data in problem space terms so that the model is portable without
change across platforms. ADTs also allow one to provide types for
knowledge values that are more relevant to the problem space --
money, volume, length, count, etc. This allows much greater
discrimination among types than computer hardware provides, which is
useful for thing like automated error checking (e.g., detecting
adding a money value to a length value). One can then map the ADTs
to hardware storage types when actually implementing the model.
However, since classes only define what their member objects must
know, there is a subtle difference between a class attribute and
data -- the attribute knowledge does not need to be stored; the
object could compute the value of the knowledge whenever it is asked
for it. Thus an ADT can also have operations when it is actually
implemented. (It can have other operations that are very convenient,
such as synchronizing values of the same attribute in different
subsystems when a value is modified.)
Thus the best way to think of an ADT is that it is a type mechanism
to map knowledge attributes to specific implementation environments.
ADTs are typically defined externally to the UML model (i.e., they
are part of the MDA transformation rules used to transform the UML
model to a different model, like a C program). Thus the
transformation rule might say that a 'money' ADT in the model must
be stored as a BCD value in memory. When one wants to port the model
to a different environment, one just needs to change the ADT
definitions (at most) and doesn't need to touch the model itself.
Thus ADTs characterize class attributes, but they are quite
different things.
2)What�s the main differences between class and datatype?
At the Assembly level, it is almost impossible to tell the
difference. When UML models are transformed to non-OOPLs, like C,
via a code generator there is very little difference.� When UML
models are transformed to an OOPL, like C++, ADTs will be explicitly
defined in header files for the mapping to storage types and
explicit getters/setters will be provided operations.
Basically a class defines a set of objects in terms of the unique
suite of problem space knowledge (attributes) and behavior
(operations) every member object must have. ADTs qualify the
knowledge with an abstract type that will be used to map between the
problem space ADT in the model and the hardware.
--
Life is the only flaw in an otherwise perfect nonexistence
-- Schopenhauer
Imagine how much more difficult physics would be if electrons had feelings
-- Richard Feynman
Rene Descartes went into a bar. The bartender asked if he would like a drink. Descartes said, "I think not," and disappeared.
H. S. Lahman
H.la...@verizon.net
software blog: http://pathfinderpeople.blogs.com/hslahman/index.html
software book: Model Based Development, Addison-Wesley, 2011
geology book: The Evolution and Utilization of Marine Resources, MIT Press, 1972