This shows you the differences between two versions of the page.
can_a_role_be_played_by_several_different_objects_in_a_given_context_instantiation [2014/01/20 01:56] gazoot created |
can_a_role_be_played_by_several_different_objects_in_a_given_context_instantiation [2014/03/11 13:35] (current) gazoot Added a more technical explanation. |
||
---|---|---|---|
Line 2: | Line 2: | ||
No. All Roles are bound as an atomic operation before an Interaction starts. And the Role being an alias for a single object, means that there can only be one object per Role during an Interaction. | No. All Roles are bound as an atomic operation before an Interaction starts. And the Role being an alias for a single object, means that there can only be one object per Role during an Interaction. | ||
- | Why is switching a problem? Imagine switching your favorite James Bond actor for your least favorite //during the same movie//. | + | Why is switching (rebinding during Interaction) a problem? It creates a conflict with the mental model. Objects in a certain context must be the same as they were at all points during an Interaction. If you write a Use Case for example, any object referred to in the beginning must be the same at the end, for consistency reasons. The same goes for Contexts (and a goal with DCI is to map Use Cases to code.) |
+ | |||
+ | A somewhat halting analogy of the above confusion: Imagine switching your favorite James Bond actor for your least favorite //during the same movie//. | ||
Note: The Roles can all be rebound before another Interaction in the same Context occurs. | Note: The Roles can all be rebound before another Interaction in the same Context occurs. |