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/01/19 23:15]
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 4: Line 4:
 However, a difference between that kind of procedure orientation and object orientation is that in the former, we ask: //"​What happens?"//​ In the latter, we ask: //"Who does what?"//​ Even in a simple example, a reader looses the "​who"​ and thereby important locality context that is essential for building a mental model of the algorithm. However, a difference between that kind of procedure orientation and object orientation is that in the former, we ask: //"​What happens?"//​ In the latter, we ask: //"Who does what?"//​ Even in a simple example, a reader looses the "​who"​ and thereby important locality context that is essential for building a mental model of the algorithm.
  
-A centralized architecture may be OK in simple cases, but the decentralized (DCI) architecture leads to more sophisticated mental model and code.  +A centralized architecture may be OK in simple cases, but the decentralized (DCI) architecture leads to more sophisticated mental model and code. The natural model is for Roles to act like actors in a play, interacting with each other to carry out the work of the system.
- +
-The natural model is for Roles to act like actors in a play, interacting with each other to carry out the work of the system. ​+
  
 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.
  
-Once in a while though, this Context-centric algorithm could have a place. ​The example is 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.+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}} 
 + 
 +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]]:​ 
 + 
 +{{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-style isn't a good solution either. 
 + 
 +DCI strikes a middle road, distributed logic under full control, functionality encapsulated in a Context: 
 + 
 +{{communication:​distributed-dci.png?​500}} 
 + 
 +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)) 
 + 
 +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.1390173318.txt.gz · Last modified: 2014/01/19 23:15 by gazoot