Saturday, June 30, 2007

Links and Nodes: here's a coupling problem

Here's a coupling problem. Consider a class TLINK, which should, of course, link two nodes, providing an association or connotation between them. It should obviously have something like:

TLINK.Create_Link (Node1, Node2, Link_Type, Link_Distance, etc.)

but here's a problem I'm currently brainstorming. This class uses the class of Nodes, right? Ok. Now, the Nodes Class also uses this (Link) one, because, when spreading activation (through observer pattern behavior: nodes observe other nodes's activation levels), one needs to know at least the link_distance. Whether or not link_distance is constant throughout a run, it is needed in the spreading activation function. So we end up with the following situation:

Class A (Links) needs objects from Class B (Nodes)

&

Class B (Nodes) needs info from Class A (Link_Distances) in order to function.


It would be just fine to strongly couple them for now. But this is a class library, and in the future, when someone wants to create an entirely new application that can't be foreseen now, strong coupling just won't work.

Remember the Hollywood principle: "Don't call us, we'll call you".

So I'm brainstorming on this one for now...

0 comments: