Path: utzoo!utgpu!jarvis.csri.toronto.edu!rutgers!gatech!hubcap!billwolf%hazel.cs.clemson.edu From: billwolf%hazel.cs.clemson.edu@hubcap.clemson.edu (William Thomas Wolfe,2847,) Newsgroups: comp.sw.components Subject: Re: Inheritance vs. component efficienc Message-ID: <5750@hubcap.clemson.edu> Date: 13 Jun 89 01:38:24 GMT References: <5021@wiley.UUCP> Sender: news@hubcap.clemson.edu Reply-To: billwolf%hazel.cs.clemson.edu@hubcap.clemson.edu Lines: 51 From simpson@poseidon.uucp (Scott Simpson): >>> The advantage of an o-o inheritance system is that it >>> makes it very easy to reuse a component *with modifications*. >> >> The same thing is possible through the use of Ada packages; a new >> package serves as an interface which hides both the calls to the old >> package and the new code which was added on top of it, thus preserving >> the integrity of the original abstraction and creating a new one. > > The same thing is not possible using layered Ada packages. You will still > have to write code to handle the added state. [...] > Notice that once I added state, my operations no longer work. There are > a few ways to get around this limitation: > > 1) Repeat operations at each level. This is precisely what I had in mind. Note: "a new package serves as an interface which hides both the calls to the old package and the new code which was added on top of it". But, you wail, this will cost me a bit of typing!! Well, not necessarily. The same pseudo-problem arises when you write an Ada package specification and then supposedly have to retype all the stuff that was in the specification over in the body: function Umptysquat (Using : in Parameter_Type) return Result_Type; must be retyped as: function Umptysquat (Using : in Parameter_Type) return Result_Type is Result : Result_Type; begin -- function Umptysquat return Result; end Umptysquat; in the body, before you enter the next phase of going in to add the logic. Well, wouldn't you know it, a short little program can be written to take an Ada package specification and automatically generate a corresponding package body, with type definitions and the like recast as comments, and procedures and functions rewritten as stubs. The same thing can be done when you wish to add a layer of abstraction; simply have a program ask you for the name of the new data type(s) and automatically generate a higher- level package which implements itself through calls to the lower-level packages. Q.E.D., as they say in mathematics... Bill Wolfe, wtwolfe@hubcap.clemson.edu