This page documents UML diagrams for the solutions to the Expression Problem using object algebras as described here by Bruno C. d. S. Oliveira and William R. Cook. Consider a simple expression evaluation consisting only of “literal” and “add”. The UML class diagram is shown below:
Augmenting the above with the “subtract” operator yields the following class diagram:
Now if we want to add a Print feature in addition to the Eval Feature we would add classes as show below:
Notice that since Print starts off with “lit”, “add” and “sub”, there is no need multiple inheritance as for Eval.
The solution appears simple enough that you may wonder what the fuss is all about. It is more likely a case of a solution becoming obvious after the solution is given.