views:

278

answers:

8

I've designed an MVC that doesn't allow communication between Views (forms). If a form needs to communicate with another form, it raise an event on the controller, which other forms can subscribe to. The general idea is to keep paths of communication to a minimum, helping keep complexity down. Each View communicates with the RootController, which is a singleton, or a subController, which the View accesses through the RootController. Again, it keeps communicate paths down because everything goes through the RootController.

Does this follow general network theory in which the more nodes you add to a network, the more complex it gets. "And", the more each of these nodes communicate directly, the more complexity introduced into the network. Can anyone point out what exactly this area/theory is called? References?

Is what I'm doing with the MVC analogous to having all nodes on the network go through a central node to communicate with each other?

+1  A: 

Sounds like a basic observer pattern.

Allain Lalonde
+3  A: 

Actually it sounds like the mediator pattern...all the communication happens through a central hub...

Jason Punyon
+4  A: 

I think you may want to look up graph theory (which is the basis for network topology).

And your solution does sound like it is analogous to having everything communicating through a central node in a network. This is a good pattern for simplicity (each new node only needs one connection to connect to everything) but is bad for scalability as you will reach a point where the amount of work your RootController is doing is huge. Each new node brings you closer to having a major performance bottleneck in your central node.

workmad3
A: 

I'm not sure that network/graph theory is going to be really helpful here. All the "paths" are of length 1. It seems self-evident that the more forms you have as well as the more these forms interact with each other the more complex your application is. If you are looking to model your application, I think you'd be better off looking at message passing, rather than graph theory.

tvanfosson
A: 

Thanks. In network/graph theory, what is the rate of increase in complexity for each node added and also for each new node that is allowed to communicate with any other node?

@tvanfosson By paths are you referring to edges? The forms aren't going to interact with each other as mentioned in OP.

@workmad3 You are correct at the RootController being a work horse but the app is a desktop client (single user) and has a very small number of forms.

4thSpace
+1  A: 

Well, if you have a complete graph (where a given node is directly connected to every other node), then it would be n(n-1)/2 edges and O(n^2)... Is that what you're looking for?

For hub-and-spoke, you're looking at n-1 edges and O(n) complexity.

However, in the many rails apps that I have worked on, allowing views to call other views has never (that I can recall) caused many problems... it would actually be really difficult to work the whole 'partial' thing without it.

Matt Rogish
A: 

Yes Matt on node to node communication. Thanks.

What about the increase in complexity will only a node is added and all communication goes through a central node. So, no node to node communication.

4thSpace
A: 

But theoretically, as is clear in the equations and O-complexity, allowing views to call other views is a more complicated app. Disclosure: all things being equal (of course someone can make anything complicated).

4thSpace