in reply to Re: Re: inheritance and object creation
in thread inheritance and object creation
I think if you have to model the differences in polygons with an object model, you are really taking your object model too far down.I didn't say polygons. I said shapes.
The polygon class should be sufficiently advanced to take arbitrary constraints and handle all properties generically.Even if I were to be talking about polygons, I still don't agree with that. If you follow such reasoning all the way through, you would never subclass. Instead, you would make you one and only base class more generic.
There shouldn't have to be classes for that, and to a mathematician, rules for a 71-sided polygon with equal angles are scarely different than a quad... the numbers just come out cleaner.But as I said, I was thinking about shapes, and properties of shapes. For instance, let's talk about simple symmetries. All parallelograms have a rotational point of symmetry (180 degrees around their center). This is not true for all 71-sided polygons - in fact, 71 being odd, there is no 71-sided polygon that has a 180 degree rotational symmetry. Every rectangle has two lines of symmetry - the lines dividing opposite sides, and whatever symmetry a parallelogram has. Every rhombus has two lines of symmetry, but different lines than the rectangle, namely the diagonals. And in addition, it has the symmetries a parallelogram has. Finally, a square has a 90 degree rotational symmetry, a -90 degree rotation symmetry, and the symmetries of a rectangle, and the symmetries of a rhombus.
So, my question remains, what kind of inheritance tree would you use? (And keep in mind, the tree is just part of a bigger picture, there may be hundreds of other shapes as well. If you want to collapse them into one general class, you'll have to do a lot of case statements, and you're back to non-OO programming).
Abigail
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Shapes don't need inheritance
by dragonchild (Archbishop) on Feb 25, 2004 at 18:07 UTC | |
by Abigail-II (Bishop) on Feb 25, 2004 at 19:43 UTC | |
by dragonchild (Archbishop) on Feb 25, 2004 at 19:51 UTC | |
by Abigail-II (Bishop) on Feb 25, 2004 at 20:01 UTC | |
|
Re: Re: inheritance and object creation
by flyingmoose (Priest) on Feb 24, 2004 at 15:00 UTC | |
by Abigail-II (Bishop) on Feb 24, 2004 at 15:12 UTC |