Hello all,
I hope that this topic is considered valid in this group. If not,
could you (kindly) point me to where I should post it?
I am having a bit of trouble deciding where to place objects within my
design. I have been following the "has a" "is a" guidelines so far.
I now have an "is acted upon by" and an "is constrained by" which I
don't know how to resolve.
I am designing some orbital analysis software (I am sure I am
reinventing a wheel, however ... ). I have one vehicle which can
travel many trajectories, i.e., standard orbit (trajectory) -> thrust
trajectory -> elliptical parking orbit -> thrust trajectory -> sling-
shot orbit, etc. With this thought, I created a parent trajectory
class from which I create (via extension) the various trajectories I
need.
Here is my problem statement:
Within each trajectory the vehicle is acted upon by several
perturbations (gravity, solar wind, etc.) and is constrained to
perform actions when in view of a ground station.
While the vehicle is the object experiencing the perturbations and
constraints, the perturbations and constraints can be different for
each trajectory, so I thought that I should add the perturbations and
constraints to the Trajectory class, but this feels wrong since:
a vehicle has a trajectory
the vehicle is acted upon by perturbations
the vehicle is constrainted by various things
which makes me think that these all belong in the vehicle class.
So, do I fish or cut bait?
Todd
Eric Sosman - 05 Sep 2007 19:06 GMT
Todd wrote On 09/05/07 12:40,:
> Hello all,
>
[quoted text clipped - 29 lines]
>
> which makes me think that these all belong in the vehicle class.
It's not clear to me just how you intend to model
all these interactions and constraints, but one way to
approach them might be for each Vehicle object to have
a collection of Perturbers and Constrainers. Or dually,
each Perturber or Constrainer could have a collection of
the Vehicles it influences. Or you could use a separate
Interaction object to represent the influence of a
particular Perturber/Constrainer on a particular Vehicle.
This is not meant to be an exhaustive list ...

Signature
Eric.Sosman@sun.com
Daniel Pitts - 05 Sep 2007 21:16 GMT
> Hello all,
>
[quoted text clipped - 32 lines]
> So, do I fish or cut bait?
> Todd
Or, perhaps you're missing something here... The Simulator class. The
simulator keeps track of what is where.
Think of it this way? What does a glass of water on a table, and a
heat lamp above it have in common? They all exist in universe.
The heat lamp doesn't have water or a table, yet it affects them. The
water doesn't have a table or a heat lamp, and yet is affected by
them.
You might say the table "has a" glass which "has a" water in it.
class Universe {
HeatLamp lamp;
Table table;
public void unpdate() {
lamp.heat(table);
}
}
class HeatLamp implements Positionable {
public void heat(Heatable heatable) {
heatable.absorbeHeat(getHeatValue().dissipate(getDistanceTo(heatable)));
}
}
public Table implements Heatable {
Glass glass;
public void absorbeHeat(HeatValue heatValue) {
surfaceTemp.adjust(heatValue);
glass.absorbeHeat(heatValue);
}
}
Hope this example helps.