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 / lea.ascii < prev    next >
Text File  |  1993-10-19  |  15KB  |  295 lines

  1.  
  2.  
  3.  
  4.  
  5.                Cataloging  Ob ject  Oriented  Software  Reuse
  6.  
  7.  
  8.  
  9.                                                  Doug Lea
  10.  
  11.  
  12.  
  13.                              SUNY Oswego, Oswego NY 13126 and
  14.  
  15.                           NY CASE Center, Syracuse NY 13244-4100
  16.  
  17.                                            Tel:  (315) 341-2688
  18.  
  19.                                        Email:  dl@g.oswego.edu
  20.  
  21.                                           Fax: (315) 443-4745
  22.  
  23.  
  24.  
  25.                                                   Abstract
  26.  
  27.  
  28.     Ob ject-Oriented design is often said to be a positive factor in reuse.  This position paper
  29. attempts to clarify some of the contributing factors and a few problem areas.
  30.  
  31.  
  32. Keywords: Reuse, Object-Oriented, Design
  33.  
  34.  
  35. Workshop Goals: Learning; networking;
  36.  
  37.  
  38. Working  Groups:  Reuse  and  OO methods,  Reuse  and  formal  methods, Domain  analy-
  39. sis/engineering, Design guidelines for reuse - OO
  40.  
  41.  
  42.  
  43.                                                     Lea- 1
  44.  
  45.  
  46. 1      Introduction
  47.  
  48.  
  49.  
  50. Among the many reasons people adopt Object-Oriented (OO)methods is the widely held reputation
  51. for enhancing software reuse. However, many different, even conflicting accounts have been offered
  52. in explanation of this reputation. The remainder of this position paper attempts to categorize and
  53. clarify some of the ways in which OO developers obtain reuse.
  54.  
  55.  
  56.  
  57. 2      Composition
  58.  
  59.  
  60.  
  61. OO methods  support  a  version  of  the  most  basic  and  essential  form  of  reuse, the  combination
  62. of possibly many individual components to serve some aggregate purp ose. Object composition is
  63. different in both concept and execution than procedure, function, or module composition. However
  64. it may be used to identical or similar effect.  In compositional OO design, a developer defines a
  65. class whose instances serve as "hosts". Hosts maintain the identities of other"help er" objects and
  66. send them messages in the course of achieving required functionality.
  67.  
  68.  
  69. Many variants exist. For example, one common form of composition is often termed "delegation".
  70. Here, any of some subset of messages are simply forwarded (delegated) to the ob ject referred to
  71. by a certain connection link, but the exact object on the other side of the link may change (be
  72. rebound) over time.
  73.  
  74.  
  75. Compositional designs may also be categorized with respect to their encapsulation and modularity
  76. properties.  Pure closed composition is a form of black box reuse.  It is among thesafest and most
  77. conservative possible design strategies, due to:
  78.  
  79.  
  80.  
  81.     fflOutward Closure. Helpers never send messages except simple replies to objects outside some
  82.        known scope.  Replies never reveal the identities of inner objects.
  83.  
  84.  
  85.     fflInward  Closure.  The  host  maintains  the  sole  link  to  each  helper.  The  host  never  reveals
  86.        the identities of helpers.  No other objects may access the helpers or otherwise exploit their
  87.        existence.
  88.  
  89.  
  90.  
  91. ADT-style OO designs rely on closed composition. The success of basic libraries containing many
  92. such black-box components attests to the utility of closed composition in addressing in-the-small
  93. reuse needs.
  94.  
  95.  
  96.  
  97. 2.1     Architecture
  98.  
  99.  
  100.  
  101. The above closure restrictions may be lifted either by choice or by necessity, resulting in a continuum
  102. of open composition strategies involvingcollab oration networks, resource sharing, and larger scale
  103. opportunities  for  reuse.  And  larger  scale  opportunities  for  disaster:  aliasing,  interference,  and
  104. lack of independence and local verifiability.  These must be dealt with via combinations of design
  105. rules (e.g., access control policies), organizing constructs (e.g. "groups", "roles"), and worst-case
  106. implementation  techniques  (e.g.,  locking,  atomic  transactions).   The  presence  of  such  dangers,
  107. along with the sheer difficulty of their diagnosis, prevention, and control can be a limiting factor
  108. in successful reuse of individual classes. However, semi-isolated networks in which these factors are
  109. known to be under control are often reusable as a group.
  110.  
  111.  
  112.                                                            Lea- 2
  113.  
  114.  
  115. Moreover, by  abstracting  over  the  functionality  of  a  system  or  subsystem  of  components,  and
  116. only paying attention to their static and dynamicinterrelations, one may use/reuse the resulting
  117. design  architectures.  Architectural  reuse  ranges  from  the  everyday  use  of  "standard  forms"  of
  118. static connections (e.g., simple linked lists), to the incorporation ofdesign patterns that represent
  119. solutions to common structuring problems (e.g., model-view-controller designs), to the system-wide
  120. adoption of large-scale architectural frameworks (e.g., software bus, Linda tuple space).
  121.  
  122.  
  123. Architectural reuse may or may not involve any actual code reuse. Some architectural elements may
  124. indeed be completely isolated from application-specific functionality.  The isolationof elements into
  125. nodes and use of parameterized code to construct lists of such nodes represents afamiliar example.
  126. Similarly, "protocol  objects"  such  as  multicast  controllers  may  be  reused  in the  construction  of
  127. group broadcast designs without regard for the contents of multicast messages.
  128.  
  129.  
  130. However, there may be at least an equal numb er ofexamples in which no code reuse is possible.
  131. For example, OO components assisting in the construction of many general graph structures seem
  132. little used, perhaps because of typical application-specificity of node and edge semantics.  Instead,
  133. the general ideas are manually adapted to the situations at hand.  It is not clear (and not worth
  134. debating) where to draw the line between this formof reuse and the application of "general design
  135. knowledge".
  136.  
  137.  
  138.  
  139. 3      Inheritance
  140.  
  141.  
  142.  
  143. 3.1     Classes as Specifications
  144.  
  145.  
  146.  
  147. Class constructs provide developers the opportunity to declaratively specify the behaviors of objects.
  148. While  there  is  an  enormous  range  in  support  for  declarative  specification,  nearly  all  methods,
  149. languages, database tools, etc., possess some means of indicating what objects do without saying
  150. how they do it, or at least without allowing other software to depend on how they do it. Constructs
  151. may include simple method interfaces, method signatures, invariants, preconditions, postconditions,
  152. and other specification devices. Unlike similar module-based constructs, classes allow the reuse of
  153. the same specification for an arbitrary number of software entities (objects).
  154.  
  155.  
  156.  
  157. 3.2     Specification Inheritance
  158.  
  159.  
  160.  
  161. The simplest way to reuse a specification that does not quite apply to anew problem is to extend
  162. it. Specification inheritance (also known as property inheritance) supports extension by addition of
  163. specifications.  Subclasses may add newprop erties (e.g., methods, attributes) and/or add further
  164. constraints  on  existing  ones.  However, additions  may  not  invalidate  any  property  listed  in  any
  165. superclass. Beyond its technical uses, the emphasis on specification inheritance in OOdevelopment
  166. can lead to increased human understandability andconceptual reuse that accompanies any effort
  167. to hierarchically categorize entities in a given domain.
  168.  
  169.  
  170.  
  171. 3.3     Polymorphism
  172.  
  173.  
  174.  
  175. Specification is an analysis and design concept. However, OOlanguages and tools integrate at least
  176. some declarative and operational aspects of types and inheritance, thus linking the expression of
  177.  
  178.  
  179.  
  180.                                                            Lea- 3
  181.  
  182.  
  183. properties and code in software. The resulting type systems enable exploitation of subclass poly-
  184. morphism: A software client c may require that a particularserver ob ject s p ossess the properties
  185. listed  in  some  class  A.  However, s  may  well  be  an  instance  of  a  subclass  SubA with  additional
  186. properties. Specification inheritance rules, taken seriously, ensure that none of theextra prop erties
  187. in SubA invalidate c's assumptions andrequirements about s.
  188.  
  189.  
  190. The  primary  effect  on  reuse  is  support  for  interoperability.  Since  client  code  is  decoupled  from
  191. inessential  features, new  subclasses  of  A may  be  developed  and  plugged  while  at  the  same  time
  192. reusing existing client code. In practice, this remains more of an ideal than an everyday occurrence.
  193. Client  code  is  too  often  written  in  a  way  that  needlessly  depends  on  inessential  features  of  a
  194. specialized class rather than a less committal, more generalsup erclass.  (Design rules and languages
  195. distinguishing  interfaces  from  implementations can  alleviate  this  but  tend  to  leave  architectural
  196. specifications hidden as "implementation" matters.) Also, the introduction of a new subclass may
  197. suggest better ways of factoring and expressing superclasses and clients.
  198.  
  199.  
  200. OO frameworks  (e.g., for  GUIs)  typically  combine  these  forms  of  polymorphic  client  code  reuse
  201. with architectural reuse.  Frameworks declare one or more inheritance hierarchies in which most
  202. classes are listed mainly in terms of their abstract interfaces.  However, the classes may also contain
  203. code-based commitments to interconnection rules and protocols that holdindep endently of how
  204. other  functionality  is  implemented.  Framework  users  must  add  subclasses  that  implement  (and
  205. perhaps add to) the desired functionality in an application-specific manner whilestill ob eying the
  206. connection patterns and protocols listed in superclasses.
  207.  
  208.  
  209. Additional  reuse  opportunities  stem  from  constructs  allowing  classes  to  be  parameterized  with
  210. respect  to  other  types.  The  techniques  are  similar  to  those  used  in  modular  design  techniques
  211. for languages such as Ada. However, inheritance and parameterization (genericity) are not purely
  212. orthogonal concepts. Interactions among them lead to new design strategies, about which there is
  213. as yet little to conclude with respect to reuse.
  214.  
  215.  
  216.  
  217. 3.4     Defeasible Inheritance
  218.  
  219.  
  220.  
  221. Few languages enforce pure property inheritance rules.  They instead support a form of defeasible
  222. inheritance in which some superclass properties may be overridden in subclasses. In most languages,
  223. this overriding is limited to redefining method implementations in subclasses.
  224.  
  225.  
  226. Overriding can enhance reusability.  Overriding rules can make it easier to obtain code decoupling.
  227. In a system with overriding, clients cannotdep end on any features of listed method code, since it
  228. may change in subclasses.  (Since in most languages,  only method code, not data representation
  229. commitments may be overridden, representational coupling remains a potential problem.)  It also
  230. provides  additional  opportunities  for  internal  reuse.  A  superclass  may  include  default  method
  231. implementations that are reused by most subclasses without forcing all of them to do so.
  232.  
  233.  
  234. However,this form of reuse-driven inheritance can have harmful effects on other aspects of reuse and
  235. software quality.  Most languages do not contain powerful enough declarative constructs to require
  236. subclass designers to preserve all essential guarantees of their superclasses.  Even inlanguages that
  237. do possess these features, programmers tend not to use them enough. It is often so much easierto
  238. write code that implements functionality than declarations describing its effects that people don't
  239. even attempt the latter.  Thus,  a subclass implementation of a method may alter semantics in a
  240. way that does not preserve interoperability prop erties that clients depend on.  As a limiting but
  241. very common case, a new class may list another as a superclass solely to reuse a few bits of its
  242.  
  243.  
  244.  
  245.                                                            Lea- 4
  246.  
  247.  
  248. implementation without in any way preserving superclass declarative properties. (Some languages
  249. do provide constructs that distinguish at least this extremecase.)
  250.  
  251.  
  252. Sometimes this form of implementation inheritance is used by developers just because it is easy to
  253. express in OO languages. Reuse goals could be better preserved via compositional techniques such
  254. as using another object as a delegated helper rather than listing its class as a superclass. Worse,the
  255. fact that many programmers see these two options as nearly equivalent can lead to other conceptual
  256. design errors. Worse still, languages, user manuals, and textbooks themselves obscure these issues
  257. by attempting to relate subclassing concepts to the use of runtime storage layout schemes that can
  258. be  viewed  as  representationally  "embedding"  superclass  objects  inside  subclass  objects.  Design
  259. decisions are sometimes based on these considerations.  Sometimes this is due to an unfortunate
  260. but correct concern for representational compatibility with existing reused software (e.g., between
  261. C and C++), but more often results from simple confusion about efficiency consequences.
  262.  
  263.  
  264. Defeasible inheritance is also used by programmers in order to evade language-based encapsulation
  265. rules.  In most languages, a client/host is not allowed to evenreference internal implementation
  266. matters listed in a class, but a subclass is. Thus, inheritance is used to simplify white-box reuse of
  267. incidental implementation features. While such code mangling is not an optimal form of reuse, it
  268. is often preferable to no reuse at all, so does have its place. It is unfortunate that OO languages
  269. force such tradeoffs against non-local reusability goals.
  270.  
  271.  
  272. To the extent to which sp ecification reuse is more important than code reuse, defeasible inheritance
  273. appears to be a net loss. There are certainly better language constructs available that still support
  274. decoupling, default code, and opportunistic white-box reuse, and even the convenience of expressing
  275. specifications,  interfaces,  and  code  in  the  same  framework.  In  fact,  even without  adding  new
  276. constructs, it is very possible to ban all use of defeasible inheritance in languages including C++
  277. and Smalltalk, and still obtain these forms of reuse. However, the constructions are awkward and
  278. unnatural enough that programmers do not employ them in practical development.
  279.  
  280.  
  281.  
  282. 4      Biography
  283.  
  284.  
  285.  
  286. Doug  Lea  teaches  computer  science  at  the  State  University  of  New  York  at  Oswego,  teaches
  287. software  engineering  courses  at  Syracuse  University, co directs  the  Software  Engineering  Lab  at
  288. the  New  York  State  Center  for  Advanced  Technology  in  Computer  Applications  and  Software
  289. Engineering, and  works  on  projects  involving  object-oriented  design,  specification,  distribution,
  290. compilation, reusability, and libraries.
  291.  
  292.  
  293.  
  294.                                                            Lea- 5
  295.