Exercise 2.76. As a large system with generic operations evolves, new types of data objects or new operations may be needed. For each of the three strategies -- generic operations with explicit dispatch, data-directed style, and message-passing-style -- describe the changes that must be made to a system in order to add new types or new operations. Which organization would be most appropriate for a system in which new types must often be added? Which would be most appropriate for a system in which new operations must often be added? ———————————————————————————————————————————————————————————————————————— In explicit dispatch, adding types requires changing all the operations to handle the new types. Adding operations doesn't require any extra work apart from actually handling the dispatch. In the data-directed style, anything which is added needs to be registered in the dispatch table, but this doesn't require changes to any other existing code. Of course code still has to be written for each desired combination of operation and data type. In the message-passing style, adding a new type might require changing existing code to use a new constructor, and adding any new operation will require adding support for that operation to every existing type. If new types are frequently added, the data-directed style might be best. Explicit dispatch in a generic constructor could also be combined with a message-passing style. If new operations are often added, they have to be implemented for each type, which can be done with explicit dispatching or data-directed style without needing to touch existing code. In practice I think future edits are hard to predict and unlikely to be a good descriminant between such styles.