BT

Facilitating the Spread of Knowledge and Innovation in Professional Software Development

Write for InfoQ

Topics

Choose your language

InfoQ Homepage News OOP: Thinking beyond verb/noun metaphor to yield a better design

OOP: Thinking beyond verb/noun metaphor to yield a better design

This item in japanese

To describe object oriented programming, objects are often referred to as “nouns” and actions that determine their behavior as “verbs”. These verbs are traditionally implemented as methods, i.e. systematically coupled to the object that ‘performs’ the action. In a recent blog post, Reg Braithwaite points out that “not all ‘verbs’ have a clear separation between an […] active entity that ought to own the verb's definition and the secondary, passive subject entities that should not own the verb's definition”. This applies for instance to commutative operations and Braithwaite shows that, in this case, linking verbs to objects may result in “code duplication and information leakage”. He argues that it may be relevant to dissociate some verbs from nouns and raise them to the same level of abstraction as the latter:

Maybe some verbs belong to objects, but some are best on their own? Maybe + and <=> and equivalent? really ought to be emancipated from their subservience to objects and ought to have their own definitions.

Buko Obele challenges the validity of the verb/noun metaphor. He argues that, unlike real verbs and nouns, objects and methods cannot exist independently from each other:

The word 'person' in a sentence isn't dependent upon any notion of a particular verb […]. In practice we would never say that a person who can't, for example, 'run' isn't a person […]. In object oriented design concepts do not exist separately and apart from their methods at all -- instead, the whole point is that they are strictly constituted by their methods.

Moreover, in real languages the use of metaphors makes it possible to confuse “subjects and verbs and other purely syntactic concerns” in order “to produce wholly new concepts”, and this is what makes “the extraordinarily creative power of language”. In programming, there are no metaphors. Hence, objects are nothing more than very limited concepts to be combined with other concepts in order “to communicate a solution to a problem” at hand.

Even though Buko Obele argues that one should go beyond verb/noun vision, ultimately his and Braithwaite’s conclusions go along the same lines, both questioning the traditional approach to OOP. While Braithwaite provides some insights on how to decouple verbs from nouns, Obele advocates for focusing on software design that he judges inevitable “whether working with objects or functions or DSLs or even the Great Lisp” :

The question of who verbs 'belong to' is always the wrong question; instead it is always a matter of how a new concept can be meaningfully introduced into our existing system.

[…]

Any talk of nouns and verbs is useful as a starting point but ultimately you will need to do some hard thinking and engage your abstractive kung fu skills in order to describe any non-trivial system.

Rate this Article

Adoption
Style

BT