Re: Help with OO Model

Tech-Archive recommends: Fix windows errors by optimizing your registry



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


.



Relevant Pages

  • Domain Model/Object Design question
    ... finding the correct design pattern. ... A class "Publisher", which is a type of company with a particular ... "Manufacturer" as well, since they create books, but they do more than ... A company can be a manufacturer, publisher or distributor, or any ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Help with OO Model
    ... A Publisher is a Company ... A Manufacturer is a Company ... A Distributor is a Company ... public class Distributor: Role ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Help with OO Model
    ... The key to your problem is I think that you want to compose companies dynamically, at run time in the client code. ... Publisher OJWhoDunItInc = new Publisher; ... A Manufacturer is a Company ... A Distributor is a Company ...
    (microsoft.public.dotnet.languages.csharp)
  • Help with OO Model
    ... I have a class Company, a class Publisher, a class Manufacturer and a class ... A Publisher is a Company ... A Distributor is a Company ... Manufacturer.Product when I'm dealing with non-printed material. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: Inactive Publisher??????
    ... The publisher name is in ALL CAPS. ... disabling distribution on the distributor and then rebooting ... made sure the other server was set up for publication. ... I then imported data from the publisher to the subscriber so that the ...
    (microsoft.public.sqlserver.replication)