473,499 Members | 1,931 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

cyclic dependency

This is a report from VSS newsgroup in hope of getting some more suggestions.

Thanks,
Po

-------------------------------------------
I guess I am not getting the whole picture here. How does this apply to the
condition when there is a cyclic reference for the binaries (dlls) in dotNet
!!
What I am thinking is that to use the real ProjectB object I will still need
to create a object from ProjectB for mapping in ProjectA, which again puts
me in loop.

Two interfaces can be made for 2 different project but still for mapping
unless I use dynamic assmebly invoke I do not see how we can do somethng
like following ---

// 1st physical binary (MyProject.Home.dll
namespace MyProject.Home
{
public class ProjectA: System.Windows.Forms.Form
{
public ProjectA()
{ // create object to use later}

public void MyProjA_Method()
{ // do something }

public void MyProjAMethodCallsProjBMethod()
{
int i = (new ProjectB()).CalBalls(5);
}
}
}

//2nd physical binary (MyProject.Work.dll
namespace MyProject.Work
{
public class ProjectB: System.Windows.Forms.Form
{
public void MyMethodInB()
{
ProjectA pA = new ProjectA();
pA.Show();
}

public int CalBalls(int i)
{// return some calculation as int}
}
}

"Jay B. Harlow [MVP - Outlook]" <Ja************@tsbradley.net> wrote in
message news:uX****************@TK2MSFTNGP14.phx.gbl...
Pohihihi,
Normally when I have two projects that need to refer to each other I use a
Separated Interface Pattern.

http://www.martinfowler.com/eaaCatal...Interface.html

Depending on the needs of the solution will decide if I use 2 or 3
projects
to implement the Separated Interface Pattern.

The "easiest" way is to put the interfaces in the first project, then
reference the first project from the second. Alternatively you can put the
interfaces in a project by themselves, and reference the interface project
from both of the other projects.

Something like:

' Project A

Public Interface InterfaceA
Sub SomeMethod()
End Interface

Public Class Something

Sub DoSomething(anA As InterfaceA)
anA.SomeMethod()
End Sub

End Class

' Project B
' references Project A

Public Class SomethingElse
Implements InterfaceA

Sub DoSomething()
Dim something As New Something
something.DoSomething(Me)
End Sub

Sub SomeMethod() Implements InterfaceA.SomeMethod
...
End Sub

End Class

--
Hope this helps
Jay [MVP - Outlook]
.NET Application Architect, Enthusiast, & Evangelist
T.S. Bradley - http://www.tsbradley.net
"Pohihihi" <no*****@hotmail.com> wrote in message
news:ed**************@TK2MSFTNGP10.phx.gbl...
Hello,

I have 2 project A & B belonging to same solution. Now what I want is that
few forms I am accessing from A in B and few I am doing that other way
around. What should I do to not get the error while building solution, I
mean by the build sequencing.

Thanks,
Po


Dec 24 '05 #1
3 2101
Po,

Forgive me for saying so, but I see cyclical references between
assemblies as a sign of bad design. If they really have a need to have that
level of familiarity with each other, then I don't see why they can't be in
the same assembly.

If you really need this, the only way to do it is the way that Jay
suggested, using interfaces. Otherwise, you will have to place the classes
in the same assembly.

On top of that, I don't think that you will find circular references in
..NET anytime soon. I think it was considered at one point, but shot down
pretty quickly.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Pohihihi" <no*****@hotmail.com> wrote in message
news:O8*************@TK2MSFTNGP14.phx.gbl...
This is a report from VSS newsgroup in hope of getting some more
suggestions.

Thanks,
Po

-------------------------------------------
I guess I am not getting the whole picture here. How does this apply to the
condition when there is a cyclic reference for the binaries (dlls) in dotNet
!!
What I am thinking is that to use the real ProjectB object I will still need
to create a object from ProjectB for mapping in ProjectA, which again puts
me in loop.

Two interfaces can be made for 2 different project but still for mapping
unless I use dynamic assmebly invoke I do not see how we can do somethng
like following ---

// 1st physical binary (MyProject.Home.dll
namespace MyProject.Home
{
public class ProjectA: System.Windows.Forms.Form
{
public ProjectA()
{ // create object to use later}

public void MyProjA_Method()
{ // do something }

public void MyProjAMethodCallsProjBMethod()
{
int i = (new ProjectB()).CalBalls(5);
}
}
}

//2nd physical binary (MyProject.Work.dll
namespace MyProject.Work
{
public class ProjectB: System.Windows.Forms.Form
{
public void MyMethodInB()
{
ProjectA pA = new ProjectA();
pA.Show();
}

public int CalBalls(int i)
{// return some calculation as int}
}
}

"Jay B. Harlow [MVP - Outlook]" <Ja************@tsbradley.net> wrote in
message news:uX****************@TK2MSFTNGP14.phx.gbl...
Pohihihi,
Normally when I have two projects that need to refer to each other I use a
Separated Interface Pattern.

http://www.martinfowler.com/eaaCatal...Interface.html

Depending on the needs of the solution will decide if I use 2 or 3
projects
to implement the Separated Interface Pattern.

The "easiest" way is to put the interfaces in the first project, then
reference the first project from the second. Alternatively you can put the
interfaces in a project by themselves, and reference the interface project
from both of the other projects.

Something like:

' Project A

Public Interface InterfaceA
Sub SomeMethod()
End Interface

Public Class Something

Sub DoSomething(anA As InterfaceA)
anA.SomeMethod()
End Sub

End Class

' Project B
' references Project A

Public Class SomethingElse
Implements InterfaceA

Sub DoSomething()
Dim something As New Something
something.DoSomething(Me)
End Sub

Sub SomeMethod() Implements InterfaceA.SomeMethod
...
End Sub

End Class

--
Hope this helps
Jay [MVP - Outlook]
.NET Application Architect, Enthusiast, & Evangelist
T.S. Bradley - http://www.tsbradley.net
"Pohihihi" <no*****@hotmail.com> wrote in message
news:ed**************@TK2MSFTNGP10.phx.gbl...
Hello,

I have 2 project A & B belonging to same solution. Now what I want is that
few forms I am accessing from A in B and few I am doing that other way
around. What should I do to not get the error while building solution, I
mean by the build sequencing.

Thanks,
Po


Dec 24 '05 #2
Nicholas,

Yes, I agree, but we are limited to what is giving as other team do not
agree to change anything other than adding one line for our part. Only thing
I wish is that managers would understand more of the programming than
deadlines.

Thanks.


"Nicholas Paldino [.NET/C# MVP]" <mv*@spam.guard.caspershouse.com> wrote in
message news:uS**************@TK2MSFTNGP09.phx.gbl...
Po,

Forgive me for saying so, but I see cyclical references between
assemblies as a sign of bad design. If they really have a need to have
that level of familiarity with each other, then I don't see why they can't
be in the same assembly.

If you really need this, the only way to do it is the way that Jay
suggested, using interfaces. Otherwise, you will have to place the
classes in the same assembly.

On top of that, I don't think that you will find circular references in
.NET anytime soon. I think it was considered at one point, but shot down
pretty quickly.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Pohihihi" <no*****@hotmail.com> wrote in message
news:O8*************@TK2MSFTNGP14.phx.gbl...
This is a report from VSS newsgroup in hope of getting some more
suggestions.

Thanks,
Po

-------------------------------------------
I guess I am not getting the whole picture here. How does this apply to
the
condition when there is a cyclic reference for the binaries (dlls) in
dotNet
!!
What I am thinking is that to use the real ProjectB object I will still
need
to create a object from ProjectB for mapping in ProjectA, which again puts
me in loop.

Two interfaces can be made for 2 different project but still for mapping
unless I use dynamic assmebly invoke I do not see how we can do somethng
like following ---

// 1st physical binary (MyProject.Home.dll
namespace MyProject.Home
{
public class ProjectA: System.Windows.Forms.Form
{
public ProjectA()
{ // create object to use later}

public void MyProjA_Method()
{ // do something }

public void MyProjAMethodCallsProjBMethod()
{
int i = (new ProjectB()).CalBalls(5);
}
}
}

//2nd physical binary (MyProject.Work.dll
namespace MyProject.Work
{
public class ProjectB: System.Windows.Forms.Form
{
public void MyMethodInB()
{
ProjectA pA = new ProjectA();
pA.Show();
}

public int CalBalls(int i)
{// return some calculation as int}
}
}

"Jay B. Harlow [MVP - Outlook]" <Ja************@tsbradley.net> wrote in
message news:uX****************@TK2MSFTNGP14.phx.gbl...
Pohihihi,
Normally when I have two projects that need to refer to each other I use
a
Separated Interface Pattern.

http://www.martinfowler.com/eaaCatal...Interface.html

Depending on the needs of the solution will decide if I use 2 or 3
projects
to implement the Separated Interface Pattern.

The "easiest" way is to put the interfaces in the first project, then
reference the first project from the second. Alternatively you can put
the
interfaces in a project by themselves, and reference the interface
project
from both of the other projects.

Something like:

' Project A

Public Interface InterfaceA
Sub SomeMethod()
End Interface

Public Class Something

Sub DoSomething(anA As InterfaceA)
anA.SomeMethod()
End Sub

End Class

' Project B
' references Project A

Public Class SomethingElse
Implements InterfaceA

Sub DoSomething()
Dim something As New Something
something.DoSomething(Me)
End Sub

Sub SomeMethod() Implements InterfaceA.SomeMethod
...
End Sub

End Class

--
Hope this helps
Jay [MVP - Outlook]
.NET Application Architect, Enthusiast, & Evangelist
T.S. Bradley - http://www.tsbradley.net
"Pohihihi" <no*****@hotmail.com> wrote in message
news:ed**************@TK2MSFTNGP10.phx.gbl...
Hello,

I have 2 project A & B belonging to same solution. Now what I want is
that
few forms I am accessing from A in B and few I am doing that other way
around. What should I do to not get the error while building solution, I
mean by the build sequencing.

Thanks,
Po

Dec 24 '05 #3
I also have a problem with circular dependancy which I would like some advice
about. I have to say I don't understand the reasoning behins this circular
dependancy rule at all. In the old days you could have two classes that
refered to each other and the linker never complained, what's the difference?
Anyway, I have a perfectly reasonable situation, I have a configuration
class that contains information about my system generally, and I have an
event logging class that writes events to a file. They are in separate
assemblies, which seems reasonable. The configuration class contains a log
file retention period which the event logger needs. However the configuration
class also needs to log events. Can't be done. Now, I could put both classes
in the same assembly. In fact I could put all my classes into one great big
assembly, but surely that is not the way. What is the answer?
--
Dave
"Nicholas Paldino [.NET/C# MVP]" wrote:
Po,

Forgive me for saying so, but I see cyclical references between
assemblies as a sign of bad design. If they really have a need to have that
level of familiarity with each other, then I don't see why they can't be in
the same assembly.

If you really need this, the only way to do it is the way that Jay
suggested, using interfaces. Otherwise, you will have to place the classes
in the same assembly.

On top of that, I don't think that you will find circular references in
..NET anytime soon. I think it was considered at one point, but shot down
pretty quickly.

Hope this helps.
--
- Nicholas Paldino [.NET/C# MVP]
- mv*@spam.guard.caspershouse.com

"Pohihihi" <no*****@hotmail.com> wrote in message
news:O8*************@TK2MSFTNGP14.phx.gbl...
This is a report from VSS newsgroup in hope of getting some more
suggestions.

Thanks,
Po

-------------------------------------------
I guess I am not getting the whole picture here. How does this apply to the
condition when there is a cyclic reference for the binaries (dlls) in dotNet
!!
What I am thinking is that to use the real ProjectB object I will still need
to create a object from ProjectB for mapping in ProjectA, which again puts
me in loop.

Two interfaces can be made for 2 different project but still for mapping
unless I use dynamic assmebly invoke I do not see how we can do somethng
like following ---

// 1st physical binary (MyProject.Home.dll
namespace MyProject.Home
{
public class ProjectA: System.Windows.Forms.Form
{
public ProjectA()
{ // create object to use later}

public void MyProjA_Method()
{ // do something }

public void MyProjAMethodCallsProjBMethod()
{
int i = (new ProjectB()).CalBalls(5);
}
}
}

//2nd physical binary (MyProject.Work.dll
namespace MyProject.Work
{
public class ProjectB: System.Windows.Forms.Form
{
public void MyMethodInB()
{
ProjectA pA = new ProjectA();
pA.Show();
}

public int CalBalls(int i)
{// return some calculation as int}
}
}

"Jay B. Harlow [MVP - Outlook]" <Ja************@tsbradley.net> wrote in
message news:uX****************@TK2MSFTNGP14.phx.gbl...
Pohihihi,
Normally when I have two projects that need to refer to each other I use a
Separated Interface Pattern.

http://www.martinfowler.com/eaaCatal...Interface.html

Depending on the needs of the solution will decide if I use 2 or 3
projects
to implement the Separated Interface Pattern.

The "easiest" way is to put the interfaces in the first project, then
reference the first project from the second. Alternatively you can put the
interfaces in a project by themselves, and reference the interface project
from both of the other projects.

Something like:

' Project A

Public Interface InterfaceA
Sub SomeMethod()
End Interface

Public Class Something

Sub DoSomething(anA As InterfaceA)
anA.SomeMethod()
End Sub

End Class

' Project B
' references Project A

Public Class SomethingElse
Implements InterfaceA

Sub DoSomething()
Dim something As New Something
something.DoSomething(Me)
End Sub

Sub SomeMethod() Implements InterfaceA.SomeMethod
...
End Sub

End Class

--
Hope this helps
Jay [MVP - Outlook]
.NET Application Architect, Enthusiast, & Evangelist
T.S. Bradley - http://www.tsbradley.net
"Pohihihi" <no*****@hotmail.com> wrote in message
news:ed**************@TK2MSFTNGP10.phx.gbl...
Hello,

I have 2 project A & B belonging to same solution. Now what I want is that
few forms I am accessing from A in B and few I am doing that other way
around. What should I do to not get the error while building solution, I
mean by the build sequencing.

Thanks,
Po


Feb 9 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
2729
by: Brian Sabolik | last post by:
I'm not sure if I've broken any Object Oriented rules or not, but ... I have projects in 2 different solutions that need to use each other's methods. Therefore I may have an "update" method in...
3
2220
by: Dennis Lerche | last post by:
Hi I have a problem regarding cyclic dependency, yeahh I know bad design. But right at this moment I can't see how it should be redesigned to avoid this. The problem is that I just can't get it...
4
4535
by: Alex Sedow | last post by:
For example, System.dll contains assembly reference to System.XML.dll, System.XML.dll refers to System.dll. Some another open projects contain cyclic assembly dependencies too. How C# compiler...
3
2719
by: fc2004 | last post by:
Hi, Is there any tools that could report where cyclic header dependency happens? this would be useful when working with a large project where tens or hundreds of headers files may form complex...
4
1712
by: sakis.panou | last post by:
Hi all, Can anyone explain to me why the copy constructor of the COuterClass is getting called for this one? Let me start by saying I reckon this is seriously bad way of implementing anything of...
1
2246
by: Joe Peterson | last post by:
I've been doing a lot of searching on the topic of one of Python's more disturbing issues (at least to me): the fact that if a __del__ finalizer is defined and a cyclic (circular) reference is...
1
677
by: pallav | last post by:
I have to header files, circuit.h and latch.h that reference each other and are causing a cyclic dependency. latch.h file #include "circuit.h" typedef boost::shared_ptr<struct LatchLatchPtr;...
3
1736
by: soup007 | last post by:
Hi, I am having some difficulties with cyclic dependency between two classes. Situation is something like following - ///A.h #include "B.h" class A { { int X; public:
11
3185
by: sgurukrupagmailcom | last post by:
Hi, When searching for a solution to my problem I stumbled upon 'Curiously Recurring Template Pattern' see link. This is how the pattern looks: template < typename T > struct y { } ;
0
7134
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7225
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
6901
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7392
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
4920
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4605
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3101
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1429
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
667
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.