how solve circular reference problems class has class b 1 of properties, while class b has class 1 of properties?
how architect kind of problems?
if take example of nhibernate, there parent-child relationship between objects.
how able handle parent child scenarios?
in cases when i've had have 2 things reference each other, i've created interface remove circular reference. example:
before
public class foo { bar mybar; } public class bar { foo myfoo; }
dependency graph:
foo bar ^ ^ | | bar foo
foo depends on bar, bar depends on foo. if in separate assemblies, have problems building, particularly if clean rebuild.
after
public interface ibar { } public class foo { ibar mybar; } public class bar : ibar { foo myfoo; }
dependency graph:
foo, ibar ibar ^ ^ | | bar foo
both foo , bar depend on ibar. there no circular dependency, , if ibar placed in own assembly, foo , bar being in separate assemblies no longer issue.
Comments
Post a Comment