PC Review


Reply
Thread Tools Rate Thread

Class Action

 
 
pigeonrandle
Guest
Posts: n/a
 
      8th Aug 2006
Hi,
Funnily enough, i have a question about passing data between classes.
There's an excellent diagram below to help drive away any confusion.

I have class A which contains an instance of class B and class E.
Class B contains an instance of class C.

What is the best way to move an object (class D) created in class C to
class E?!

A
{
...B
{
.....C
{
.......D (from inside class C)
}
}
...E
{
..... (to inside class E)
}
}

I am currently raising a chain of events in the classes with class D as
part of the EventArgs. This seems like a rather contrived method so any
adivice you have will be greatfully received.

Cheers,
James Randle.

 
Reply With Quote
 
 
 
 
Bill Butler
Guest
Posts: n/a
 
      8th Aug 2006
"pigeonrandle" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi,
> Funnily enough, i have a question about passing data between classes.
> There's an excellent diagram below to help drive away any confusion.
>
> I have class A which contains an instance of class B and class E.
> Class B contains an instance of class C.
>
> What is the best way to move an object (class D) created in class C to
> class E?!
>
> A
> {
> ..B
> {
> ....C
> {
> ......D (from inside class C)
> }
> }
> ..E
> {
> .... (to inside class E)
> }
> }
>


You say that class A contains an INSTANCE of B and E which looks like
this:

public class A
{
private B b;
private E e;
...
}

but your pseudocode looks more like classes B and E are nested classes
inside A.
public class A
{
// other A stuff
...

public class B
{
// other B stuff
...
}
public class E
{
// other E stuff
...
}
}

Depending on which it is there is a different answer.

A small demo program that demonstrates your problem could held as well

Bill





 
Reply With Quote
 
pigeonrandle
Guest
Posts: n/a
 
      8th Aug 2006
Bill,
Sorry. None of them are actually textually nested inside each other,
the classes contain objects of the 'nested' classes.

Cheers,
James.


Bill Butler wrote:
> "pigeonrandle" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > Hi,
> > Funnily enough, i have a question about passing data between classes.
> > There's an excellent diagram below to help drive away any confusion.
> >
> > I have class A which contains an instance of class B and class E.
> > Class B contains an instance of class C.
> >
> > What is the best way to move an object (class D) created in class C to
> > class E?!
> >
> > A
> > {
> > ..B
> > {
> > ....C
> > {
> > ......D (from inside class C)
> > }
> > }
> > ..E
> > {
> > .... (to inside class E)
> > }
> > }
> >

>
> You say that class A contains an INSTANCE of B and E which looks like
> this:
>
> public class A
> {
> private B b;
> private E e;
> ...
> }
>
> but your pseudocode looks more like classes B and E are nested classes
> inside A.
> public class A
> {
> // other A stuff
> ...
>
> public class B
> {
> // other B stuff
> ...
> }
> public class E
> {
> // other E stuff
> ...
> }
> }
>
> Depending on which it is there is a different answer.
>
> A small demo program that demonstrates your problem could held as well
>
> Bill


 
Reply With Quote
 
Ignacio Machin \( .NET/ C# MVP \)
Guest
Posts: n/a
 
      8th Aug 2006
Hi ,

You will have to pass a reference of E to B which will pass it over to C.

Can you give a little more detail about the creation time of all the
instances?


--
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"pigeonrandle" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi,
> Funnily enough, i have a question about passing data between classes.
> There's an excellent diagram below to help drive away any confusion.
>
> I have class A which contains an instance of class B and class E.
> Class B contains an instance of class C.
>
> What is the best way to move an object (class D) created in class C to
> class E?!
>
> A
> {
> ..B
> {
> ....C
> {
> ......D (from inside class C)
> }
> }
> ..E
> {
> .... (to inside class E)
> }
> }
>
> I am currently raising a chain of events in the classes with class D as
> part of the EventArgs. This seems like a rather contrived method so any
> adivice you have will be greatfully received.
>
> Cheers,
> James Randle.
>



 
Reply With Quote
 
pigeonrandle
Guest
Posts: n/a
 
      8th Aug 2006
Ignacio,
Thanks for replying!

It's a little more complicated than my first explanation, but here is
an attempt at a 'better' one.

Class A is a server class that contains class B (a TCP server class),
which in turn contains class C (a TCP client handler class) that is
launched in a separate thread when a connection is made.

Class B is also sat on a different thread to class A.

Class E runs on it's own thread, and is responsible for processing
objects of type Class D that are put into it's queue by class C.

Funnily enough, i have actually already done what you suggested, and as
i add items to the queue using lock(Queue) i assume it will be thread
safe...

Cheers,
James.
Ignacio Machin ( .NET/ C# MVP ) wrote:
> Hi ,
>
> You will have to pass a reference of E to B which will pass it over to C.
>
> Can you give a little more detail about the creation time of all the
> instances?
>
>
> --
> --
> Ignacio Machin,
> ignacio.machin AT dot.state.fl.us
> Florida Department Of Transportation
>
> "pigeonrandle" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > Hi,
> > Funnily enough, i have a question about passing data between classes.
> > There's an excellent diagram below to help drive away any confusion.
> >
> > I have class A which contains an instance of class B and class E.
> > Class B contains an instance of class C.
> >
> > What is the best way to move an object (class D) created in class C to
> > class E?!
> >
> > A
> > {
> > ..B
> > {
> > ....C
> > {
> > ......D (from inside class C)
> > }
> > }
> > ..E
> > {
> > .... (to inside class E)
> > }
> > }
> >
> > I am currently raising a chain of events in the classes with class D as
> > part of the EventArgs. This seems like a rather contrived method so any
> > adivice you have will be greatfully received.
> >
> > Cheers,
> > James Randle.
> >


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
class action lawsuit =?Utf-8?B?d2hlZWxtYW4=?= Windows Vista General Discussion 184 13th Apr 2008 03:05 AM
Best Class Action Suit =?Utf-8?B?RWQ=?= Windows Vista Installation 13 25th Apr 2007 09:05 PM
HDD Class Action Lawsuit PawsForThought Computer Hardware 4 18th Dec 2003 10:19 PM
Re: microsoft class action mrtee Windows XP Setup 0 27th Jul 2003 05:34 PM
microsoft class action Ron Rector Windows XP Setup 0 27th Jul 2003 11:22 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:15 AM.