Comments on “the law of demeter” and C++

  • Authors:
  • M. Sakkinen

  • Affiliations:
  • Univ. of Jyva¨skyla¨, Jyva¨skyla¨, Finland

  • Venue:
  • ACM SIGPLAN Notices
  • Year:
  • 1988

Quantified Score

Hi-index 0.02

Visualization

Abstract

A rule of good style for object-oriented programming has recently been put forward, actually in several flavours (class vs. object, weak vs. strong). Some possible problems in the original rule are discussed, and a modified formulation is proposed to overcome at least part of the them. Doubts still remain about how useful the rule is with Smalltalk and other untyped languages. Then the application of the rule to the C++ language is studied and shown not to be as straightforward as has been suggested. This is largely a consequence of the intertwining of the conventional and the object-oriented component in C++. On the other hand, being typed, it is a promising language for enforcing rules of this kind at compile time. A new language-specific formulation is finally presented, argumenting that it is better in class than object flavour.