First, you need to be clear whether your Aircraft class represents an
instance of a single Aircraft, or a type of Aircraft, such as a Cessna 195.
If it represents a single Aircraft, then I would assume that there is a
single Owner. If it represents a type of Aircraft, then it would have no
Owner. So, if it is a single Aircraft, you're talking about a one-to-many
relationship of Owners to Aircraft instances. If so, there would be one
Owner per Aircraft, and many Aircraft (o or more) to each Owner. If so,
there is no recursion involved. To find the Owner of a single Aircraft
instance, you look at the Owner property. To find all Aircraft for an Owner,
you look at the AircraftList property of the Owner. Similarly, to find all
Aircraft owned by the Owner of an Aircraft, you look at the AircraftList
property of the Owner property of the Aircraft.
--
HTH,
Kevin Spencer
Microsoft MVP
Ministry of Software Development
http://unclechutney.blogspot.com
Any experience you can walk away from
is a good one.
<li******@gmail.comwrote in message
news:11**********************@h48g2000cwc.googlegr oups.com...
>I have been working with objects long enough to have the basics down,
but some things give me fits, and this is one of them.
Brief description:
I have an airplane object, and each airplane has an owner.
Likewise I have a customer object and each customer has a list of
airplanes.
The basic structure of my objects is: (ignoring public/private for
clarity)
public class Aircraft
{
int ID;
string Series;
List<Aircraft_OptionsOptionList;
Customer Owner;
/* Assorted Methods */...
}
public class Customer
{
int ID;
string Name;
List<AircraftAircraftList;
/* Assorted Methods */...
}
I want Aircraft to have the Customer object for reference when I grab
the Aircraft List, and obviously when I grab the Customer I want access
to all the associated aircraft. It seems to me I'll run into problems
with recursion. I considered a limited Customer class for Aircraft to
have, but that doesn't strike me as efficient.
How should I best deal with this situation?