Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #15557
| From | Terry Reedy <tjreedy@udel.edu> |
|---|---|
| Subject | Re: The python implementation of the "relationships between classes". |
| Date | 2011-11-10 14:38 -0500 |
| References | (1 earlier) <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> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.2614.1320953960.27778.python-list@python.org> (permalink) |
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 | Next — Next in thread | Find similar | Unroll 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