Modelling question - make more generic or risk of over-engineering?
From: Andrew Quine (andrew_quine_at_fastmail.fm)
Date: 01/10/04
- Next message: Dave Benjamin: "Re: TDD *will* solve world hunger"
- Previous message: Robert C. Martin: "Re: TDD: Test-Driven Design or Test-Driven Development?"
- Next in thread: Phlip: "Re: Modelling question - make more generic or risk of over-engineering?"
- Reply: Phlip: "Re: Modelling question - make more generic or risk of over-engineering?"
- Reply: Daniel T.: "Re: Modelling question - make more generic or risk of over-engineering?"
- Reply: H. S. Lahman: "Re: Modelling question - make more generic or risk of over-engineering?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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
- Next message: Dave Benjamin: "Re: TDD *will* solve world hunger"
- Previous message: Robert C. Martin: "Re: TDD: Test-Driven Design or Test-Driven Development?"
- Next in thread: Phlip: "Re: Modelling question - make more generic or risk of over-engineering?"
- Reply: Phlip: "Re: Modelling question - make more generic or risk of over-engineering?"
- Reply: Daniel T.: "Re: Modelling question - make more generic or risk of over-engineering?"
- Reply: H. S. Lahman: "Re: Modelling question - make more generic or risk of over-engineering?"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|