Path: utzoo!utgpu!news-server.csri.toronto.edu!cs.utexas.edu!uunet!van-bc!rsoft!mindlink!a35 From: Bruce_Atherton@mindlink.UUCP (Bruce Atherton) Newsgroups: comp.lang.eiffel Subject: Re: Inheritance and Information Hiding Message-ID: <4810@mindlink.UUCP> Date: 14 Feb 91 15:13:47 GMT Organization: MIND LINK! - British Columbia, Canada Lines: 42 I have some thoughts to add on this debate regarding how to deal with a RECTANGLE and the add_vertex call. When trying to work these questions out, I usually rely on real world examples, so please bear with me. Consider a gardener who is told that to prune plants you have to cut some branches off. He is given the task of pruning a garden, so he goes to each plant and does so. What does he do when faced with a cactus? It has no discernible branches, yet it is clearly a plant. He could cut away at it anyway, but this is stupid behaviour. He could just ignore it, but if the cactus required special care instead of pruning, this would not be smart either. The best solution would be for the gardener to report to whoever gave him the task that he could not prune a cactus. This seems to be analogous to the RECTANGLE-add_vertex debate. The correct action would be to report an error. Bertrand Meyer pointed out that this would alter the terms of the contract, but I don't think this is necessarily correct. It could be a fundamental part of the language that a contract can be breached (to continue the metaphor). The action taken when an object is in breach of contract is up to the object that is contracting the services. I don't know whether ALL contracts should be breachable. After all, there are some things that are so fundamental to our understanding of a polygon that we can't imagine a polygon without them. On the other hand, just because we can't imagine one doesn't mean that someone who reuses the class can't. I am not a language designer, nor have I paid much attention to such details in the past. I am just an end user of these languages. It may well be that allowing a contract to be breached invalidates some model that is used in object-oriented language design. If it does, though, in my opinion there is something wrong with the model. It is often required that a subclass eliminate a property of the more general class. A language which does not provide this facility is not meeting my needs as a user. And isn't that what it is all about? -- UBC Faculty of Law Artificial Intelligence Research Project Bruce_Atherton@mindlink.UUCP or| "You fell for the second most famous blunder. uunet!van-bc!rsoft!mindlink!a35| The most famous is never to get involved in a land war in Asia." - The Princess Bride