Chapter 2: Problem 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- styledescribe 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?
Short Answer
Step by step solution
Understanding Generic Operations with Explicit Dispatch
Analyzing Data-Directed Style
Examining Message-Passing Style
Comparing Systems for Type Addition
Comparing Systems for Operation Addition
Unlock Step-by-Step Solutions & Ace Your Exams!
-
Full Textbook Solutions
Get detailed explanations and key concepts
-
Unlimited Al creation
Al flashcards, explanations, exams and more...
-
Ads-free access
To over 500 millions flashcards
-
Money-back guarantee
We refund you if you fail your exam.
Over 30 million students worldwide already upgrade their learning with 91Ó°ÊÓ!
Key Concepts
These are the key concepts you need to understand to accurately answer the question.
Understanding Generic Operations
- Adding a new data type involves teaching the dispatch system to understand this type and stipulate its interactions with existing operations.
- Incorporating a new operation means defining its behavior concerning all known data types within this centralized system.
Exploring Data-Directed Style
- To include a new data type: you add a new row in the table for this type and specify how existing operations apply to it.
- To introduce a new operation: you add a column in the table indicating the operation and assign functionalities for each data type.
Delving Into Message-Passing Style
- To add a new type: one simply defines a new object encapsulating the data type alongside its associated methods.
- For a new operation: you modify each object's class to incorporate the new method, thus endowing it with additional functionality.
Navigating System Evolution
- For system strategies embracing frequent type changes: data-directed style provides an efficient path. It allows developers to simply extend the existing operation table, ensuring minimal disruption to the system's functionality.
- When frequent operational additions are expected: a generic operation with explicit dispatch is advantageous. This allows developers to maintain consistency by updating a centralized dispatch structure for new operations.
Understanding Dispatch Mechanisms
- In explicit dispatch systems: the mechanism is centralized, requiring adjustments at the control level whenever new types or operations are added.
- Data-directed systems: utilize a dispatch table, which helps decentralize these decisions, offering flexibility in adapting to new data types or operations without overriding the entire dispatch system.
- Message-passing systems: lack a traditional dispatch mechanism, as each type-object contains its own methods, making the system inherently flexible yet more complex in managing multiple interactions.