473,411 Members | 2,080 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,411 software developers and data experts.

Class Action

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.

Aug 8 '06 #1
4 1921
"pigeonrandle" <pi**********@hotmail.comwrote in message
news:11**********************@n13g2000cwa.googlegr oups.com...
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

Aug 8 '06 #2
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" <pi**********@hotmail.comwrote in message
news:11**********************@n13g2000cwa.googlegr oups.com...
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
Aug 8 '06 #3
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" <pi**********@hotmail.comwrote in message
news:11**********************@n13g2000cwa.googlegr oups.com...
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.

Aug 8 '06 #4
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" <pi**********@hotmail.comwrote in message
news:11**********************@n13g2000cwa.googlegr oups.com...
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.
Aug 8 '06 #5

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

Similar topics

1
by: Phil Powell | last post by:
Consider this: class ActionHandler { ...
0
by: James | last post by:
Running on Xp with WSAD5.0.1 (acts the same in 5.1) an action class is simply not being called when it is configured identically with others called in the same manner. It never gets into the...
6
by: John | last post by:
I'm inheriting from multiple abstract base classes (2 to be exact). In the inherited class I want to know if I can implement two pure virtual methods (one from each base class) having the same...
0
by: keith bannister via .NET 247 | last post by:
(Type your message here) -------------------------------- From: keith bannister Hi, I'm new to .net (as of last week) but here goes. I want to serialize/deserialize a file the conforms...
5
by: Keith Bannister | last post by:
I'm new to .net so here goes. I'm tying to deserialize a class that is associated with an XML schema. I created the C# class with xsd.exe as below: xsd.exe /c /n:somenamespace...
3
by: Mark Assousa | last post by:
Hi, I'm having trouble finding the right news group for this posting so here goes... I am attempting to execute some special actions within an installation project for a standard .Net Windows...
3
by: shanmukhi | last post by:
hi all, i got a problem with struts. iam unable to find it. i have written an action class, form bean class and a jsp page on submitting form, request is going to action class but it is not...
8
by: shapper | last post by:
Hello, I am working with VS 2008 and created a Web Application Project. I added a class but whatever I do the class is not visible to my aspx pages or anywhere else. I then changed the...
25
by: Jeremy Banks | last post by:
Hi. I wondered if anyone knew the rationale behind the naming of the Popen class in the subprocess module. Popen sounds like the a suitable name for a function that created a subprocess, but the...
1
by: seanacais | last post by:
I want to create a class derived from a Borg class that can instantiated as part of a script or be contained in other classes. When methods from the Borg class are called, I would like to know the...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
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...

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.