google-code-export / umple

Automatically exported from code.google.com/p/umple
1 stars 0 forks source link

Support for cloneable #242

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
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).

Original issue reported on code.google.com by TimothyCLethbridge on 19 Oct 2011 at 8:10

GoogleCodeExporter commented 9 years ago

Original comment by TimothyCLethbridge on 27 Sep 2012 at 8:07

GoogleCodeExporter commented 9 years ago

Original comment by TimothyCLethbridge on 12 Sep 2013 at 3:07

GoogleCodeExporter commented 9 years ago

Original comment by TimothyCLethbridge on 17 Sep 2013 at 1:30

GoogleCodeExporter commented 9 years ago

Original comment by TimothyCLethbridge on 5 Sep 2014 at 3:00