|
|
|
date: Thu, 22 Dec 2005 22:04:18 -1000,
group: microsoft.public.vsnet.vss
back
Re: cyclic dependency
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]" wrote in
message news:uX7Dn%238BGHA.2036@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/eaaCatalog/separatedInterface.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" wrote in message
> news:edk95d5BGHA.1544@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
>
>
date: Fri, 23 Dec 2005 17:10:45 -1000
author: Pohihihi
Re: cyclic dependency
Phihihi,
|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
The Separated Interface Pattern removes the need for cyclic references of
binaries in dotNet! Which IMHO is rarely needed, as this Design Pattern &
its variations demonstrate.
| 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.
If you start with ProjectA and it has the interface, then ProjectB needs to
reference ProjectA. ProjectB can create either A object & B objects (as it
references the first assembly). However ProjectA can only create A objects,
it needs to be "handed" B objects, or as you suggest, dynamically create B
objects.
| Two interfaces can be made for 2 different project but still for mapping
Only one interface is needed.
| unless I use dynamic assmebly invoke I do not see how we can do
Only one of the assemblies is allowed to create objects, the one opposite
where the interface is defined.
I've used a variation of the Separated Interface Pattern, where the name of
the object to create is stored in the app.config/web.config and Type.GetType
& Activator.CreateInstance are used to create an instance of the specific
object, similar to how the Providers work in ASP.NET 2.0.
| somethng
| like following ---
| // 1st physical binary (MyProject.Home.dll
| namespace MyProject.Home
interface IProjectB
{
int CalBalls(int i);
}
| public void MyProjAMethodCallsProjBMethod(IProjectB aProjectB)
| {
| int i = aProjectB.CalBalls(5);
| }
| //2nd physical binary (MyProject.Work.dll
| namespace MyProject.Work
| {
| public class ProjectB: System.Windows.Forms.Form, IProjectB
Something else, would need to create the ProjectB object, either by B
calling back into A, or ProjectC that references both A & B.
If you don't have Martin's book, you may want to locate a copy, as he goes
into greater detail on how to get this pattern to work.
--
Hope this helps
Jay [MVP - Outlook]
..NET Application Architect, Enthusiast, & Evangelist
T.S. Bradley - http://www.tsbradley.net
"Pohihihi" wrote in message
news:OS1KjeDCGHA.2616@TK2MSFTNGP10.phx.gbl...
|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]" wrote in
| message news:uX7Dn%238BGHA.2036@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/eaaCatalog/separatedInterface.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" wrote in message
| > news:edk95d5BGHA.1544@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
| >
| >
|
|
date: Sat, 24 Dec 2005 10:54:32 -0600
author: Jay B. Harlow [MVP - Outlook]
Re: cyclic dependency
That lights lot of things, Thanks Jay.
"Jay B. Harlow [MVP - Outlook]" wrote in
message news:e9$63qKCGHA.628@TK2MSFTNGP14.phx.gbl...
> Phihihi,
> |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
> The Separated Interface Pattern removes the need for cyclic references of
> binaries in dotNet! Which IMHO is rarely needed, as this Design Pattern &
> its variations demonstrate.
>
> | 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.
> If you start with ProjectA and it has the interface, then ProjectB needs
> to
> reference ProjectA. ProjectB can create either A object & B objects (as it
> references the first assembly). However ProjectA can only create A
> objects,
> it needs to be "handed" B objects, or as you suggest, dynamically create B
> objects.
>
> | Two interfaces can be made for 2 different project but still for mapping
> Only one interface is needed.
>
> | unless I use dynamic assmebly invoke I do not see how we can do
> Only one of the assemblies is allowed to create objects, the one opposite
> where the interface is defined.
>
> I've used a variation of the Separated Interface Pattern, where the name
> of
> the object to create is stored in the app.config/web.config and
> Type.GetType
> & Activator.CreateInstance are used to create an instance of the specific
> object, similar to how the Providers work in ASP.NET 2.0.
>
> | somethng
> | like following ---
>
> | // 1st physical binary (MyProject.Home.dll
> | namespace MyProject.Home
> interface IProjectB
> {
> int CalBalls(int i);
> }
>
> | public void MyProjAMethodCallsProjBMethod(IProjectB aProjectB)
> | {
> | int i = aProjectB.CalBalls(5);
> | }
>
> | //2nd physical binary (MyProject.Work.dll
> | namespace MyProject.Work
> | {
> | public class ProjectB: System.Windows.Forms.Form, IProjectB
>
> Something else, would need to create the ProjectB object, either by B
> calling back into A, or ProjectC that references both A & B.
>
> If you don't have Martin's book, you may want to locate a copy, as he goes
> into greater detail on how to get this pattern to work.
>
> --
> Hope this helps
> Jay [MVP - Outlook]
> .NET Application Architect, Enthusiast, & Evangelist
> T.S. Bradley - http://www.tsbradley.net
>
>
> "Pohihihi" wrote in message
> news:OS1KjeDCGHA.2616@TK2MSFTNGP10.phx.gbl...
> |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]" wrote in
> | message news:uX7Dn%238BGHA.2036@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/eaaCatalog/separatedInterface.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" wrote in message
> | > news:edk95d5BGHA.1544@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
> | >
> | >
> |
> |
>
>
date: Sat, 24 Dec 2005 13:16:47 -1000
author: Pohihihi
|
|