from an OOP standpoint what we are talking about is the difference between Inheritance, Composition and Aggregation.
Inheritance is the
TRabbit would generally be able to use the code [the behaviors and attributes] from TAnimal. A Rabbit "is an" Animal.
Composition is a form of "Has-a". A Type is made up of other types.
Aggregation is very similar to Composition. The major difference (the litmus test) is:
"If the base type is destroyed, do the composed types live on?"
A common example would be a duck pond:
If the Pond is destroyed (drained, whatever) the Ducks would continue to exist.
anyway. You will probably use a combination of Inheritance and Composition/Aggregation but From what I have read (just enough to be dangerous) you should Favor Composition over inheritance.
Inheritance is the
Type TRabbit Extends TAnimal
TRabbit would generally be able to use the code [the behaviors and attributes] from TAnimal. A Rabbit "is an" Animal.
Composition is a form of "Has-a". A Type is made up of other types.
Type TSpaceship Field Weapon:TWeapon Field ShipEntity:Tentity end type
Aggregation is very similar to Composition. The major difference (the litmus test) is:
"If the base type is destroyed, do the composed types live on?"
A common example would be a duck pond:
Type TPond Field List_of_Ducks:TList End type
If the Pond is destroyed (drained, whatever) the Ducks would continue to exist.
anyway. You will probably use a combination of Inheritance and Composition/Aggregation but From what I have read (just enough to be dangerous) you should Favor Composition over inheritance.