Abstraction over implementation structure with symmetrically encapsulated multimethods

  • Authors:
  • David Lievens;William Harrison

  • Affiliations:
  • -;-

  • Venue:
  • Science of Computer Programming
  • Year:
  • 2013

Quantified Score

Hi-index 0.00

Visualization

Abstract

In object-oriented languages, methods are encapsulated, hence module interfaces are made up of sets of methods partitioned along the objects or classes that make up the module. This prevents abstraction over the implementation structure of applications. Any change in method placement may cause a global effect that ripples through all clients depending on that method. Sometimes this unduly restricts the scope of software evolution, particularly for methods with multiple parameters where there is no clear owner. We investigate a simple scheme where methods may be defined in the classes of any of their parameters. This allows client code to be oblivious to choice of method placement, and therefore immune against it changing. When combined with multiple dispatch, this scheme allows for modular extensibility, where methods defined in one class may be overloaded by methods defined in classes that are not its subclasses. We detail our proposal by extending a core calculus of class-based object-oriented languages with these symmetrically encapsulated multimethods, and prove the result sound. It is well-known that multiple dispatch is at odds with modular type-checking. We also discuss different strategies that can be followed to mitigate the type-checking problem and propose variants of the original calculus that are amenable to modular checking.