XRobots / openDog

CAD and code for each episode of my open source dog series
GNU General Public License v3.0
830 stars 189 forks source link

Use Enum in code #18

Open maisonsmd opened 5 years ago

maisonsmd commented 5 years ago

You should use enum (or at least #define) to name constants such as LEFT_LEGS, RIGHT_LEGS,... instead of using number like 0, 1 which decreases the code readability. for example:

enum LegSides{
    LEFT_LEGS = 0,
    RIGHT_LEGS = 1
};

or just forget the numbers:

enum LegSides{
    LEFT_LEGS,
    RIGHT_LEGS
};

then the function:

double leg(double Z, double Y, double X2, int side) {...}

will be:

double leg(double Z, double Y, double X2, LegSides side) {...}

and call it:

leg(x, y, z, LEFT_LEGS);

further here