Re: Architecting Dilemma
- From: "jeff" <jhersey at allnorth dottt com>
- Date: Wed, 11 Apr 2007 04:58:06 -0700
i think you are using inheritance wrong ... inheritance is for things
like...
BaseClass ... Person ... properties ... name, age, sex, DoB
PatientClass inherits from PersonClass and includes these additional
properties ... ChartNumber
PhysicianClass inherits from PersonClass and includes these additional
properties ... CollegeOfPhysicianID ...
SpecialistClass inherits from PhysicianClass and includes these additional
properties ... SpecialtyCode
So a patient has a name, age, sex, DoB and ChartNumber property
Physician has a name, aga, sex, DoB and CollegeOfPhysicianID
Specialist has a name, age, sex, DoB, CollegeOfPhysicianID and SpecialtyCode
If you want to record Eye Color for all Persons, you simple add the Property
to the Base PersonClass and ALL people now have EyeColor.
If you want to record CountryOfOrigin for each physician, you simply add
this property to the PhysicianClass and now you have it for All physicians,
including Specialist.
Inheritance allows you to 'extend' a base class to better reflect your
business object. It is not intended to model relationships.
What you describe here, if I am reading correctly is a relationship.
There are many FOO's in a Widget
There are many Widgets in a Piece ...
Is this the relationship ...
Foo is many to 1 Widget
Widget is many to 1 piece
If this is the case, than you are dealing with three seperate classes ...
that ARE related, not INHERITENT. You do not use INHERITENCE to should
RELATIONSHIP, you use inheritence to extend a class to better suit your
object.
What I would do is ...
Create Foo Class...
- make the properties specific to the FOO object.
Create a Widget Class...
- make the properties specific to the Widget object
- one property will be a Collection of FOO's ...
Create a Piece Class
- make the properties specific to a piece
- one property will be a collection of widgets.
This is assuming I am reading your request correctly...If I am not correct,
the please ignore.
Thanks
Jeff
"John Wright" <riley_wrightx@xxxxxxxxxxx> wrote in message
news:e4y2Nh7eHHA.2376@xxxxxxxxxxxxxxxxxxxxxxx
Here is the situation. We are rearchitecting an application from VB 6.0
to VB.NET 2005. Of course in VB6 there was no OOP so there are lots of
CLS files that do the work for each object type. I am proposing creating
a base class object that contains all the common properties and methods
for an object, then using inheritance, creating specific types of objects
from the base class. This is not a problem. This is a manufacturing
application and the manufacturing process is FOO ---> Widget --->Piece.
All Widgets are created from FOO's and all Pieces are created from
Widgets. I have proposed creating a Widget base class and inheriting the
Piece classes from Widget. Widget will contain the FOO ID and FOO Part
Number as read only properties since they are really the only thing needed
for the Piece class. Not a problem. So to create a FOO I do the following
(pseudocode)
Dim x as new FOO
x.ID = 5
x.PartNumber = "12345B"
x.Weight = 2500
x.Traveler = "FOO 124(4)"
x.Standard = "FOO 344-(J)"
x.ChemistryID = 44
x.update.
This creates a new FOO item. Next I need to create a Piece from Widget so
pseudocoding again, I create a Piece Class (inheriting from Widget):
Dim Y as new Piece(54)
y.traveler = "Piece12345A" 'Set in Widget since all pieces have a
traveler
y.Standard = "Standard1234" 'Set in Widget since all pieces have a
standard
y.weight = 32 'Set in the Piece class since not all pieces have a weight
y.Step = 44 'Set in Widget since all pieces have a traveler step
y.PartNumber = "PieceX" 'Set in Widget since all pieces have a PartNumber
y.Batch = "44x" 'Set in Piece since not all pieces have a batch
y.FOOID = FOOID 'Readonly from the Widget Class
y.FOONumber = FOONumber 'Readonly from the Widget class
y.update
Now for the big question. While MOST of the time we only need the FOOID
and FOONumber as readonly data, there are occasions where someone would
need more information such as the chemistry and the weight (there will be
some cases where weight would be very necessary), should we create two
classes for FOO? One class would be created when we are creating a FOO
for the first time and entered into the system, the other would be
readonly data that a function in Widget would create. Example:
Public Class FOO
_Weight as Long
_ID as integer
_PartID as string
Properties here
Methods here
Public Class FOO2
_Weight as Long
_ID as integer
_PartID as string
Readonly Properties here
No methods.
Then call the class properties as follows:
Public Class Widget
'Widget Properties
Dim _X as new FOO2 ([ID])
Public Readonly Property FOOWeight as long
Return _x.Weight
Or should I create one FOO class and set readonly properties for FOO in my
Widget Class and set them as appropriate.
Public Class Widget
Dim _FOOID as Integer
Dim _FOONumber as String
Dim _FOOWeight as long
Public Readonly Property _FOOWeight as Long
return _FOOID
...More FOO Read only properties
...Widget Properties
...Widget Events
...Widget Methods
I know this is a lot but I would like some direction.
Thanks.
John Wright
.
- References:
- Architecting Dilemma
- From: John Wright
- Architecting Dilemma
- Prev by Date: Re: Easiest possible error handling?
- Next by Date: Re: Plzzzzzzzzzzz Help for callback function
- Previous by thread: Re: Architecting Dilemma
- Next by thread: Re: Architecting Dilemma
- Index(es):
Relevant Pages
|
Loading