User Tools

Site Tools


what_is_the_advantage_of_distributing_the_interaction_algorithm_in_the_rolemethods_as_suggested_by_dci_instead_of_centralizing_it_in_a_context_method

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

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 08:09]
gazoot Added illustrations for the communication design
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:​+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 the 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]]:
  
 {{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 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:+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}}
  
-Trygve explains the differences between the procedural thinking/​mediator and the distributed DCI algorithm:+Trygve explains the differences between the three:
  
 > Is DCI a procedure oriented paradigm in disguise? My answer is no. Both state and behavior is here distributed among the objects. I see DCI as even more object oriented than regular OO. In DCI, we work with networks of collaborating objects; in regular OO, we work with classes and can only see one object at the time.((http://​fulloo.info/​Documents/​200904commonsense.pdf p.65)) > Is DCI a procedure oriented paradigm in disguise? My answer is no. Both state and behavior is here distributed among the objects. I see DCI as even more object oriented than regular OO. In DCI, we work with networks of collaborating objects; in regular OO, we work with classes and can only see one object at the time.((http://​fulloo.info/​Documents/​200904commonsense.pdf p.65))
  
 Once in a while though, this Context-centric algorithm could have a place. Taking the age-old example of drawing a shape on a window, where each object comes from its corresponding class hierarchy. If the draw algorithm doesn'​t easily decompose in a way that fits naturally in either class or in any corresponding roles, it belongs in the Context. This is the exceptional case, however. Once in a while though, this Context-centric algorithm could have a place. Taking the age-old example of drawing a shape on a window, where each object comes from its corresponding class hierarchy. If the draw algorithm doesn'​t easily decompose in a way that fits naturally in either class or in any corresponding roles, it belongs in the Context. This is the exceptional case, however.
what_is_the_advantage_of_distributing_the_interaction_algorithm_in_the_rolemethods_as_suggested_by_dci_instead_of_centralizing_it_in_a_context_method.1393142953.txt.gz ยท Last modified: 2014/02/23 08:09 by gazoot