Re: Observer pattern limitations




"Dmitry A. Kazakov" wrote in message:
On Fri, 14 Jul 2006 14:29:25 -0500, Leslie Sanford wrote:

Here is an example that can cause a problem:

---------------->

+---+out
| B |--+
+---+ |
+---+ out |in | in+---+out
| A |-------+ +---| D |---->
+---+ |in | +---+
+---+ |
| C |--+
+---+out

So how can this be solved?

[snip]

There exist other solutions as well.

1. In the data-flow language I designed, D is triggered by an
expression @B~@C, which has the semantics: "both time stamps have been
incremented." This kills the race condition between B and C.

2. In synchronous data-flow languages (my is asynchronous) like
Simulink, there is no problem at all, because D(n+1) takes B(n) and
C(n) from the state vector of the previous step.

This second one sounds similar to an another idea I've been toying with.
The components are placed in an array of lists. At each index in the
array, there is a list of components that process the signal at the same
step in the algorithm. So to run the algorithm, you iterate through the
array and iterate through the list at each index, instructing the
components to perform their calculation. In my above example, 'A' would
be at index 0, 'B' and 'C' at index 1, and 'D' at index 2.

So the code for running the algorithm could possibly look like this:

for(int i = 0; i < componentArray.Length; i++)
{
foreach(Component c in componentArray[i])
{
c.Calculate();
}
}

Is this close to what you've described?




.



Relevant Pages

  • Re: Observer pattern limitations
    ... In the data-flow language I designed, ... The components are placed in an array of lists. ... So to run the algorithm, ...
    (comp.object)
  • Re: Cons cell archaic!?
    ... from s-expression or XML or other syntax you keep the bloated array ... For using vectors to emulate lists that ... Allocate 2, move 1 element: ... What do you think of that algorithm? ...
    (comp.lang.lisp)
  • Re: Algorithm Runtime???
    ... Sam Jarenson wrote in news:030220042358433814% ... we iterate r over the remaining n-1 elements. ... The Omeans that if we double 'n', the length of the array, we ... how long your algorithm will take to execute (on the setup the timings ...
    (comp.programming)
  • Re: How many bytes per Italian character?
    ... it is a hyrbrid solution between array and list ... Another cool algorithm I did some years ago was to create sparse arrays with constant time ... was to represent parser state tables, where the dimensionality is n*m, for n the number of ... for large lists without thinking too hard about it. ...
    (microsoft.public.vc.mfc)
  • Re: Slow Macros in Excel 2007
    ... The concept of using an array or an array of arrays applies went you ... need to iterate through a result set and insert all the data into a ... Worksheet using a *SINGLE* VBA instruction. ... AppleScript lists translate into Arrays in VBA - but not always. ...
    (microsoft.public.excel.programming)