I'm having some trouble with design at the moment. I guess one of my questions is: Can a problem always be solved using object oriented design? Let me explain the system to you and then I'll elaborate on where I'm having trouble.
I'm writing software to determine the attitude of an aircraft (how it is oriented in 3d space - i.e. bank angle etc.) using an array of GPS receivers. Here are some of the objects I've identified:
1. Satellite: There are m of these
2. Receiver: Receives GPS signals from m space vehicles and outputs measurement data and navigation data. There are n receivers.
3. Baseline: Represents the line vector between between the primary receiver and any secondary receiver. So for n receivers there are n-1 baselines.
4. User: In this case the aircraft. Such attributes would include: position, velocity and attitude.
So in my head I've been saying this:
A user 'has n-1 baselines'.
A baseline 'has 2 receivers' (1 primary and one secondary)
Which I've taking in programming terms to be:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
|
class User{
...
Receiver recs[n];
Baseline baselines[n-1];
...
//Class User will have to give receiver pointers to the baselines.
}
class Baseline{
...
Receiver* primRec;
Receiver* secRec;
...
}
class Receiver{
...
}
|
Now I guess why this is causing me some trouble is because the data is coming into the receivers. To solve for the attitude, data from 2 receivers needs to be combined in the baseline and then data from n-1 baselines need to be combined to get the final attitude solution.
So as you can see, data is floating "up". I'm not used to this.
The event which should trigger the software to attempt to get an attitude solution is when the primary receiver obtains a nav message. So then the primary receiver would have to let all of the baselines know it has the nav message. Then the baselines would have to get data from the receivers and perform some calculations on the data. Then the baselines would need to pass that data to user, where the data from each baseline is used in calculations to determine the attitude of the aircraft, which is then stored in a private variable in the User class.
So this would require that the primary receiver holds pointers to the baselines it is part of or pointers to functions ('eventHandlers') in these Baseline instances. Then further, each baseline would need a pointer to the user object or a function of that user object. So pretty much, it is a mess.
From experience, things are simpler when data flows down - i.e. data would come in at user and filter down the hierarchy. However this can't happen here - or at least I can't see how that would happen here.
Sorry for the long post. Any general guidance would be really appreciated. It just feels weird having so much circular dependency - I think that is what you call it.
So:
1. Does the messy/complicated solution I posted seem reasonable?
2. Should I move away from OOP for this problem?
Again, any help would be greatly appreciated.
Nick.