[cad-linux-dev] Re: polymorphic inheritance

  • From: Bruno Postle <bruno@xxxxxxxxxx>
  • To: CAD linux development <cad-linux-dev@xxxxxxxxxxxxx>
  • Date: Wed, 25 Aug 2004 11:47:03 +0100

On Tue 24-Aug-2004 at 15:22 -0500, Eric Wilhelm wrote:
> 
> >polymorphic inheritance.
> 
> What exactly do you mean by that?  Is the inheritance in types or
> references?

References.  Sorry, was just throwing words around without
explaining what I mean.

Say you have a drawing showing the elevation of a door, it has a
window, some trim and a doorhandle.  In a project you've reused this
as a standard library item using xref (ignore the fact that AutoCAD
is slow as hell when using xrefs this way).

Suddenly you have a need for a drawing of a door that has a
pushplate instead of a handle.  With a normal CAD system you have
the following options:

1. Create a fresh new door drawing and use that throughout.

   Drawback: there is no "code-reuse", the two doors are now not
   related in any way.

2. Go back and fix the original door drawing so that it is itself a
   combination of two drawings - A blank door and a handle.  Then
   reassemble a new door-with-pushplate drawing from these bits and
   use that.

   Drawback: you are tinkering with an item that might be being used
   in a unknown number of locations by other people - Better get it
   right or this could be *very* expensive (for this reason, you
   probably don't have write-permissions on the file in the first
   place).

This is similar to the kind of problem programmers face.  With
object-oriented programming, if you have a method that shouldn't be
there or needs to behave differently, just subclass the object and
rewrite the method.

With a directory-based CAD file-format you can have this 3rd option,
because every element that is used to define the door-handle is an
independent file with a persistent address.

With Draft, a reference (block/xref) element has a list that can
point to one or more 'drawings' (hence "multiple inheritance").  It
also has an 'ignore' list of elements - So a door can be subclassed.

> If you are addressing individual files outside of a drawing, you
> are going to kill the "grep litmus test."
> 
> I think anything to do with inheritance and references takes us
> too far towards relational drafting.  That doesn't fit the
> rhizopod model.

Yes, none of this has any relevance when using a hub as an
intermediary between existing CAD tools.

Though the other litmus test of a "good idea" is that it makes
possible things that were never possible before.

> So, are you already designing the "sardine" spec here?

No, I'm designing an extension to the spec for the 'reference'
object, I want everything else to be identical to rhizopod.  If I
can tag these extended reference elements with "version: foo", then
your library will know not to bother interpreting them - It will
spit out a warning and won't core dump on people.

-- 
Bruno

Other related posts: