The python implementation of the "relationships between classes".

Jerry Zhang jerry.scofield at gmail.com
Thu Nov 10 20:34:30 EST 2011


2011/11/11 Terry Reedy <tjreedy at udel.edu>

> On 11/10/2011 9:31 AM, Jerry Zhang wrote:
>
>     Unfortunately there is a difference between composition and
>>    aggregation in my real word, and my application really care this
>>    since it is trying to simulate this real world model, so my system
>>    should track this difference accurately, otherwise the system may
>>    not work well.
>>
>>    For example,
>>    a. the Cls_arm and Cls_body may be composition, but not aggregation.
>>    My app must ensure that " one arm instance only live with one body
>>    instance, if the body instance die, the arm instance must die.
>>
>
> Create the arm as a private member '_arm' of body and make sure that no
> method of body passes out a reference to the arm. (In Python, outside code
> can still grab a reference to the private attribute, but that is a coding
> bug.)
>
> I will point out that in the real world, dead donor transplants are based
> on the fact the parts of the body do NOT have to die when the composition
> does. I will not be surprised if we someday see arm transplants.

Thanks for your comment.
Actually you are mixing the concept. That is aggregation implementation,
which also points out there is difference between aggregation and
composition implementation. You already know that.

>
>
> --
> Terry Jan Reedy
>
> --
> http://mail.python.org/**mailman/listinfo/python-list<http://mail.python.org/mailman/listinfo/python-list>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20111111/648c592f/attachment-0001.html>


More information about the Python-list mailing list