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: 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 Subject: Re: The python implementation of the "relationships between classes". Date: Thu, 10 Nov 2011 14:38:58 -0500 References: 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: X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.12 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: 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 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