home *** CD-ROM | disk | FTP | other *** search
/ ftp.umcs.maine.edu / 2015-02-07.ftp.umcs.maine.edu.tar / ftp.umcs.maine.edu / pub / WISR / wisr6 / proceedings / ascii / thatte5.ascii < prev    next >
Text File  |  1993-10-19  |  22KB  |  396 lines

  1.  
  2.  
  3.  
  4.  
  5.           Synthesizing  Interface  Stubs  for  Reusable  Classes
  6.  
  7.  
  8.  
  9.                                             Satish R. Thatte
  10.  
  11.  
  12.  
  13.                      Department of Mathematics and Computer Science
  14.  
  15.                         Clarkson University, Potsdam, NY 13699-5815
  16.  
  17.                                            Tel:  (315) 268-2395
  18.  
  19.                                E-mail: satish@sun.mcs.clarkson.edu
  20.  
  21.                                           Fax: (315) 268-6670
  22.  
  23.  
  24.  
  25.                                                   Abstract
  26.  
  27.  
  28.     The problem of fitting together reusable components in spite of differences in protocol and
  29. representation choices is well-known. I discuss a novel approachto the protocol problem based
  30. on a formal logic of adaptability of interface types to automatically synthesize interface stubs to
  31. achieve an exact fit between the available "socket" for a reusable part and the actual part. The
  32. underlying notion of adaptability turns out to be related to but distinct from both subtyping
  33. and inheritance. The important related problem of data and object mobility in the presence of
  34. representation differences such as those between polar and cartesian representations ofp oints
  35. appears  to  be  amenable  to  a  solution  based  on  transformational  knowledge  in  the  form  of
  36. equational laws used in conjunction with unification/matching techniques.
  37.  
  38.  
  39. Keywords: class libraries, interface adaptation, object mobility, stub generation
  40.  
  41.  
  42. Workshop Goals: Learning; networking; advance state of the art of class libraries and object
  43. interoperability.
  44.  
  45.  
  46. Working Groups: reuse and OO methods,reuse and formal methods, tools and environments,
  47. reuse education.
  48.  
  49.  
  50.  
  51.                                                   Thatte- 1
  52.  
  53.  
  54. 1      Background
  55.  
  56.  
  57.  
  58. I have started to get involved in thinking and learning about reuse issues in the context of object-
  59. oriented systems over the last year or so.  My background is in programming languages and typ e
  60. theory and I have recently been working on some typ e-theoretic problems that have applications
  61. in  automatic  stub  generation  for  adaptation  of  object  interfaces  including  data  transformations
  62. based  on  knowledge  expressed  in  the  form  of  equational  theories.   I am  particularly  interested
  63. in  exploring  the  methods  involved  in  enhancing  interoperability  of  classes  and  objects  at  both
  64. small and large grained levels in environments that are heterogeneous in some sense (ranging from
  65. hardware platforms to "ontology").
  66.  
  67.  
  68.  
  69. 2      Position
  70.  
  71.  
  72.  
  73. This paper starts from the position that object technology is the most promising vehicle forrealizing
  74. the goal of large-scale software reuse. This is now a common perception that provides much of the
  75. motivation  for  the  current  industry-wide  shift  towards  object-oriented  software  design  methods.
  76. An obvious potential bottleneck in the practical realizationof this vision is the weakness of current
  77. component integration tools especially in the context of heterogeneous systems, where heterogeneity
  78. is broadly understood to mean anything ranging from different languages/hardware platforms to
  79. different sources for code components. This problem has been recognized and partly addressed,e.g.,
  80. in the CORBA [1] standard for distributed components1, and in IBM's SOM [2] library management
  81. system for class libraries. However, neither CORBA nor SOM adequately deal with the inflexibility
  82. of the interfaces (signatures) offered by objects to the outside world.  Ib elieve that such inflexibility
  83. is at least a serious nuisance and could become a real problem whether the ob jects are connected
  84. statically by being compiled together or are dynamically connected using, say, CORBA's notion of
  85. a dynamic invocation interface (DII).
  86.  
  87.  
  88. Focusing on the static (class library) case first,note that in the typical lifecycle of a large component-
  89. based system, there are likely to be many rebuilding episodes in which some of the old components
  90. are  replaced  by  functionally  equivalent  (or  superior)  new  components.   For  instance,  in  replac-
  91. ing an old library of container classes with a better one, or in accommodating an upgrade for a
  92. database system which also results in a rationalization of the API. In both cases,  there is likely
  93. to be a protocol mismatch between the expected and actual interfaces forthe new ob jects. The
  94. application programmer is now faced with the task of somehow adapting the new objects to bridge
  95. the  difference  between  their  expected  and  available  interfaces_the  obvious  solution  is  to  create
  96. stubs to connect the old interfaces to the new ones2. The task is not difficult in principle; in fact
  97. in most practical cases it is conceptually trivial. However, if a number of interdependent classes
  98. are involved, along with the complications of genericity, inheritance and overloading, the technical
  99. difficulty and opportunity for error are likely tob e substantial.  Conceptual triviality and technical
  100. complexity is a very uninviting combination for most people, and as such the task of synthesizing
  101. interface stubs is likely to be unwelcome and an obstacle to the optimal evolution of both class
  102. libraries and component-based systems. At the same time, its relatively mechanical nature makes
  103. it an inviting target for automatic inference.
  104. ___________________________________________________1
  105.      Although the main motivation for CORBA comes from distributed systems integration, CORBA-compliantORB's
  106. may of course be used for integrating objects located on the same node or even in the sameaddress space.
  107.    2 Even when the functionality of a reused class needs to be extended to fulfill the requirements of the application,
  108.  
  109. the problem can often be factored intoa stub generation problem and an extension problem.
  110.  
  111.  
  112.  
  113.                                                          Thatte- 2
  114.  
  115.  
  116. The stub generation problem also occurs in both the static and dynamic invo cationinterfaces of an
  117. ORB. In the context of static invocation, the interface repository is used in a way that resembles
  118. the use of a class (or stub) library and the remarks above about class libraries apply. In using the
  119. DII, the alternatives for an application are either to write complex code that cananalyze and use
  120. an interface found in the repository in the form of what amounts to a data-structure at run-time,
  121. or to assume a generic interface for the required server and rely on the ORB to supply a dynamic
  122. stub-generation service to bridge the protocol gap3, possibly with some interactive help. The latter
  123. is obviously the more attractive option.
  124.  
  125.  
  126. Conceptually there are two somewhat orthogonal issues in stub generation.  One is the formalization
  127. of "compatibility" between interface types that is a generalization of substitutability in the usual
  128. subtyping relation, and allows functionality preserving changes in method names, parameter order,
  129. etc.   The  other  is  both  built-in  and  user-definable  mechanisms  for  type  isomorphism  between
  130. parameter  and  result  types  of  methods  that  would  allow  data  and  ob ject interchange  between
  131. client and server objects in spite of differences in representation and structure.  I have made some
  132. progress in solving both problems. The main ideas and current state of this work are summarized
  133. below.
  134.  
  135.  
  136.  
  137. Formalization of Compatibility4
  138.  
  139.  
  140.  
  141. Compatibility is a new kind of conformance that can be formalized usingan adaptability relation
  142. between interface types, which is relatedto but distinct from both subtyping and subclassing.  As
  143. with the latter, the relation is quite simple except where the object (interface) types are recursive.
  144. Recursive  interfaces  are  commonly  found  in  small  library  classes  and  are  rare  for  large  active
  145. components like servers.
  146.  
  147.  
  148. The main conceptual difficulty in formalizing the logic of adaptability is the misleading similarity
  149. of the concept with both subtyping and inheritance. Clearly, if a class A can emulate B, then an
  150. A-object can be used (with some disguise) where a B-object is needed. Treating the disguise as a
  151. coercion, this sounds exactly like the normal notion of subtyping. However, a formal application
  152. of this intuition leads to an impasse where obviously compatible interfaces cannot be shown to be
  153. related.  The main insight needed to distinguish subtyping from adaptability is that adaptability
  154. is bijective whereas subtyping is injective,  whenb oth are seen as mappings realized by coercions.
  155. In other words, the set of objects belonging to a subtype typically forms only a part of theset of
  156. objects belonging to each of its supertypes, but if the interface of a classA is adapted to implement
  157. the  interface  specification  of  a  class  B, then  every  B-object  is  emulated  by  a  hidden  A-object,
  158. and every A-object can be converted to a B-object by attaching a suitable interface stub.  These
  159. ideas (along with certain functionality preserving protocol transformations) can be formalized in a
  160. natural way in the form of a logic of adaptability and stub inference.  The inference process can
  161. also be automated using an algorithm that modifies and extends the (complete) subtyp e inference
  162. algorithm of Amadio and Cardelli [4] for recursive types.
  163.  
  164.  
  165. Some interesting issues arise in extending adaptability to generic classes.  The main difficulty (as-
  166. suming that their instantiation is user-specified) is the representation of their interface types since
  167. the type parameters of such classes are typicallyconstrained by implicit assumptions about their
  168. functionality_for instance they may be used in the implementation as though they support cer-
  169. tain operations. It has b een found that representing such constraints with full generality requires
  170. ___________________________________________________3
  171.      Of course, there is theoretically the third option of hand-coding a stub interactively once the required interface
  172. is found, but this would require all users to be system experts.
  173.    4 Adetailed discussion of current results is given in [3].
  174.  
  175.  
  176.  
  177.                                                          Thatte- 3
  178.  
  179.  
  180. F-bounded polymorphism [5] which is significantly more complex than ordinary bounded polymor-
  181. phism [6].  However, since the reusable generic class and the actual parameters it is used with often
  182. come from different domains (the latter typicallyfrom the application domain), it is natural to use
  183. adaptability rather than subtyping bounds for the parametersand the proof-theoretic properties
  184. of adaptability permit the use of ordinary bounded polymorphism without loss of generality.  It is
  185. worth noting that the interface adaptation of even a single generic class can be quite complex since
  186. the actual parameters for it often need stubs, besides the stub needed for the generic class itself.
  187.  
  188.  
  189. Some important issues relating to adaptability have yet to be addressed.  One is the extension to
  190. frameworks, which can be thought of as collections of classes related by subtyping and/or inher-
  191. itance.  The  existing  logic  ensures  that  the  application  classes  can  be  related  by  any structural
  192. subtyping relation consistent with the subtyping relations among the reusable classes used to im-
  193. plement them.  However,  there are many unresolved semantic issues.  The entire framework is at
  194. present built around a simple core-OOL based on the -calculus extended with labeled records.
  195. I have not yet extended the logic or algorithms to account for the idiosyncrasies of any realistic
  196. language.
  197.  
  198.  
  199.  
  200. Type Isomorphism for Flexible Data Transp ortb etween Clients and Servers
  201.  
  202.  
  203.  
  204. This is a multifaceted problem with many existingapproaches.  An excellent survey of the current
  205. state of the art is given by Wileden, et al [7].  Most current systems support what one might call
  206. data  structure  isomorphism  (DSI) which  is  used  in  data  transport  among  components  based  on
  207. different platforms (languages, processors, operating systems). The typical solution is to define a
  208. universal  data  type  definition  notation  (e.g., IDL  [1]  or  XDR  [8 ])  along  with  language bindings
  209. to translate data to and from the standard format. Data transformations necessary for transport
  210. can then be automated_typical RPC stub generation techniquesalready automate such transfor-
  211. mations during transport for distributed client-server interactions [8 ].  The main shortcoming of
  212. DSI is its lack of support for bridging the differences between alternative representations of ab-
  213. stract types, such as the polar and cartesian representations of points in a plane.  We need abstract
  214. type isomorphism (ATI) to fully support data mobility in a heterogeneous environment when data
  215. formats differ in more than platform-specific idiosyncrasies.  I am interested in exploring an ap-
  216. proach  where  user  knowledge  about  the  equivalence  of  various  representations  can  be  expressed
  217. declaratively in the form of equational laws (seenas bijections with two-way coercions) between
  218. representation types. The problem of establishing equivalence between representation types then
  219. reduces to the word problem in algebraic theories for which there are well-established automated
  220. techniques based on canonical term-rewriting. There are good research tools available to experiment
  221. with these techniques [9, 10 ]. Inefficiencies due to multistage transformations can be eliminated by
  222. using techniques such as deforestation [11 ]if the transformations are themselves expressed declar-
  223. atively using a functional language. Note that such transformations are of interest whether or not
  224. encapsulation of data-representation is important.
  225.  
  226.  
  227. For a discussion of a closely related problem in the context of type reconstruction in functional
  228. languages, and the associated equational unification theory, see [12 , 13 ].
  229.  
  230.  
  231.  
  232. 3      Comparison
  233.  
  234.  
  235.  
  236. To my knowledge there has been no previous work on automated tools for generating interface stubs
  237. of the kind described above, but there are many frameworks and actual systems which provide a
  238.  
  239.  
  240.                                                          Thatte- 4
  241.  
  242.  
  243. suitable habitat for such an extension. These are of two kinds: class library management systems
  244. and  component  connection  and  interoperability  frameworks.   A few  of  these,  along  with  some
  245. alternative approaches, are described below.
  246.  
  247.  
  248. IBM has implemented a class library framework called SOM [2].  SOM provides language neutral
  249. packaging and upwardly compatible binary libraries with support for dynamic linking which permits
  250. changes  without  recompilation  of  clients  and even  cross-language  subclassing  without  access  to
  251. source code. SOM also supports the use of object-oriented technology from procedural languages.
  252. The interface stubbing techniques described aboveclearly complement these strengths and would
  253. further enhance the reusability of classes in SOM libraries.
  254.  
  255.  
  256. Wileden, et al [7], describe an approach to what they call specification level interoperability which
  257. is quite similar in spirit to the notion of abstract type isomorphism discussed above.  However, their
  258. implementation appears to focus on pairs of language-specific stubs to ferry calls and results b etween
  259. static client-server pairs. They do not support knowledge-based automated exploration/selection
  260. of possible isomorphisms among representations. In fact, the prototype described in the paper does
  261. not support object mobility at all, although they do recognize the need for it asa future extension.
  262.  
  263.  
  264. CORBA [1] is perhaps now the most widely accepted framework for interoperability of distributed
  265. components.  It contains DSI support for data transport at a relatively high level of abstraction
  266. based  on  a  type  definition  facility  called  IDL.  The basic  framework  contains  no  notion  of  auto-
  267. mated support for interface adaptation or abstract type isomorphism although b othcould b e seen
  268. as "components" (in the CORBA terminology) that define extensions of the basic functionality.
  269. CORBA contains an interface repository which would be the natural habitat for such an extension.
  270.  
  271.  
  272. Bart [14 ] is interesting as a concrete ORB (although it does not claim adherence to the CORBA
  273. standard)  that  exemplifies  one  currently  popular  approach  to  ob ject  mobility  in  heterogeneous
  274. distributed systems. Bart is realized as a single "bus" that carries (and stores) relational data and
  275. works mainly in broadcast mode. The translation of all shared objects to and from the relational
  276. form  must  be  specified  explicitly  by  the  developers  of  attached  components5 .  This  allows  great
  277. flexibility since the representations of objects can be mapped into tuples in arbitrary ways6 . On
  278. the other hand, it also means a lot more work as opposed to automated matching of (say)IDL
  279. versions of the representation types bythe bus.  Note also that automatedinterface stub generation
  280. offers an alternative mode for object mobility in homogeneous contexts where co deas well as data
  281. is  mobile.  This  alternative  respects  object  encapsulation  absolutely.  Such  an  alternative  is  not
  282. possible within the Bart framework.
  283.  
  284.  
  285. Genesereth's facilitators [15 ] are much moreambitious ORBs that support a strong distribution
  286. model  as  opposed  to  Bart's  weak  one  (there  is  no  single  shared  bus_each  component  connects
  287. to others through its own facilitator). Facilitators are supposed to use an extension of first-order
  288. logic to exchange information about port specifications and to negotiate connections using theorem
  289. proving techniques. A similar but simpler model is described by Konstantas [16 ] where each dis-
  290. tributed component consists of a "nucleus" that communicates with the outside world through a
  291. "membrane" (a kind of ORB) and the entire system has a "multicellular" structure. An interesting
  292. aspect of membranes is that they contain interfacetype managers that negotiate type compatibility
  293. with foreign membranes. This appears to call for stub generation techniques of the kind Iprop ose.
  294. ___________________________________________________5
  295.      There is a striking similarity to the shared tuple-space of Linda.
  296.    6 The flexibility is further enhanced in Bart by a Prolog-like language called SGLthat allows the definition of new
  297.  
  298. relations based on the extensionally represented ones.
  299.  
  300.  
  301.  
  302.                                                          Thatte- 5
  303.  
  304.  
  305. References
  306.  
  307.  
  308.  
  309.   [1] O.  M.  Group, "The  common  object  request  broker:  Architecture  and  specification."  OMG
  310.       Document 91.12.1 Revision 1.1, 1992.
  311.  
  312.  
  313.   [2] I. Corporation, "OS/2 2.0 technical library system object model guide and reference." IBM
  314.       Document S10G6309, 1992.
  315.  
  316.  
  317.   [3] S. R. Thatte,"Automated synthesis of interface adapters for reusable classes," in to appear in
  318.       the Proceedings of the 21st Annual ACM Symposium on Principles of Programming Languages
  319.       (POPL'94), ACM Press, 1994.
  320.  
  321.  
  322.   [4] R.  M.  Amadio  and  L.  Cardelli, "Subtyping  recursive  types," in  Proceedings  of  Eighteenth
  323.       POPL Symposium, pp. 104-118, ACM Press, January 1991.
  324.  
  325.  
  326.   [5] P. Canning, W. Cook, W. Hill, W. Olthoff, and J. C. Mitchell, "F-bounded polymorphism for
  327.       object-oriented  programming," in  Proceedings  of  Fourth  International  Conference  on  Func-
  328.       tional Programming Languages and Computer Architecture (FPCA'89), London, U.K., ACM
  329.       Press, Addison-Wesley, 1989.
  330.  
  331.  
  332.   [6] L. Cardelli and P. Wegner, "On understanding types, data abstraction and polymorphism,"
  333.       Computing Surveys, vol. 17, no. 4, 1985.
  334.  
  335.  
  336.   [7] J. C. Wileden, A. L. Wolf, W. R. Rosenblatt, and P. L. Tarr, "Specification-level interoper-
  337.       ability," Communications of the ACM, vol. 34, pp. 72-87, May 1991.
  338.  
  339.  
  340.   [8] S. Microsystems, "Network programming guide." Part Number:  800-3850-10, 1990.
  341.  
  342.  
  343.   [9] D. Kapur and H. Zhang, "RRL: A rewrite rule laboratory," inProceedings of 9th Conference
  344.       on  Automated  Deduction  (CADE-9),  Argonne,  Illinois,  USA, Springer-Verlag, 1988.  LNCS
  345.       310.
  346.  
  347.  
  348. [10]  S.  J.  Garland  and  J.  V.  Guttag, "A guide  to  LP,  the  Larch  prover," Tech.  Rep.  82, DEC
  349.       Systems Research Center, 1991.
  350.  
  351.  
  352. [11]  P. Wadler, "Deforestation:  Transforming programs to eliminate trees," in Proceedings of Sec-
  353.       ond European Symposium on Programming, Springer-Verlag, 1988.  LNCS 300.
  354.  
  355.  
  356. [12]  S. R. Thatte, "Coercive type isomorphism," in Proceedings of the Fifth Conference on Func-
  357.       tional Programming Languages and Computer Architecture (FPCA'91), pp. 29-49, ACM Press,
  358.       1991.
  359.  
  360.  
  361. [13]  S. R. Thatte,"Finite acyclic theories are unitary," Journal of Symbolic Computation, vol. 15,
  362.       February 1993.
  363.  
  364.  
  365. [14]  B. W. Beach, "Connecting software components with declarative glue," in Proceedings of the
  366.       14th  International  Conference  on Software  Engineering,  Melbourne,  Australia,  pp. 120-137,
  367.       ACM Press, May 1992.
  368.  
  369.  
  370. [15]  M. Genesereth, "An agent-based approach tosoftware interoperation," Tech. Rep. Logic-91-6,
  371.       Stanford University Logic Group, 1991.
  372.  
  373.  
  374. [16]  D. Konstantas, "The implementation of the Hybrid cell," in Object Frameworks (D. Tsichritzis,
  375.       ed.), Centre Universitaire d'Informatique, Universite de Geneve, 1992.
  376.  
  377.  
  378.  
  379.                                                          Thatte- 6
  380.  
  381.  
  382. 4      Biography
  383.  
  384.  
  385.  
  386. Satish  R.  Thatte is an Associate Professor of mathematics and computer science at Clarkson
  387. University.  The focus of his current research is language design and software engineering issues
  388. connected with static and dynamic type systems. In the past he has worked in functional program-
  389. ming and symbolic computation including term rewriting systems and equational unification.  He
  390. has previously taught at the Universityof Michigan and the University of California at San Diego.
  391. He received a Ph.D. in Computer Science from the University of Pittsburgh in 1982.
  392.  
  393.  
  394.  
  395.                                                          Thatte- 7
  396.