Dependency Graphs

Christian_
Endlosschleifenbastler
Endlosschleifenbastler
Beiträge: 178
Registriert: 10. Apr 2009 16:30

Dependency Graphs

Beitrag von Christian_ »

I got a question regarding dependency edges when using Signal.getVal
given example:

Code: Alles auswählen

val s1: Signal[Int] = Siganl{...}
val s2: Signal[Int] = Signal{...}
val t = Signal{s1() + s2.getVal}
t is only updated when s1 changes but also uses the value of s2.
Should we draw an edge from s2 to t?


My next question is about Signals passed to objects

Code: Alles auswählen

val s1: Signal[Int] = Signal{...}
val s2: Signal[Int] = Signal{...}
val o1 = new SignalDependent(s1)
val o2 = new SignalDependent(s2)

class SignalDependent(val x: Signal[Int]){
val y: Signal[Int] = Signal{x() + 5}
}
how to model a dependancy graph in the example above? Especially the Signal y.
Omnium rerum principia parva sunt. -Cicero

imaier
Mausschubser
Mausschubser
Beiträge: 61
Registriert: 21. Okt 2013 21:27

Re: Dependency Graphs

Beitrag von imaier »

For getVal dependencies, please use a different edge style than for other dependencies or put a getVal next to the edge.

For your second example, I don't see the problem: y depends on x, and you have one y and one x per instance of SignalDependent. That should make clear how your dependency graph will look like. Use appropriate names for the nodes to distinguish between the different y's. It should be rather obvious what the proper name for these should be, given that you have names for the SignalDependent instances. I don't wanna say more about it, since you have to do a little thinking on your own, even thought there is not much more left now :)

Cheers,
Ingo

Antworten

Zurück zu „Archiv“