Modelling question - make more generic or risk of over-engineering?

From: Andrew Quine (andrew_quine_at_fastmail.fm)
Date: 01/10/04


Date: 10 Jan 2004 10:11:13 -0800

Hi

I have a system of Shapes and Paths. Here's a full description:

Paths are composed of at least two Points (the start and end Points of
the Path and other 'internal' Points in the Path). Paths can exist
independently. Also, each Path can have its start associated with a
Shape or finish associated with a Shape (or both) i.e. a Path can be
associated with 0..2 Shapes.

When a Shape moves, any Path with an association to that Shape and its
end Points (i.e. start or finish Point) needs to update those Points
to "keep in sychronization" with the moving Shape.

The way it is being currently modelled is as follows: a Path has a
collection of Points and also two references to Shapes (startShape and
finishShape which can be both null, either referencing a Shape, or
both having references to Shapes). A constraint is put on via the
constructor of the Path so that it is supplied with at least two
Points.

When any Shape reference is updated an Observer is put in place
between the Path and the Shape in order to keep any Path's end points
up to date with any associated Shape movements.

There are explicit accessors/modifiers on the Path for StartShape,
EndShape, StartPoint, EndPoint.

That's it!

Now, for the questions. I keep on thinking about the fact that there
are the possibly null references to exactly two Shapes. Is there a
better way to model the situation I have? Would it be worth treating
the end Points as different from other Points and perhaps having a new
class EndPoint which is composed of a Point and a Shape reference,
possibly null. But then the null reference still troubles me.

More generically, I started thinking about a 'constraint' system which
would help a future requirement. Namely that, as well as moving Shapes
altering the attached end Points of the Path, there will also be a way
to 'select' any set of the Points and have them adjusted by some
external mechanism (actually the mouse moving once that Path has been
selected :-) ). Now it sounds like Points should 'exist in their own
right' i.e. have the ability to be synchronized via observation and so
not just have the Path dealing with the special cases of Shapes being
attached to a Path's end Points. But is this over the top? I'm having
difficulty in the area between possibly over-engineering something but
not knowing whether some remodelling is necessary.

How do others go about modelling this sort of basic situation - both
the current state (mainly the worry about the null references) and
also in view of the future requirement (all Points moving around based
on external factors)?

Well, thanks for reading and hope to hear a few ideas!

Cheers

Andrew Quine
Underscore + fastmail.fm



Relevant Pages

  • Re: New to SQL server
    ... [CONSTRAINT constraint_name] ... | [FOREIGN KEY] ... Is the name of the database in which the table is created. ... REFERENCES permission on the type is ...
    (microsoft.public.access.adp.sqlserver)
  • Re: Modelling Disjoint Subtypes
    ... constraints one should have are foreign key references. ... exactly prevents one from using a foreign key constraint to enforce ... enforces a constraint between columns in two tables. ... columns in N tables (where there are N-1 subtypes). ...
    (comp.databases.theory)
  • Re: Foreign Key Problem errno 150
    ... CONSTRAINT `FK_tblstammblatt_aufsteck` FOREIGN KEY REFERENCES ... So interpretiere ich die Anleitung. ...
    (de.comp.datenbanken.mysql)
  • Re: Use a variable number of fields
    ... it) that embedding logic and business rules into the underlying data ... REFERENCES Classes, ... CHECK constraint can be replaced by a record-level Validation Rule. ...
    (microsoft.public.access.tablesdbdesign)
  • Re: Modelling Disjoint Subtypes
    ... the only constraints one should have are foreign key references. ... I think the answer is that a foreign key constraint enforces a constraint between columns in two tables. ... these tables also have a primary key K which references K as a foreign key. ...
    (comp.databases.theory)