Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #15557

Re: The python implementation of the "relationships between classes".

Path csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.albasani.net!feeder.erje.net!newsfeed.xs4all.nl!newsfeed5.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <python-python-list@m.gmane.org>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.000
X-Spam-Evidence '*H*': 1.00; '*S*': 0.00; 'python,': 0.01; 'instance,': 0.05; 'passes': 0.05; 'does.': 0.07; 'received:verizon.net': 0.07; 'terry': 0.07; 'donor': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:80.91.229.12': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'received:lo.gmane.org': 0.09; 'subject:python': 0.11; 'am,': 0.12; '11/10/2011': 0.16; '9:31': 0.16; 'aggregation': 0.16; 'arm.': 0.16; 'attribute,': 0.16; 'die,': 0.16; 'reedy': 0.16; 'simulate': 0.16; 'subject:between': 0.16; 'subject:classes': 0.16; 'wrote:': 0.18; 'instance': 0.18; 'model,': 0.18; 'jan': 0.19; 'trying': 0.21; 'header:In-Reply- To:1': 0.23; 'code': 0.25; '(in': 0.26; 'fact': 0.27; 'coding': 0.32; 'app': 0.32; 'to:addr:python-list': 0.32; 'there': 0.33; 'header:User-Agent:1': 0.33; 'header:X-Complaints-To:1': 0.33; 'arm': 0.34; 'surprised': 0.34; 'example,': 0.36; 'reference': 0.37; 'but': 0.37; 'received:org': 0.37; 'word,': 0.38; 'should': 0.39; 'subject:: ': 0.39; 'to:addr:python.org': 0.39; 'difference': 0.40; 'really': 0.40; 'body': 0.61; 'die': 0.61; 'world': 0.62; 'grab': 0.65; 'care': 0.70; 'subject:The': 0.72; 'dead': 0.77; 'composition': 0.84; 'zhang': 0.84
X-Injected-Via-Gmane http://gmane.org/
To python-list@python.org
From Terry Reedy <tjreedy@udel.edu>
Subject Re: The python implementation of the "relationships between classes".
Date Thu, 10 Nov 2011 14:38:58 -0500
References <CANVwdDr-6x8bt4iNL+Q=jZ7+edk7XbR2K_LeJC3Z60qy=vVFQA@mail.gmail.com> <CAPTjJmoOBTiRE8vUNz_xQcwDZA6gazG1fAMkFfhPMomtAKtp6w@mail.gmail.com> <CANVwdDr6qBueBGXykLrhH+MLiwyozD_U1+YRBnrWNfge0=uvDQ@mail.gmail.com> <CAPTjJmqkH6WzbEXWLf6T9yyJyfkH-yCFk1HWd_Vrqwi7iz3FrQ@mail.gmail.com> <CANVwdDqYt+YiJ-hz1F7r+HWnQvFRaJzHvESGoiJu5TKdKE5W7Q@mail.gmail.com> <CANVwdDpSP8fCpHnMvfA5tf9n1iut1_A_1jxqnnKykeMzXygtwg@mail.gmail.com>
Mime-Version 1.0
Content-Type text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding 7bit
X-Gmane-NNTP-Posting-Host pool-74-109-121-73.phlapa.fios.verizon.net
User-Agent Mozilla/5.0 (Windows NT 6.1; WOW64; rv:8.0) Gecko/20111105 Thunderbird/8.0
In-Reply-To <CANVwdDpSP8fCpHnMvfA5tf9n1iut1_A_1jxqnnKykeMzXygtwg@mail.gmail.com>
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.12
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <http://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <http://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.2614.1320953960.27778.python-list@python.org> (permalink)
Lines 25
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1320953960 news.xs4all.nl 6851 [2001:888:2000:d::a6]:50286
X-Complaints-To abuse@xs4all.nl
Xref x330-a1.tempe.blueboxinc.net comp.lang.python:15557

Show key headers only | View raw


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.

-- 
Terry Jan Reedy

Back to comp.lang.python | Previous | NextNext in thread | Find similar | Unroll thread


Thread

Re: The python implementation of the "relationships between classes". Terry Reedy <tjreedy@udel.edu> - 2011-11-10 14:38 -0500
  Re: The python implementation of the "relationships between classes". Steven D'Aprano <steve+comp.lang.python@pearwood.info> - 2011-11-10 22:48 +0000
    Re: The python implementation of the "relationships between classes". Chris Kaynor <ckaynor@zindagigames.com> - 2011-11-10 15:14 -0800
    Re: The python implementation of the "relationships between classes". Chris Angelico <rosuav@gmail.com> - 2011-11-11 10:39 +1100

csiph-web