From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: fac41,9a0ff0bffdf63657 X-Google-Attributes: gidfac41,public X-Google-Thread: f43e6,9a0ff0bffdf63657 X-Google-Attributes: gidf43e6,public X-Google-Thread: 103376,4b06f8f15f01a568 X-Google-Attributes: gid103376,public X-Google-Thread: 1108a1,9a0ff0bffdf63657 X-Google-Attributes: gid1108a1,public From: "Robert Martin" Subject: Re: Which wastes more time? (Was Re: Software landmines (loops)) Date: 1998/09/05 Message-ID: <6ssmjd$h0l$1@hirame.wwa.com>#1/1 X-Deja-AN: 388289084 References: <6rfra4$rul$1@nnrp1.dejanews.com> <35DBDD24.D003404D@calfp.co.uk> <6sbuod$fra$1@hirame.wwa.com> <6sebjr$b69$1@nnrp1.dejanews.com> <6sff74$q0s@gurney.reilly.home> <6sh2j5$jnl$1@nnrp1.dejanews.com> <35EC2E5A.16DB6CB1@bigfoot-.com> <6sjc0a$1lk$3@news.indigo.ie> <35EFB09E.15412933@s054.aone.net.au> <35f2bd98.40599408@news.erols.com> <35F06A58.F968BDE1@s054.aone.net.au> <35f48276.90997557@news.erols.com> <35F0C3C9.D1E56FF3@s054.aone.net.au> <6srh67$sj5$1@hirame.wwa.com> <35F1C0B9.8A50CEB0@s054.aone.net.au> X-MimeOLE: Produced By Microsoft MimeOLE V4.72.2106.4 Organization: WorldWide Access - Midwestern Internet Services - www.wwa.com Newsgroups: comp.lang.eiffel,comp.object,comp.software-eng,comp.lang.ada Date: 1998-09-05T00:00:00+00:00 List-Id: Loryn Jenkins wrote in message <35F1C0B9.8A50CEB0@s054.aone.net.au>... >rmartin wrote: >> Meyer presents a model in which >> CAR_OWNER inherits from PERSON and uses CAR. And this is certainly a much >> better model. > >Agreed. But it still flouts basic classification theory. >From a global point of view, I agree. In the global sense, CAR_OWNER is a role of PERSON. It can also be a role of COMPANY, or TRUST, or any number of other responsible entities. However, from the limited view of a particular application domain, it may be quite acceptable for CAR_OWNER to be derived from PERSON; especially if the application domain puts very little semantics into PERSON. You might complain that it is better to take the global view; but this is clearly impractical. The essence of modeling is to take a limited view. Clearly we have to be careful about choosing that view. But from the context of Meyer's example it is not feasible to determine whether his view is acceptable or not. > >I find this test to be a very useful in finding whether a (sub-type) >inheritance relationship should hold: > >Is the child class a type of the parent class, and will it be for the >whole of its existence? And, is the parent class a supertype of the >child class, and will it be for the whole of its existence? Agreed, this is a good test. And I would agree that in very many cases your analysis of the CAR_OWNER situation is correct. But you cannot insist that it is correct for *all* cases. And that makes Meyer's example valid. > >That is, in this example: >(1) Is a CAR_OWNER a PERSON, and will it be for the whole of its >existence? >(A1) Yes. > >(2) Is a PERSON a CAR_OWNER, and will it be for the whole of its >existence? >(A2) No. Any PERSON can buy and sell cars, moving its status from car >owner to not multiple times during their life. However, it may be that the application domain is one that studies cars and their owners during one single instant of time. In which case (2) will always hold. >As far as I'm concerned, this flouts basic classification theory. As far >as I'm concerned, this is *wrong*. (How can you claim to be programming >for reuse, as Meyer so eloquently points out as a fundamental goal, and >model things so rigidly? So incorrectly?) With respect, I think you have our roles reversed. Your position is the rigid one, since you are insisting on there being only one solution to this problem. I, on the other hand, am suggesting that there are circumstances where other models (such as Meyers) may be valid. >However, I can easily understand why Bertrand modelled things like so: >simplicity. He was simply trying to make a point about the difference >between inheritance and clientship. In hindsight, I think he may have >been better off choosing a simple example that works well in all >contexts. Writing a book is one of the hardest things a human can do. It is harder than writing software, believe me. Writing a book of *significance* (for which OOSC2 certainly qualifies) is even harder. So I am not going to complain too loudly about an imperfect example. I am more likely to complain about his rather flippant criticism of Somerfield; which I think detracts from the credibility of the work. Be that as it may, the example in question is not incorrect as it stands. It's just not correct in all, or even most, contexts. > >> However, I strongly sympathize with motivation. I agree that we should give >> thought to 'future proofing' our application structures (although I don't >> think that a simple reliance on real world structure actually accomplishes >> that goal). > >The Role Pattern (very similar to Gamma et al's State Pattern) just >described here doesn't necessarily model 'the real world'. I think it >does model our 'concept of the world', according to a certain >classification theory. Granted. Robert C. Martin | Design Consulting | Training courses offered: Object Mentor | rmartin@oma.com | Object Oriented Design 14619 N Somerset Cr | Tel: (800) 338-6716 | C++ Green Oaks IL 60048 | Fax: (847) 918-1023 | http://www.oma.com "One of the great commandments of science is: 'Mistrust arguments from authority.'" -- Carl Sagan