View Single Post
  #9   Spotlight this post!  
Unread 25-12-2007, 14:18
Phalanx's Avatar
Phalanx Phalanx is offline
Formerly Team 1089 (Mercury)
AKA: Michael Reffler
FRC #5431 (Titan Robotics)
Team Role: Mentor
 
Join Date: Jun 2005
Rookie Year: 1999
Location: Lewisville, TX (previously NJ)
Posts: 384
Phalanx has a reputation beyond reputePhalanx has a reputation beyond reputePhalanx has a reputation beyond reputePhalanx has a reputation beyond reputePhalanx has a reputation beyond reputePhalanx has a reputation beyond reputePhalanx has a reputation beyond reputePhalanx has a reputation beyond reputePhalanx has a reputation beyond reputePhalanx has a reputation beyond reputePhalanx has a reputation beyond repute
Re: Programming style When to use Caps and Underscores?

As others have stated there is no "official" style. Again as others have stated pick a style and stick to it. Being consistent throughout is a bigger benefit than it is usually given credit for.

There's an old saying that I found to be true...
"Programmers don't need to spell correctly, just consistently"

What we have opted for is below with a few exceptions.
lower_case_variable_name
UPPER_CASE_DEFINE_MACRO
Mixed_Case_Function_Call()
We indent everything at each level for clarity as well.

We've also adapted a philosophy of modular code design so we can have different programmers working on different functions concurrently and independently. All functions have "Get" and "Set" functions to allow programmers to access values from each function without needing to access a variable directly.

some examples...

Code:
#DEFINE ZERO 0
int x = 0;
x = Get_Left_Encoder_Count();
Set_Left_Encoder_Count(ZERO);
if (p1_y == 127)
    {
    pwm01 = 127;
    }
else
    {
    pwm01 = p1_y;
    }
__________________
Don't just ask the experts, become one!
Leadership is not about ability. It's about responsibility!
Diagonally Parked in a Parallel Universe. It's okay we do Quantum Physics



Last edited by Phalanx : 25-12-2007 at 14:27.