Is there a way to control class coupling in C#
Posted on 2011-04-18
In part of my design I have two classes, A and B, that are both aware of a common data structure C (also a class). While most of the contents of A and B are private or protected, there are some public members for various reasons. A and B are supposed to be completely decoupled - I would like to enforce a rule at compile time that says that A will not talk to B directly at all and vice versa. Logic using these two classes (or instances of these 2 classes) would be by a 3rd party generally using an instance of the common data structure C.
I was wondering about a good way to express this rule in my code (the rule being that A and B are completely decoupled). Would namespaces be good for this and/or is there another way?