Code Design

Desired Attributes

Object Oriented

We don't use a procedural interface for the TPSAPI because TPS requires that we mix and match many different peices that are much more easily organized as classes with abstract interfaces than functions.

Class Names

Class names are meant to be clear and represent their function. All classes begin with the letters "Tps." Derived classes retain their base class name as a root, for example:

class TpsTrajectoryUniformStep: public TpsTrajectory
{
        ...
};

References

We aim to create a Java-like API where no pointers are ever passed as part of the interface. Rather, all objects are passed by reference.

class TpsTrajectory
{
        public:
                TpsTrajectory(TpsSimulationPlugin&, int=-1, int=-1);
                ...
        protected:
                ...
                TpsSimulationPlugin& _sim;
                
};

Now the class TpsTrajectory contains a reference to a specific instance of a TpsSimulationPlugin. Any changes made to the simulation will apply to the trajectory.

Explicit Constructors

All classes should take everything that they need during construction. They should contain "set" functions so that these settings can be modified later.
class TpsTrajectory
{
        public:
                TpsTrajectory(TpsSimulationPlugin&, int min=-1, int max=-1);
                void setSimulationPlugin(TpsSimulationPlugin&);
                void setMin(int);
                void setMax(int);
                ...
        protected:
                ...
                TpsSimulationPlugin& _sim;
                
};

Constructors should take default arguments so that they don't become long and unweildly.


Generated on Tue Jul 21 15:52:40 2009 for TPS by  doxygen 1.5.9