Re: Help with OO Model
- From: Bob Jones <robert@xxxxxxxxxxxxxx>
- Date: Sun, 24 Dec 2006 13:14:59 -0600
Apologies for the multiple postings.
I wanted to add one more thing..... I noticed you said of products "... I would like to return it's creator". Use Reflection.
Every object we create in C# inherits the GetType() method. This method returns an instance of the Type (capital Tee) class. This class is the basis of reflection. This class tells you everything you want to know about the given object. What properties and methods it has, it's inheritance chain, etc.
So in the example code where I show passing in a string: xxx.GetCompany ("Distributor"), you can pass in the actual class type (not the Distributor object mind you, just it's class type as extracted from xxx.GetType()) and not have to deal w/ maintaining strings to represent the various company classes.
On 2006-12-22 15:19:03 -0600, "Marc De Schrijver" <marc.deschryver1@xxxxxxxxxx> said:
I'm designing an OO Model for a large application, and I have some question
on how to model a particular situation; it's not directly related to C# but
rather to general OO. The applicaiton will be developed in C# 2.0 though,
which may have some influence on the OO model.
Here's what I'm trying to model:
I have a class Company, a class Publisher, a class Manufacturer and a class
Distributor.
Their relationships are as follows:
1. A Publisher is a Company
2. A Manufacturer is a Company
3. A Distributor is a Company
6. A Company can be just a distributor
4. A Company can be just a publisher or a publisher and distributor at the
same time
5. A Company can be just a manufacturer or a manufacturer and distributor at
the same time
7. A Company can be a publisher, manufacturer and distributor all at the
same time
A Publisher and a Manufacturer are very similar in that they both create a
product; however, I think of the two roles differently and would prefer to
maintain them as different entity types. I would like to see code like
Publisher.Product when I'm dealing with printed material and
Manufacturer.Product when I'm dealing with non-printed material.
On the other hand, given a Product I would like to be able to return its
creator, which could be either a manufacturer or a publisher, depending on
the kind of product.
Any insights or recommendations are greatly appreciated.
-- Hans
.
- References:
- Help with OO Model
- From: Marc De Schrijver
- Help with OO Model
- Prev by Date: Re: How to customized typedDataSet with VS designer
- Next by Date: Re: a confusing problem relative to C# thread!
- Previous by thread: Re: Help with OO Model
- Next by thread: Re: Help with OO Model
- Index(es):
Relevant Pages
|