Support for cloneable #142
Labels
cloneable
Component-SyntaxAndParsing
Related to the Umple grammar and the parser that builds the abstract syntax tree and analyses models
Diffic-Hard
Likely not obvious how to fix or reproduce it and may take many weeks by an experienced person
interfaces
patterns
Priority-VLow
This is likely a cosmetic issue or a long-range low-impact wishlist item
Status-Accepted
ucosp
Suitable for 4th year capstone projects
Originally reported on Google Code with ID 242
We should consider allowing a class in umple to be tagged as
cloneable;
This would generate 'implements clone able' in java, and, more importantly would implement
the clone method directly (or standard copying syntax in other languages).
This would be very straight-forward in classes that don't have associations, or where
there is an incoming unidirectional association. In such cases just the attributes
would need cloning.
The main use case would be to duplicate an object and then change it (using a set method)
so that it is just a little different from the original. This is a bit like the concept
of the exemplar. See the 'self' programming language.
Where there are other kinds of associations, this becomes intrinsically tricky. In
many cases, there would have to be a semantic error raised.
For example
class A {}
class B {
cloneable;
1-- * A;
}
would be illogical, since duplicating the B would force the A to then have two attached
B's which violates the multiplicity.
Cloning an entirely immutable object would also be somewhat illogical, since then you
would have two objects with no way to tell them apart. However it would be useful to
create the ability to clone such an object in all respects except for certain attributes,
which would be given different values. For example to move a complex graphical shape
to a new origin (clone, but change the origin).
Reported by @umple on 2011-10-19 20:10:21
The text was updated successfully, but these errors were encountered: