This shows you the differences between two versions of the page.
what_is_the_advantage_of_distributing_the_interaction_algorithm_in_the_rolemethods_as_suggested_by_dci_instead_of_centralizing_it_in_a_context_method [2014/02/23 09:17] gazoot |
what_is_the_advantage_of_distributing_the_interaction_algorithm_in_the_rolemethods_as_suggested_by_dci_instead_of_centralizing_it_in_a_context_method [2014/10/21 23:36] (current) gazoot Added note about polymorphism |
||
---|---|---|---|
Line 8: | Line 8: | ||
Most of the time, putting the algorithm in the Context is global procedural thinking: an all-knowing algorithm orchestrating conscribed objects to perform low-level operations on the behalf of the procedure. You can of course do that in DCI and of course can do it through generic interfaces, but it's not DCI. | Most of the time, putting the algorithm in the Context is global procedural thinking: an all-knowing algorithm orchestrating conscribed objects to perform low-level operations on the behalf of the procedure. You can of course do that in DCI and of course can do it through generic interfaces, but it's not DCI. | ||
- | So to illustrate, we have the current "OO" way of creating object communication, passing messages wherever and whenever it is needed: | + | So to illustrate, we have the current "OO" way of creating object communication, passing messages between objects wherever and whenever it is needed: |
{{communication:current-oo.png}} | {{communication:current-oo.png}} | ||
- | This approach is too chaotic, and it doesn't help that there is no separation of data and behavior in the current OO paradigm. Reasoning about system behavior is very hard. | + | This approach is too chaotic, and it doesn't help that there is no separation of data and behavior in the current OO paradigm, or that polymorphism often makes it very hard to know where the program execution will move next. Reasoning about system behavior and functionality is very hard. |
Then we have procedural thinking, or as it can be implemented in OO-programming, the [[https://en.wikipedia.org/wiki/Mediator_pattern|mediator pattern]]: | Then we have procedural thinking, or as it can be implemented in OO-programming, the [[https://en.wikipedia.org/wiki/Mediator_pattern|mediator pattern]]: | ||
Line 18: | Line 18: | ||
{{communication:mediator-pattern.png?500}} | {{communication:mediator-pattern.png?500}} | ||
- | This approach actually prevents object communication, leading to a complex all-knowing algorithm. It's too rigid for responding quickly to system changes, so stepping back to Pascal or Fortran isn't a good solution either. | + | This approach actually prevents object communication, leading to a complex all-knowing algorithm. It's too rigid for responding quickly to system changes, so stepping back to Pascal or Fortran-style isn't a good solution either. |
- | DCI strikes a middle road, distributed logic under full control, encapsulated in a Context: | + | DCI strikes a middle road, distributed logic under full control, functionality encapsulated in a Context: |
{{communication:distributed-dci.png?500}} | {{communication:distributed-dci.png?500}} |