Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > .NET General

Vista Tutorial - Problem with circular references

Reply
 
Old 01-09-2009   #1 (permalink)
don H. Lee
Guest


 
 

Problem with circular references

Hi newsgroup

I have a little problem in designing my assemblies.

Following situation:

1. I have 3 Assemblies: Assembly_A, Assembly_B and Assembly_C
2. Assembly_A has a Collection of Assembly_C
3. Assembly_B has as Collection of Assembly_C
4. Assembly_C has a Object of Assembly_A and another one of Assembly_B

So that's the situation and the situation must be like this (relationally)
because Assembly_A and Assembly_B represent contractors and Assembly_C
represents the contract. A contract is made between A and B.

Both contractors can have n contracts. A contract has one A and one B.

When trying to build this solution with team build the build process stops
in case of circular references.
It is logical, because A cannot be build until C is build and C cannot be
build until A is build.

Now my question. Is there a desing that don't destry the logic of the
depencies between the assemblies but don't result in build errors.

If not, what kind of design should I use for cases like this?

Thanks for every suggestions and help!

Best regards

D.H. Lee



My System SpecsSystem Spec
Old 01-09-2009   #2 (permalink)
Adam Benson
Guest


 
 

Re: Problem with circular references

If possible, commonly used objects should be pushed into common assemblies.
So if what C uses in A doesn't have to be in A but could be in
MyCommonStuff.dll (that knows nothing about A, B or C) then so much the
better. Look seriously at whether or not you can achieve this. But if that's
not possible then a couple of general comments :

1) use interfaces.

If A needs B and B needs C and C needs A, then change it so that C knows
absolutely nothing about A but uses an interface (defined in
MyCommonStuff.dll) that A supports.

2) dynamic loading and object creation

You can write C so that at run time it gets passed a few strings that tell
it you need type "MyNameSpace.MyType" and its in assembly "MyDll_C.dll" The
type supports an interface that C knows about and hey presto it works.

A circular reference definitely means your design needs changing.

HTH,

Adam.

"don H. Lee" <nospam@xxxxxx> wrote in message
news:O5TTJ3icJHA.1532@xxxxxx
Quote:

> Hi newsgroup
>
> I have a little problem in designing my assemblies.
>
> Following situation:
>
> 1. I have 3 Assemblies: Assembly_A, Assembly_B and Assembly_C
> 2. Assembly_A has a Collection of Assembly_C
> 3. Assembly_B has as Collection of Assembly_C
> 4. Assembly_C has a Object of Assembly_A and another one of Assembly_B
>
> So that's the situation and the situation must be like this (relationally)
> because Assembly_A and Assembly_B represent contractors and Assembly_C
> represents the contract. A contract is made between A and B.
>
> Both contractors can have n contracts. A contract has one A and one B.
>
> When trying to build this solution with team build the build process stops
> in case of circular references.
> It is logical, because A cannot be build until C is build and C cannot be
> build until A is build.
>
> Now my question. Is there a desing that don't destry the logic of the
> depencies between the assemblies but don't result in build errors.
>
> If not, what kind of design should I use for cases like this?
>
> Thanks for every suggestions and help!
>
> Best regards
>
> D.H. Lee
>

My System SpecsSystem Spec
Old 01-09-2009   #3 (permalink)
Jack Jackson
Guest


 
 

Re: Problem with circular references

On Fri, 9 Jan 2009 08:40:03 +0100, "don H. Lee" <nospam@xxxxxx> wrote:
Quote:

>Hi newsgroup
>
>I have a little problem in designing my assemblies.
>
>Following situation:
>
>1. I have 3 Assemblies: Assembly_A, Assembly_B and Assembly_C
>2. Assembly_A has a Collection of Assembly_C
>3. Assembly_B has as Collection of Assembly_C
>4. Assembly_C has a Object of Assembly_A and another one of Assembly_B
>
>So that's the situation and the situation must be like this (relationally)
>because Assembly_A and Assembly_B represent contractors and Assembly_C
>represents the contract. A contract is made between A and B.
>
>Both contractors can have n contracts. A contract has one A and one B.
>
>When trying to build this solution with team build the build process stops
>in case of circular references.
>It is logical, because A cannot be build until C is build and C cannot be
>build until A is build.
>
>Now my question. Is there a desing that don't destry the logic of the
>depencies between the assemblies but don't result in build errors.
>
>If not, what kind of design should I use for cases like this?
>
>Thanks for every suggestions and help!
>
>Best regards
>
>D.H. Lee
I would probably use and Interface to represent the contractors in C.
A and B would implement that Interface, which would be defined in a
fourth assembly that does not reference any of the others.
My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
Project References. .NET General
references an object name with a variable PowerShell
Best references for learning C# for PowerShell? PowerShell


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46