Quote:
Originally Posted by MagiChau
You are going to teach them all to abuse if then statements like proper programmers should right? 
|
Actually, I am almost scared of if statements with more than 3 if then statements.

I try to keep them at 2 or under. Or, in fact, even eliminate them. Well personally I think that comes with experience. Or it might just be my strange personality. I try to find that one equation that can do a whole bunch of if then statements can do. That is why I had so many feuds with the other programmer; he tries to code high level and I try to code the lowest level I can.
I think programming styles differ from one person to another. I was a if then statement spammer in my earlier years; but I just changed somehow. But I always stay away from recursive functions or anything like that. My mind functions more efficiently with equations rather than whatever you call recursive functions.
edit: This is what I mean; my drive code:
Code:
if(y <= pow(x, 2)/3 + 0.2 && y >= pow(x, 2)/-3 - 0.2)//pow is x^2 It is the dead zone for zero point turning. We can live with the else statement.
{
pwm1 = x * 127 + 128;
pwm2 = x * 127 + 128;
}
else
{
pwm1 = (pow(y, 3) * 127 + 128) + (pow(x, 3) * 70);//x^3
pwm2 = (pow(y, 3) * 127 + 128) - (pow(x, 3) * 70);
}
regulate();//Just makes sure it does not go out of range